Add a cvar for FOV color (#3741)

This commit is contained in:
metalgearsloth
2023-02-12 08:56:45 +11:00
committed by GitHub
parent 0d8032e3df
commit 72b5735349
6 changed files with 29 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ END TEMPLATE-->
### New features
*None yet*
* The FOV color is now configurable via the "render.fov_color" cvar
### Bugfixes

View File

@@ -5,6 +5,7 @@ preset raw;
#include "/Shaders/Internal/fov_shared.swsl"
const highp float g_MinVariance = 0.0;
uniform highp vec4 occludeColor;
void fragment()
{
@@ -19,5 +20,5 @@ void fragment()
discard;
}
COLOR = vec4(0.0, 0.0, 0.0, 1.0 - occlusion);
COLOR = vec4(occludeColor.rgb, 1.0 - occlusion);
}

View File

@@ -5,6 +5,7 @@ preset raw;
#include "/Shaders/Internal/fov_shared.swsl"
const highp float g_MinVariance = 0.0;
uniform highp vec4 occludeColor;
void fragment()
{
@@ -18,5 +19,5 @@ void fragment()
discard;
}
COLOR = vec4(0.0, 0.0, 0.0, 1.0);
COLOR = vec4(occludeColor.rgb, 1.0);
}

View File

@@ -813,6 +813,10 @@ namespace Robust.Client.Graphics.Clyde
fovShader.SetUniformTextureMaybe(UniIMainTexture, TextureUnit.Texture0);
if (!Color.TryParse(_cfg.GetCVar(CVars.RenderFOVColor), out var color))
color = Color.Black;
fovShader.SetUniformMaybe("occludeColor", color);
FovSetTransformAndBlit(viewport, eye.Position.Position, fovShader);
GL.StencilMask(0x00);
@@ -856,6 +860,7 @@ namespace Robust.Client.Graphics.Clyde
GL.StencilOp(TKStencilOp.Keep, TKStencilOp.Keep, TKStencilOp.Replace);
CheckGlError();
fovShader.SetUniformMaybe("occludeColor", Color.Black);
FovSetTransformAndBlit(viewport, eye.Position.Position, fovShader);
if (_hasGLSamplerObjects)

View File

@@ -1912,5 +1912,20 @@ namespace Robust.Shared.Maths
{
return DefaultColorsInverted.TryGetValue(this, out var name) ? name : null;
}
public static bool TryParse(string input, out Color color)
{
if (TryFromName(input, out color))
return true;
var nullableColor = TryFromHex(input);
if (nullableColor != null)
{
color = nullableColor.Value;
return true;
}
return false;
}
}
}

View File

@@ -6,6 +6,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Physics;
@@ -718,6 +719,9 @@ namespace Robust.Shared
public static readonly CVarDef<double> RenderSpriteDirectionBias =
CVarDef.Create("render.sprite_direction_bias", -0.05, CVar.ARCHIVE | CVar.CLIENTONLY);
public static readonly CVarDef<string> RenderFOVColor =
CVarDef.Create("render.fov_color", Color.Black.ToHex(), CVar.ARCHIVE | CVar.CLIENTONLY);
/*
* DISPLAY
*/