@@ -208,6 +208,8 @@ fn sample_shadow_map_jimenez_fourteen(
208208 return sum / 8 .0 ;
209209}
210210
211+ const PENUMBRA_FILTER_SIZE : vec2 <f32 > = vec2 (128 .0f );
212+
211213// Performs the blocker search portion of percentage-closer soft shadows (PCSS).
212214// This is the variation used for directional lights.
213215//
@@ -224,16 +226,17 @@ fn search_for_blockers_in_shadow_map(
224226 array_index : i32 ,
225227) -> f32 {
226228 let shadow_map_size = vec2 <f32 >(textureDimensions (view_bindings :: directional_shadow_textures ));
229+ let rotation_matrix = random_rotation_matrix (light_local * shadow_map_size , false );
227230 let uv_offset_scale = PENUMBRA_FILTER_SIZE / shadow_map_size ;
228231
229- let offset0 = D3D_SAMPLE_POINT_POSITIONS [0 ] * uv_offset_scale ;
230- let offset1 = D3D_SAMPLE_POINT_POSITIONS [1 ] * uv_offset_scale ;
231- let offset2 = D3D_SAMPLE_POINT_POSITIONS [2 ] * uv_offset_scale ;
232- let offset3 = D3D_SAMPLE_POINT_POSITIONS [3 ] * uv_offset_scale ;
233- let offset4 = D3D_SAMPLE_POINT_POSITIONS [4 ] * uv_offset_scale ;
234- let offset5 = D3D_SAMPLE_POINT_POSITIONS [5 ] * uv_offset_scale ;
235- let offset6 = D3D_SAMPLE_POINT_POSITIONS [6 ] * uv_offset_scale ;
236- let offset7 = D3D_SAMPLE_POINT_POSITIONS [7 ] * uv_offset_scale ;
232+ let offset0 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [0 ] * uv_offset_scale ;
233+ let offset1 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [1 ] * uv_offset_scale ;
234+ let offset2 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [2 ] * uv_offset_scale ;
235+ let offset3 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [3 ] * uv_offset_scale ;
236+ let offset4 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [4 ] * uv_offset_scale ;
237+ let offset5 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [5 ] * uv_offset_scale ;
238+ let offset6 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [6 ] * uv_offset_scale ;
239+ let offset7 = rotation_matrix * D3D_SAMPLE_POINT_POSITIONS [7 ] * uv_offset_scale ;
237240
238241 var sum = vec2 (0 .0 );
239242 sum += search_for_blockers_in_shadow_map_hardware (light_local + offset0 , depth , array_index );
0 commit comments