Skip to content

Commit 3ea23dc

Browse files
committed
Fix #795
1 parent 551c731 commit 3ea23dc

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Build/svencoop/renderer/shader/studio_shader.frag.glsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,18 @@ vec3 R_StudioCelShade(vec3 v_color, vec3 normalWS, vec3 lightdirWS, float specul
548548
// N dot L
549549
float litOrShadowArea = smoothstep(r_celshade_midpoint - r_celshade_softness, r_celshade_midpoint + r_celshade_softness, NoL);
550550

551+
#if defined(STUDIO_NF_CELSHADE_FACE)
552+
// When the light direction is nearly vertical, the Z-flattening in
553+
// R_GetAdjustedLightDirection has no horizontal component to preserve,
554+
// so normalize() pushes L back to vertical, causing a "vertical shadow"
555+
// artifact on the face. Fade toward no shadow to suppress it.
556+
{
557+
float flLightHorizLen = length(lightdirWS.xy);
558+
float flVerticalFade = smoothstep(0.05, 0.2, flLightHorizLen);
559+
litOrShadowArea = mix(1.0, litOrShadowArea, flVerticalFade);
560+
}
561+
#endif
562+
551563
#if defined(STUDIO_NF_CELSHADE_FACE) && defined(STENCIL_TEXTURE_ENABLED)
552564

553565
litOrShadowArea = mix(0.5, 1.0, litOrShadowArea);

0 commit comments

Comments
 (0)