Lighting: Polar Coordinates fix: Sparkle-Be-Gone (#1345)

This commit is contained in:
20kdc
2020-10-24 14:51:17 +01:00
committed by GitHub
parent 6bbc4b01e9
commit 4f6a4c8a28
5 changed files with 30 additions and 3 deletions

View File

@@ -729,6 +729,20 @@ namespace Robust.Client.Console.Commands
}
}
internal class ToggleHardFOV : IConsoleCommand
{
public string Command => "togglehardfov";
public string Description => "Toggles hard fov for client (for debugging space-station-14#2353).";
public string Help => "togglehardfov";
public bool Execute(IDebugConsole console, params string[] args)
{
var mgr = IoCManager.Resolve<ILightManager>();
mgr.DrawHardFov = !mgr.DrawHardFov;
return false;
}
}
internal class ToggleShadows : IConsoleCommand
{
public string Command => "toggleshadows";

View File

@@ -297,7 +297,7 @@ namespace Robust.Client.Graphics.Clyde
RenderOverlays(OverlaySpace.WorldSpace);
if (_lightManager.Enabled && eye.DrawFov)
if (_lightManager.Enabled && _lightManager.DrawHardFov && eye.DrawFov)
{
ApplyFovToBuffer(viewport, eye);
}

View File

@@ -25,6 +25,12 @@ uniform float shadowOverlapSide;
// also deal with the reference to it in shadow_cast_shared
const highp float PI = 3.1415926535897932384626433;
// expands wall edges a little to prevent holes
const highp float DEPTH_LEFTRIGHT_EXPAND_BIAS = 0.001;
// added to zbufferDepth BEFORE divide
// really just keep at 1.0 (keeps it away from the near clipping plane)
const highp float DEPTH_ZBUFFER_PREDIV_BIAS = 1.0;
void main()
{
// aPos is clockwise, but we need anticlockwise so swap it here
@@ -33,6 +39,11 @@ void main()
float xA = atan(pA.y, -pA.x);
float xB = atan(pB.y, -pB.x);
// expand bias
float lrSignBias = sign(xB - xA) * DEPTH_LEFTRIGHT_EXPAND_BIAS;
xA -= lrSignBias;
xB += lrSignBias;
// We need to reliably detect a clip, as opposed to, say, a backdrawn face.
// So a clip is when the angular area is >= 180 degrees (which is not possible with a quad and always occurs when wrapping)
if (abs(xA - xB) >= PI)
@@ -66,7 +77,7 @@ void main()
// because GLES SL 1.00 doesn't have gl_FragDepth.
// Keep in mind: Ultimately, this doesn't matter, because we use the colour buffer for actual casting,
// and we don't really need to have correction
float depth = 1.0 - (1.0 / length(mix(pA, pB, subVertex.x)));
float zbufferDepth = 1.0 - (1.0 / (length(mix(pA, pB, subVertex.x)) + DEPTH_ZBUFFER_PREDIV_BIAS));
gl_Position = vec4(mix(xA, xB, subVertex.x) / PI, mix(1.0, -1.0, subVertex.y), depth, 1.0);
gl_Position = vec4(mix(xA, xB, subVertex.x) / PI, mix(1.0, -1.0, subVertex.y), zbufferDepth, 1.0);
}

View File

@@ -6,5 +6,6 @@ namespace Robust.Client.Graphics.Lighting
{
public bool Enabled { get; set; } = true;
public bool DrawShadows { get; set; } = true;
public bool DrawHardFov { get; set; } = true;
}
}

View File

@@ -4,5 +4,6 @@
{
bool Enabled { get; set; }
bool DrawShadows { get; set; }
bool DrawHardFov { get; set; }
}
}