From 892513f81ed68e05d4dedb99f51de5bc46cab6b2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 28 Jan 2024 02:25:11 +0000 Subject: 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. --- gfx/gl/shaders/directionalLight.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gfx/gl/shaders/directionalLight.fs') 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); } } -- cgit v1.2.3