mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user