Skip to content

Support GSPLAT_AA in the hybrid gsplat renderer#8807

Merged
mvaligursky merged 1 commit into
mainfrom
mv-gsplat-hybrid-aa
May 29, 2026
Merged

Support GSPLAT_AA in the hybrid gsplat renderer#8807
mvaligursky merged 1 commit into
mainfrom
mv-gsplat-hybrid-aa

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

The quad gsplat renderer applies an anti-aliasing opacity compensation factor when GSPLAT_AA is enabled (via GSplatParams#antiAlias), but the hybrid (GPU-sort) renderer ignored it. This wires AA support through the hybrid pipeline.

Because the hybrid path projects splats in a compute pass and rasterizes from a pre-projected cache, the AA factor is computed in the projector and baked into the cached alpha — so the hybrid vertex shader and the cache layout need no changes. The formula matches the quad renderer's initCornerCov exactly: aaFactor = sqrt(detOrig / detBlur), the ratio of the pre-blur to post-blur 2D covariance determinant.

Changes:

  • compute-gsplat-common.js: computeSplatCov keeps the raw (pre-blur) covariance diagonal and, under #if GSPLAT_AA, computes aaFactor into a new SplatCov2D field.
  • compute-gsplat-projector.js: the non-pick color branch multiplies alpha *= proj.aaFactor under #if GSPLAT_AA.
  • gsplat-projector.js: threads antiAlias through _projectorKey / _createProjectorCompute / _getProjectorCompute / dispatch, adding the GSPLAT_AA cdefine and an Aa variant suffix. The setting is read live each frame, so toggling takes effect on the next frame.
  • gsplat-manager.js: passes antiAlias: gsplat.antiAlias into projector.dispatch.

AA is gated to non-pick mode (aaMode = antiAlias && !pickMode) since picking only gates on a binary opacity threshold — this keeps the projector variant count at 12 rather than 16.

This is the WebGPU-only path, so only WGSL chunks were touched; the GLSL quad path already had AA.

Examples:

  • Added an "Anti-alias" toggle to the gsplat viewer example's Renderer panel, wired to GSplatParams#antiAlias.

Notes for reviewers:

  • Minor behavioural nuance vs. the quad renderer: the projector's opacity <= alphaClip early-out runs against raw opacity before AA modulation, whereas the quad VS applies AA before its alpha discard. The fragment shader's alpha < alphaClipForward test still catches anything AA pushes below threshold, so the visible result matches.
  • WGSL shader chunks are template strings (not compiled at build), so this carries code-review + lint verification. Worth a manual check in the viewer with the GPU-sort renderer selected.

The quad gsplat renderer applies an anti-aliasing opacity factor when
GSPLAT_AA is enabled, but the hybrid (GPU-sort) renderer ignored it.
Since the hybrid path projects in a compute pass and rasterizes from a
cache, the AA factor is computed in the projector and baked into the
cached alpha, so the hybrid VS and cache layout are unchanged.

The AA variant is gated to non-pick mode (picking only gates on a binary
opacity threshold), keeping the projector variant count to 12 not 16.

Also adds an Anti-alias toggle to the gsplat viewer example's Renderer
panel, wired to GSplatParams#antiAlias.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

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

Adds GSPLAT_AA (anti-aliasing opacity compensation) support to the WebGPU hybrid (GPU-sort) gsplat renderer. The compensation factor — sqrt(detOrig / detBlur) matching the quad renderer's initCornerCov — is computed in the projector compute pass and baked into the cached alpha, so the rasterizer's VS and cache layout are unchanged. A projector variant axis (Aa) is added, gated to non-pick mode to cap variants at 12.

Changes:

  • Compute the AA factor in computeSplatCov (preserving pre-blur covariance diagonal) and store it on SplatCov2D under #if GSPLAT_AA; the projector multiplies it into the cached alpha for the non-pick color branch.
  • Thread an antiAlias flag through GSplatProjector (_projectorKey/_createProjectorCompute/_getProjectorCompute/dispatch), adding the GSPLAT_AA cdefine and Aa variant suffix; GSplatManager passes gsplat.antiAlias per dispatch.
  • Add an "Anti-alias" toggle to the gsplat viewer example bound to app.scene.gsplat.antiAlias.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/scene/shader-lib/wgsl/chunks/gsplat/compute-gsplat-common.js Compute and expose aaFactor on SplatCov2D from raw vs. blurred covariance determinants.
src/scene/shader-lib/wgsl/chunks/gsplat/compute-gsplat-projector.js Multiply cached alpha by proj.aaFactor under #if GSPLAT_AA in the non-pick branch.
src/scene/gsplat-unified/gsplat-projector.js Add antiAlias to projector variant key/name/cdefines and dispatch; gate AA off in pick mode.
src/scene/gsplat-unified/gsplat-manager.js Pass antiAlias: gsplat.antiAlias into projector.dispatch.
examples/src/examples/gaussian-splatting/viewer.example.mjs Add antialias observer data and wire it to app.scene.gsplat.antiAlias.
examples/src/examples/gaussian-splatting/viewer.controls.mjs Add Anti-alias toggle in the Renderer panel bound to data.antialias.

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

@mvaligursky mvaligursky merged commit 77bb162 into main May 29, 2026
9 checks passed
@mvaligursky mvaligursky deleted the mv-gsplat-hybrid-aa branch May 29, 2026 09:32
mvaligursky added a commit that referenced this pull request May 29, 2026
The quad gsplat renderer applies an anti-aliasing opacity factor when
GSPLAT_AA is enabled, but the hybrid (GPU-sort) renderer ignored it.
Since the hybrid path projects in a compute pass and rasterizes from a
cache, the AA factor is computed in the projector and baked into the
cached alpha, so the hybrid VS and cache layout are unchanged.

The AA variant is gated to non-pick mode (picking only gates on a binary
opacity threshold), keeping the projector variant count to 12 not 16.

Also adds an Anti-alias toggle to the gsplat viewer example's Renderer
panel, wired to GSplatParams#antiAlias.

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants