From 5c45e6c708af636709db2491ab8128451e32e84a Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Sun, 17 May 2026 12:03:20 -0700 Subject: [PATCH] Fix lighting volume WGSL depth texture binding LightingVolume binds the shadow generator's shadow map depthStencilTexture - a depth-format texture - as the shadowMap input of the lightingVolume compute shader. Declare that binding as texture_depth_2d instead of texture_2d, and drop the .r swizzle on the textureLoad result since textureLoad on texture_depth_2d returns a scalar f32. The loaded value is the same depth that .r previously carried, so far-plane fitting results are unchanged. This completes the compute depth sample-type support introduced in PR #18460: _GetComputeTextureSampleType classifies this texture as bind group layout sampleType "depth", and WebGPU validation requires a texture_depth_2d WGSL declaration for a "depth" layout entry. With the previous texture_2d declaration, createComputePipeline fails validation (observed in Chromium and wgpu-native) as soon as the lighting volume compute shaders run with an explicit pipeline layout. The change is also safe with the default auto layout: texture_depth_2d derives sampleType "depth", which is valid for the depth-aspect view Babylon binds, so behavior is identical there. This came from the Hill Valley GLTF/NativeXR AR Portal validation pass. (cherry picked from commit a81ccfb959af1e3996cf5c86f1b92698ee6a21ea) --- packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx b/packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx index 2445aff20b26..e09605831d98 100644 --- a/packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx +++ b/packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx @@ -8,7 +8,7 @@ struct Params { orthoMax: vec3f, }; -@group(0) @binding(0) var shadowMap : texture_2d; +@group(0) @binding(0) var shadowMap : texture_depth_2d; @group(0) @binding(1) var params : Params; @group(0) @binding(2) var positions : array; @@ -27,7 +27,7 @@ fn updateFarPlaneVertices(@builtin(global_invocation_id) global_id : vec3u) { let stepY = floor(params.step * f32(coord.y)); let depthCoord = vec2u(u32(floor(f32(coord.x) * params.step)), u32(stepY)); - var depth = textureLoad(shadowMap, depthCoord, 0).r; + var depth = textureLoad(shadowMap, depthCoord, 0); #ifdef MOVE_FAR_DEPTH_TO_NEAR if (depth == 1.0) { depth = 0.0;