Skip to content

Commit 443da4e

Browse files
matthargettclaude
authored andcommitted
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<f32>, 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 BabylonJS#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<f32> 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 a81ccfb)
1 parent 11ae68e commit 443da4e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/dev/core/src/ShadersWGSL/lightingVolume.compute.fx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct Params {
88
orthoMax: vec3f,
99
};
1010

11-
@group(0) @binding(0) var shadowMap : texture_2d<f32>;
11+
@group(0) @binding(0) var shadowMap : texture_depth_2d;
1212
@group(0) @binding(1) var<uniform> params : Params;
1313
@group(0) @binding(2) var<storage,read_write> positions : array<f32>;
1414

@@ -27,7 +27,7 @@ fn updateFarPlaneVertices(@builtin(global_invocation_id) global_id : vec3u) {
2727
let stepY = floor(params.step * f32(coord.y));
2828
let depthCoord = vec2u(u32(floor(f32(coord.x) * params.step)), u32(stepY));
2929

30-
var depth = textureLoad(shadowMap, depthCoord, 0).r;
30+
var depth = textureLoad(shadowMap, depthCoord, 0);
3131
#ifdef MOVE_FAR_DEPTH_TO_NEAR
3232
if (depth == 1.0) {
3333
depth = 0.0;

0 commit comments

Comments
 (0)