@@ -184,14 +184,25 @@ struct ClusterOffsetsAndCounts {
184184
185185[[group (0 ), binding (1 )]]
186186var <uniform > lights : Lights ;
187+ #ifdef CUBE_ARRAY_TEXTURES_SUPPORT
187188[[group (0 ), binding (2 )]]
188189var point_shadow_textures : texture_depth_cube_array ;
189190[[group (0 ), binding (3 )]]
190191var point_shadow_textures_sampler : sampler_comparison ;
192+ #endif
193+ #ifdef NO_CUBE_ARRAY_TEXTURES_SUPPORT
194+ [[group (0 ), binding (2 )]]
195+ var point_shadow_textures : texture_depth_cube ;
196+ [[group (0 ), binding (3 )]]
197+ var point_shadow_textures_sampler : sampler_comparison ;
198+ // var point_shadow_textures_sampler: sampler;
199+ #endif
191200[[group (0 ), binding (4 )]]
192- var directional_shadow_textures : texture_depth_2d_array ;
201+ // var directional_shadow_textures: texture_depth_2d_array;
202+ var directional_shadow_textures : texture_depth_2d ;
193203[[group (0 ), binding (5 )]]
194204var directional_shadow_textures_sampler : sampler_comparison ;
205+ // var directional_shadow_textures_sampler: sampler;
195206[[group (0 ), binding (6 )]]
196207var <uniform > point_lights : PointLights ;
197208[[group (0 ), binding (7 )]]
@@ -516,7 +527,18 @@ fn fetch_point_shadow(light_id: u32, frag_position: vec4<f32>, surface_normal: v
516527 // a quad (2x2 fragments) being processed not being sampled, and this messing with
517528 // mip-mapping functionality. The shadow maps have no mipmaps so Level just samples
518529 // from LOD 0.
530+ #ifdef CUBE_ARRAY_TEXTURES_SUPPORT
519531 return textureSampleCompareLevel (point_shadow_textures , point_shadow_textures_sampler , frag_ls , i32 (light_id ), depth );
532+ #endif
533+ #ifdef NO_CUBE_ARRAY_TEXTURES_SUPPORT
534+ return textureSampleCompare (point_shadow_textures , point_shadow_textures_sampler , frag_ls , depth );
535+ // let sampled_depth = textureSample(point_shadow_textures, point_shadow_textures_sampler, frag_ls);
536+ // if (sampled_depth >= depth) {
537+ // return 0.0;
538+ // } else {
539+ // return 1.0;
540+ // }
541+ #endif
520542}
521543
522544fn fetch_directional_shadow (light_id : u32 , frag_position : vec4 <f32 >, surface_normal : vec3 <f32 >) -> f32 {
@@ -547,7 +569,24 @@ fn fetch_directional_shadow(light_id: u32, frag_position: vec4<f32>, surface_nor
547569 // do the lookup, using HW PCF and comparison
548570 // NOTE: Due to non-uniform control flow above, we must use the level variant of the texture
549571 // sampler to avoid use of implicit derivatives causing possible undefined behavior.
550- return textureSampleCompareLevel (directional_shadow_textures , directional_shadow_textures_sampler , light_local , i32 (light_id ), depth );
572+ // return textureSampleCompareLevel(directional_shadow_textures, directional_shadow_textures_sampler, light_local, i32(light_id), depth);
573+ return textureSampleCompareLevel (directional_shadow_textures , directional_shadow_textures_sampler , light_local , depth );
574+ // let sampled_depth = textureSample(directional_shadow_textures, directional_shadow_textures_sampler, light_local, i32(light_id));
575+ // // No shadow outside the orthographic projection volume
576+
577+ // if (offset_position_clip.w <= 0.0) {
578+ // return 1.0;
579+ // }
580+ // if (any(offset_position_ndc.xy < vec2<f32>(-1.0)) || offset_position_ndc.z < 0.0
581+ // || any(offset_position_ndc > vec3<f32>(1.0))) {
582+ // return 1.0;
583+ // }
584+
585+ // if (sampled_depth >= depth) {
586+ // return 0.0;
587+ // } else {
588+ // return 1.0;
589+ // }
551590}
552591
553592fn hsv2rgb (hue : f32 , saturation : f32 , value : f32 ) -> vec3 <f32 > {
@@ -683,8 +722,15 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
683722 let light_id = get_light_id (i );
684723 let light = point_lights . data [light_id ];
685724 var shadow : f32 = 1 .0 ;
725+ #ifdef CUBE_ARRAY_TEXTURES_SUPPORT
686726 if ((mesh . flags & MESH_FLAGS_SHADOW_RECEIVER_BIT ) != 0u
687727 || (light . flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT ) != 0u ) {
728+ #endif
729+ #ifdef NO_CUBE_ARRAY_TEXTURES_SUPPORT
730+ if (light_id < 1u
731+ && ((mesh . flags & MESH_FLAGS_SHADOW_RECEIVER_BIT ) != 0u
732+ || (light . flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT ) != 0u )) {
733+ #endif
688734 shadow = fetch_point_shadow (light_id , in . world_position , in . world_normal );
689735 }
690736 let light_contrib = point_light (in . world_position . xyz , light , roughness , NdotV , N , V , R , F0 , diffuse_color );
0 commit comments