From 5509096158cf92a0afac26d92f0f46e8b5afd18f Mon Sep 17 00:00:00 2001 From: N8n5h Date: Fri, 6 Aug 2021 18:34:39 -0300 Subject: [PATCH] fix volumetric lights not working with shadow map atlas enabled Added missing code so the shader refers to the correct variable when using shadow map atlasing. --- .../volumetric_light.frag.glsl | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Shaders/volumetric_light/volumetric_light.frag.glsl b/Shaders/volumetric_light/volumetric_light.frag.glsl index a0817b54..693d7b1d 100644 --- a/Shaders/volumetric_light/volumetric_light.frag.glsl +++ b/Shaders/volumetric_light/volumetric_light.frag.glsl @@ -44,7 +44,15 @@ uniform vec2 cameraPlane; uniform vec3 sunDir; uniform vec3 sunCol; #ifdef _ShadowMap + #ifdef _ShadowMapAtlas + #ifndef _SingleAtlas + uniform sampler2DShadow shadowMapAtlasSun; + #else + uniform sampler2DShadow shadowMapAtlas; + #endif + #else uniform sampler2DShadow shadowMap; + #endif uniform float shadowsBias; #ifdef _CSM //!uniform vec4 casData[shadowmapCascades * 4 + 4]; @@ -95,7 +103,17 @@ void rayStep(inout vec3 curPos, inout float curOpticalDepth, inout float scatter #endif vec4 lPos = LWVP * vec4(curPos, 1.0); lPos.xyz /= lPos.w; - visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias)); + visibility = texture( + #ifdef _ShadowMapAtlas + #ifndef _SingleAtlas + shadowMapAtlasSun + #else + shadowMapAtlas + #endif + #else + shadowMap + #endif + , vec3(lPos.xy, lPos.z - shadowsBias)); #endif #ifdef _SinglePoint