summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/directionalLight.fs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-08-18 13:11:46 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-08-18 13:11:46 +0100
commit87ebf7a7587e832d922635021a32c887823d92c7 (patch)
tree38f043ebb75ce7c540fb793e25cf6345e762a48a /gfx/gl/shaders/directionalLight.fs
parentReplace low poly plants with the double sided version (diff)
downloadilt-87ebf7a7587e832d922635021a32c887823d92c7.tar.bz2
ilt-87ebf7a7587e832d922635021a32c887823d92c7.tar.xz
ilt-87ebf7a7587e832d922635021a32c887823d92c7.zip
Offset shaded position to reduce chance of self-shadowing
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r--gfx/gl/shaders/directionalLight.fs6
1 files changed, 3 insertions, 3 deletions
diff --git a/gfx/gl/shaders/directionalLight.fs b/gfx/gl/shaders/directionalLight.fs
index 24457b8..86447ec 100644
--- a/gfx/gl/shaders/directionalLight.fs
+++ b/gfx/gl/shaders/directionalLight.fs
@@ -34,10 +34,10 @@ isShaded(vec4 Position)
const float inside = insideShadowCube(PositionInLightSpace);
if (inside > 0) {
const float lightSpaceDepth = texture(shadowMap, vec3(PositionInLightSpace.xy, m)).r;
- return step(lightSpaceDepth, PositionInLightSpace.z);
+ return step(PositionInLightSpace.z, lightSpaceDepth + 0.001);
}
}
- return 0;
+ return 1;
}
void
@@ -46,5 +46,5 @@ main()
const vec4 Position = vec4(texture(gPosition, TexCoords).xyz - lightPoint, 1);
const vec3 Normal = texture(gNormal, TexCoords).rgb;
const float shaded = isShaded(Position);
- FragColor = (1 - shaded) * max(dot(-lightDirection, Normal) * lightColour, 0);
+ FragColor = shaded * max(dot(-lightDirection, Normal) * lightColour, 0);
}