Skip to content

Add depth testing for compute GSplat renderer when CameraFrame depth prepass is enabled#8581

Merged
mvaligursky merged 2 commits intomainfrom
mv-gsplat-compute-depth-test
Apr 8, 2026
Merged

Add depth testing for compute GSplat renderer when CameraFrame depth prepass is enabled#8581
mvaligursky merged 2 commits intomainfrom
mv-gsplat-compute-depth-test

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented Apr 8, 2026

Enable the compute-based Gaussian Splat rasterizer to depth-test against opaque scene geometry using the linear depth texture from the depth prepass.

Changes:

  • Add a DEPTH_TEST shader variant to the compute rasterize shader that loads per-pixel scene depth and skips splats behind opaque geometry
  • Early-out optimization: when all four pixels in a 2x2 quad are behind scene depth, skip remaining splats (front-to-back ordering)
  • Extend GSplatLocalDispatchSet variant system to support color-depth variant with sceneDepthMap binding
  • Detect depth availability at dispatch time via camera.shaderParams.sceneDepthMapLinear and uSceneDepthMap
  • Set requiresDepth: true on the beforePasses entry to signal depth prepass dependency
  • Vectorize transmittance early-out using all() for consistency
  • Deduplicate transmittance declarations across pick/color branches
  • Refactor getRasterizeCompute to accept boolean parameters instead of string keys

Examples:

  • Updated lod-streaming example with an "Occluder" toggle in Scene controls that shows an orange cube and enables the depth prepass

Performance:

  • Depth-occluded tiles early-out immediately, avoiding unnecessary splat evaluation behind opaque geometry

…prepass is enabled

Enable the compute-based Gaussian Splat rasterizer to depth-test against opaque scene
geometry using the linear depth texture from the depth prepass. Splats behind opaque
surfaces are skipped per-pixel, and entire 2x2 quads early-out when fully occluded.

Made-with: Cursor
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds an optional depth-test path to the compute-based Gaussian Splat (GSplat) local rasterizer so splats can be occluded by opaque scene geometry when a linear-depth prepass is enabled (e.g., via CameraFrame.rendering.sceneDepthMap).

Changes:

  • Adds a DEPTH_TEST WGSL shader variant that loads the scene’s linear depth texture and skips splats behind it, including an early-out when a splat is behind all 2x2 quad samples.
  • Extends GSplatLocalDispatchSet rasterize variants to support a color-depth pipeline with a sceneDepthMap binding and refactors variant selection to use boolean flags.
  • Updates the lod-streaming example UI to toggle an occluder cube and enable/disable the depth prepass.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/scene/shader-lib/wgsl/chunks/gsplat/compute-gsplat-local-rasterize.js Adds DEPTH_TEST sampling/comparisons against linear scene depth during compute rasterization.
src/scene/gsplat-unified/gsplat-local-dispatch-set.js Adds bind-group support + shader defines for the depth-test rasterize variant.
src/scene/gsplat-unified/gsplat-compute-local-renderer.js Selects depth-test variant at dispatch time and marks the pass as requiresDepth.
examples/src/examples/gaussian-splatting/lod-streaming.example.mjs Adds an occluder entity and toggles CameraFrame depth prepass via UI state.
examples/src/examples/gaussian-splatting/lod-streaming.controls.mjs Adds an “Occluder” toggle control.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/scene/gsplat-unified/gsplat-compute-local-renderer.js
Comment on lines +281 to +283
// requiresDepth hints that a depth prepass should run first, so the
// rasterize shader can skip splats behind opaque geometry.
camera.beforePasses.push({ pass: this.framePass, requiresDepth: true });
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

requiresDepth on camera.beforePasses doesn’t appear to be consumed anywhere in the current codebase (no reads found), so setting it to true here is currently a no-op and the added comment implies behavior that doesn’t actually happen. Either wire requiresDepth into the scheduling logic (so it actually triggers/requests a depth prepass) or keep this metadata/comment aligned with what the engine does today.

Suggested change
// requiresDepth hints that a depth prepass should run first, so the
// rasterize shader can skip splats behind opaque geometry.
camera.beforePasses.push({ pass: this.framePass, requiresDepth: true });
camera.beforePasses.push({ pass: this.framePass });

Copilot uses AI. Check for mistakes.
@mvaligursky mvaligursky merged commit 65a9949 into main Apr 8, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-gsplat-compute-depth-test branch April 8, 2026 12:58
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