feat: Respect gsplat alphaCull on CPU raster and compute paths#8687
Merged
Conversation
- Wire scene.gsplat.alphaCull into compute local renderer (matches hybrid projector clamp). - Use alphaCull uniform in forward fragment shaders and clipCorner; sync hybrid VS. - Export ALPHA_VISIBILITY_THRESHOLD from gsplat-unified constants; reuse in manager.
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns gsplat alpha-threshold handling so scene.gsplat.alphaCull is applied beyond the hybrid projector path, aiming to make CPU raster and compute/local rendering behave more consistently with the unified gsplat pipeline.
Changes:
- Adds
alphaCull-based culling/shrinking to CPU raster GLSL/WGSL vertex/fragment shaders. - Threads
alphaCullthrough the hybrid renderer and compute-local renderer, while centralizing the historical1/255visibility floor in a shared constant. - Updates manager/renderer plumbing so hybrid/compute paths use the shared visibility threshold logic.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatHybrid.js |
Adds alphaCull to the hybrid WGSL vertex path for quad shrinking. |
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatCommon.js |
Adds shared WGSL alphaCull uniform and clip-corner logic. |
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplat.js |
Switches WGSL vertex early-out from fixed floor to alphaCull. |
src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplat.js |
Switches WGSL forward fragment discard from fixed floor to alphaCull. |
src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatCommon.js |
Adds shared GLSL alphaCull uniform and clip-corner logic. |
src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplat.js |
Switches GLSL vertex early-out from fixed floor to alphaCull. |
src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplat.js |
Switches GLSL forward fragment discard from fixed floor to alphaCull. |
src/scene/gsplat-unified/gsplat-manager.js |
Reuses the shared alpha visibility constant in manager logic. |
src/scene/gsplat-unified/gsplat-hybrid-renderer.js |
Syncs alphaCull onto hybrid forward/pick materials each frame. |
src/scene/gsplat-unified/gsplat-compute-local-renderer.js |
Propagates alphaCull into compute-local non-pick dispatch thresholds. |
src/scene/gsplat-unified/constants.js |
Exports the shared historical visibility floor constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // discard splats with alpha too low to contribute any visible pixel | ||
| if (half(255.0) * clr.w <= half(1.0)) { | ||
| if (clr.w <= half(uniform.alphaCull)) { |
Comment on lines
+17
to
+19
| // modify the gaussian corner so it excludes gaussian regions below alphaCull (forward pass) | ||
| void clipCorner(inout SplatCorner corner, float alpha) { | ||
| float clip = min(1.0, sqrt(log(255.0 * alpha)) * 0.5); | ||
| float clip = min(1.0, sqrt(max(0.0, log(alpha / alphaCull))) * 0.5); |
Comment on lines
+17
to
+19
| // modify the gaussian corner so it excludes gaussian regions below alphaCull (forward pass) | ||
| fn clipCorner(corner: ptr<function, SplatCorner>, alpha: half) { | ||
| let clip = min(half(1.0), sqrt(log(half(255.0) * alpha)) * half(0.5)); | ||
| let clip = min(half(1.0), sqrt(max(half(0.0), log(alpha / half(uniform.alphaCull)))) * half(0.5)); |
|
|
||
| frameUpdate(params) { | ||
| this._material.setParameter('alphaClip', params.alphaClip); | ||
| this._material.setParameter('alphaCull', params.alphaCull); |
Comment on lines
+114
to
+117
| // clipCorner: shrink the quad to exclude near-zero alpha regions. Mirrors the | ||
| // helper in gsplatCommonVS (kept inline to avoid pulling in the full gsplatCommonVS). | ||
| let cornerUV = vec2f(vertex_position.xy); | ||
| let clip = min(half(1.0), sqrt(log(half(255.0) * alpha)) * half(0.5)); | ||
| let clip = min(half(1.0), sqrt(max(half(0.0), log(alpha / half(uniform.alphaCull)))) * half(0.5)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scene.gsplat.alphaCullwas applied only on the hybrid GPU-sort projector path. CPU-sorted raster and the tiled compute renderer still used a hardcoded ~1/255 floor. This change aligns those renderers with the same threshold (with the existingmax(1/255, alphaCull)convention used for hybrid/compute projection).Changes:
max(ALPHA_VISIBILITY_THRESHOLD, alphaCull)into tile-count / rasteralphaClipuniforms (same rule as hybrid sort).alphaCull;clipCornerand vertex early-out usealphaCull; guardsqrt(log(...))when opacity is at or below the threshold.gsplatHybrid):alphaCulluniform for quad shrink;frameUpdatesyncsalphaCullon forward and pick materials.ALPHA_VISIBILITY_THRESHOLDexported fromgsplat-unified/constants.js;gsplat-managerimports it instead of a local constant.Public API: No changes — existing
GSplatParams#alphaCullbehavior now affects CPU raster and compute renderer paths consistently with hybrid GPU sort.Performance: Raising
alphaCullcan reduce work on compute and CPU raster (fewer splats / smaller quads); lowering it preserves more translucent splats.