summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/directionalLight.fs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-28 02:25:11 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-28 02:25:11 +0000
commit892513f81ed68e05d4dedb99f51de5bc46cab6b2 (patch)
tree19209bc3f1c58123bd497c7c555ac8c7d251c351 /gfx/gl/shaders/directionalLight.fs
parentSet light view point uniform once (diff)
downloadilt-892513f81ed68e05d4dedb99f51de5bc46cab6b2.tar.bz2
ilt-892513f81ed68e05d4dedb99f51de5bc46cab6b2.tar.xz
ilt-892513f81ed68e05d4dedb99f51de5bc46cab6b2.zip
Geometry shader for single pass shadow maps
2D array texture, 4 levels, geometry shader outputs to each layer for a specific band, single scene rendering. Pending massive tidy up.
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r--gfx/gl/shaders/directionalLight.fs7
1 files changed, 4 insertions, 3 deletions
diff --git a/gfx/gl/shaders/directionalLight.fs b/gfx/gl/shaders/directionalLight.fs
index f36d83f..d0c5062 100644
--- a/gfx/gl/shaders/directionalLight.fs
+++ b/gfx/gl/shaders/directionalLight.fs
@@ -9,7 +9,7 @@ in vec2 TexCoords;
layout(binding = 0) uniform isampler2D gPosition;
layout(binding = 1) uniform sampler2D gNormal;
-layout(binding = 2) uniform sampler2D shadowMap;
+layout(binding = 2) uniform sampler2DArray shadowMap;
uniform vec3 lightDirection;
uniform vec3 lightColour;
@@ -34,8 +34,9 @@ isShaded(vec4 Position)
const vec3 PositionInLightSpace = (lightViewProjection[m] * Position).xyz;
const float inside = insideShadowCube(PositionInLightSpace);
if (inside > 0) {
- const float lightSpaceDepth
- = texture(shadowMap, PositionInLightSpace.xy * shadowMapRegion[m].xy + shadowMapRegion[m].zw).r;
+ const float lightSpaceDepth = texture(
+ shadowMap, vec3(PositionInLightSpace.xy * shadowMapRegion[m].xy + shadowMapRegion[m].zw, m))
+ .r;
return step(lightSpaceDepth, PositionInLightSpace.z * .5 + .5);
}
}