Opt out of shadow casting for some lights (#2085)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
mirrorcult
2021-10-09 09:21:22 -07:00
committed by GitHub
parent 39eb1a7d75
commit ffb3800664
3 changed files with 10 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ void fragment()
highp vec2 diff = worldPosition - lightCenter;
// Totally not hacky PCF on top of VSM.
highp float occlusion = createOcclusion(diff);
highp float occlusion = lightIndex < 0.0 ? 1.0 : createOcclusion(diff);
if (occlusion == 0.0)
{

View File

@@ -120,6 +120,12 @@ namespace Robust.Client.GameObjects
set => _visibleNested = value;
}
/// <summary>
/// Whether this pointlight should cast shadows
/// </summary>
[DataField("castShadows")]
public bool CastShadows = true;
[DataField("nestedvisible")]
private bool _visibleNested = true;
[DataField("autoRot")]

View File

@@ -361,6 +361,8 @@ namespace Robust.Client.Graphics.Clyde
{
var (light, lightPos, _) = lights[i];
if (!light.CastShadows) continue;
DrawOcclusionDepth(lightPos, ShadowMapSize, light.Radius, i);
}
}
@@ -459,7 +461,7 @@ namespace Robust.Client.Graphics.Clyde
}
lightShader.SetUniformMaybe("lightCenter", lightPos);
lightShader.SetUniformMaybe("lightIndex", (i + 0.5f) / ShadowTexture.Height);
lightShader.SetUniformMaybe("lightIndex", component.CastShadows ? (i + 0.5f) / ShadowTexture.Height : -1);
var offset = new Vector2(component.Radius, component.Radius);