Skip to content

Commit 7afbed8

Browse files
authored
Fix shadow artifacts by employing hardware clamping (#7532)
1 parent a7a2b9c commit 7afbed8

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

code/def_files/data/effects/main-g.sdr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ out VertexOutput {
163163
gl_Position = shadow_proj_matrix[instanceID] * gl_in[vert].gl_Position;
164164
#prereplace ENDIF_FLAG //MODEL_SDR_FLAG_TRANSFORM
165165

166-
if(gl_Position.z < -1.0)
167-
gl_Position.z = -1.0;
168-
169166
vertOut.position = gl_in[vert].gl_Position;
170167
vertOut.normal = vertIn[vert].normal;
171168
vertOut.texCoord = vertIn[vert].texCoord;

code/graphics/opengl/gropengltnl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ void gr_opengl_shadow_map_start(matrix4 *shadow_view_matrix, const matrix *light
697697
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
698698
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
699699

700+
glEnable(GL_DEPTH_CLAMP);
701+
700702
Rendering_to_shadow_map = true;
701703
Glowpoint_override_save = Glowpoint_override;
702704
Glowpoint_override = true;
@@ -715,6 +717,8 @@ void gr_opengl_shadow_map_end()
715717
if(!Rendering_to_shadow_map)
716718
return;
717719

720+
glDisable(GL_DEPTH_CLAMP);
721+
718722
gr_end_view_matrix();
719723
Rendering_to_shadow_map = false;
720724

0 commit comments

Comments
 (0)