diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-30 22:48:33 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-30 22:48:33 +0000 |
commit | 3c239338f5d1e97e3c0ddd05976e14b20758e07d (patch) | |
tree | 7eb3c254b681d2cafbc9ce8f13b285a9313474c4 /gfx/gl/shaders/directionalLight.fs | |
parent | 3D relative scaling in asset factory (diff) | |
parent | Adjust light view projection matrix upfront (diff) | |
download | ilt-3c239338f5d1e97e3c0ddd05976e14b20758e07d.tar.bz2 ilt-3c239338f5d1e97e3c0ddd05976e14b20758e07d.tar.xz ilt-3c239338f5d1e97e3c0ddd05976e14b20758e07d.zip |
Merge branch 'geo-shadows'
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r-- | gfx/gl/shaders/directionalLight.fs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/gfx/gl/shaders/directionalLight.fs b/gfx/gl/shaders/directionalLight.fs index f36d83f..24457b8 100644 --- a/gfx/gl/shaders/directionalLight.fs +++ b/gfx/gl/shaders/directionalLight.fs @@ -9,16 +9,15 @@ 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; uniform ivec3 lightPoint; uniform mat4 lightViewProjection[MAX_MAPS]; -uniform vec4 shadowMapRegion[MAX_MAPS]; uniform uint lightViewProjectionCount; -const vec3 e1 = vec3(-1, -1, -1), e2 = vec3(1, 1, 1); +const vec3 e1 = vec3(0, 0, 0), e2 = vec3(1, 1, 1); float insideShadowCube(vec3 v) @@ -34,9 +33,8 @@ 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; - return step(lightSpaceDepth, PositionInLightSpace.z * .5 + .5); + const float lightSpaceDepth = texture(shadowMap, vec3(PositionInLightSpace.xy, m)).r; + return step(lightSpaceDepth, PositionInLightSpace.z); } } return 0; |