Skip to content

Fix lighting volume WGSL depth texture binding#18658

Open
matthargett wants to merge 1 commit into
BabylonJS:masterfrom
rebeckerspecialties:claude/jolly-allen-k9ldki
Open

Fix lighting volume WGSL depth texture binding#18658
matthargett wants to merge 1 commit into
BabylonJS:masterfrom
rebeckerspecialties:claude/jolly-allen-k9ldki

Conversation

@matthargett

@matthargett matthargett commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Replaces #18564 after it was closed while I was on summer holidays.

Rebased on latest master; the change is still limited to treating the lighting volume shadow map as a WGSL depth texture and reading it with textureLoad.

Local validation:

  • npx nx build babylonjs --outputStyle=static
  • npx nx build babylonjs-gui --outputStyle=static
  • npm run check:treeshaking

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)
Copilot AI review requested due to automatic review settings July 4, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a WebGPU/WGSL binding-type mismatch for the lighting volume compute shader by declaring the shadow map input as a depth texture, matching the pipeline layout’s inferred sample type (Depth) and avoiding validation failures when using explicit pipeline layouts.

Changes:

  • Declare shadowMap as texture_depth_2d in lightingVolume.compute.fx to align with depth-texture bind group layout requirements.
  • Update textureLoad usage to consume the scalar f32 result returned by depth textures (remove the .r swizzle).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants