summaryrefslogtreecommitdiff
path: root/gfx/gl
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:12:59 +0100
commita694e337f30b3320c45b6164cb31fe65c35e6bc9 (patch)
treeab4a6c4f4dddd014d6d9dafafb3d9b9a9f9c457b /gfx/gl
parentReplace low poly plants with the double sided version (diff)
downloadilt-a694e337f30b3320c45b6164cb31fe65c35e6bc9.tar.bz2
ilt-a694e337f30b3320c45b6164cb31fe65c35e6bc9.tar.xz
ilt-a694e337f30b3320c45b6164cb31fe65c35e6bc9.zip
Offset shaded position to reduce chance of self-shadowing
Diffstat (limited to 'gfx/gl')
-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);
}