From 4c19ff2b55e6dd3d97c681112821de0556f78d4a Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 27 Jul 2024 00:43:31 -0500 Subject: [PATCH] OpenGL2: Don't project sun shadows onto nothing Don't project sun shadows (r_forceSun 1) on to view depth equal to 1.0 (nothing drawn or skybox). This caused a full second shadow of the entire level in tr.screenShadowImage. It would move as the camera far plane changed and rotate/stretch strangely as the camera view changed. It was visible in-game on lightmapped transparent surfaces facing the skybox and happen to overlap the extra shadow of the level. This affected the glass in wop_padship's underwater room. --- code/renderergl2/glsl/shadowmask_fp.glsl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/renderergl2/glsl/shadowmask_fp.glsl b/code/renderergl2/glsl/shadowmask_fp.glsl index 2b57e3ba..56d480fb 100644 --- a/code/renderergl2/glsl/shadowmask_fp.glsl +++ b/code/renderergl2/glsl/shadowmask_fp.glsl @@ -103,14 +103,19 @@ void main() vec4 shadowpos = u_ShadowMvp * biasPos; + if ( depth >= 1.0 - DEPTH_MAX_ERROR ) + { + result = 1.0; + } + else #if defined(USE_SHADOW_CASCADE) if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) - { #endif + { shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z); -#if defined(USE_SHADOW_CASCADE) } +#if defined(USE_SHADOW_CASCADE) else { shadowpos = u_ShadowMvp2 * biasPos;