Skip to content

Commit

Permalink
OpenGL2: Don't project sun shadows onto nothing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zturtleman committed Jul 27, 2024
1 parent 15f5fe7 commit 4c19ff2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions code/renderergl2/glsl/shadowmask_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c19ff2

Please sign in to comment.