Fix invalid global-merge reads and respect camera layer masks#38
Draft
andybak wants to merge 5 commits into
Draft
Fix invalid global-merge reads and respect camera layer masks#38andybak wants to merge 5 commits into
andybak wants to merge 5 commits into
Conversation
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.
This PR fixes correctness issues in globally sorted rendering.
First, the final merge shader previously used a conditional expression that could
evaluate an out-of-range buffer access before selecting the valid result. Replacing
it with an explicit branch ensures only the selected order buffer is read.
Second, one global draw can carry only one Unity layer. The global path now falls
back to per-renderer rendering when participating splat renderers use different
layers. If all participating renderers share a layer, that layer is assigned to the
global
RenderParams, so Unity camera culling masks include or exclude the mergeddraw correctly.
Third, isolated splat renderers such as model or panel previews can now opt out of
the global merge through
GsplatRenderer.ParticipateInGlobalSort. Participatingsame-layer scene renderers can remain globally sorted while opted-out renderers use
the existing per-renderer fallback path.
Main changes
set.
RenderParamsdraw.ParticipateInGlobalSortrenderer option,enabled by default.
Risk and compatibility
Existing renderers participate by default, so existing same-layer scenes retain the
global draw optimization.
Mixed layers within the participating set still force the scene back to
per-renderer rendering. A renderer explicitly opted out of global sorting is not
depth-sorted against the global set, so opt-out is intended for isolated previews,
UI, or renderers in a separate visual space. It should not be used for splats that
must blend with participating renderers in the same scene.
When global rendering is active, each opted-out renderer retains its existing
per-renderer sort and draw cost. The renderer partitions reuse their lists and do
not add per-frame managed allocations.
Integration note with
pr/depth-prepassThis branch is independently correct against current
main, whose global draw usesRenderParams. The depth-prepass branch adds SRP command-buffer global draws, whichdo not receive layer filtering automatically. If both PRs are accepted, rebase this
branch after
pr/depth-prepassand retain the combined branch's per-camera globaleligibility check and opted-out fallback draws in the new color and depth draw
methods. This prevents the SRP global path from reintroducing the camera-mask
regression or dropping opted-out renderers.
Suggested testing
back to per-renderer rendering.
different layer; confirm the scene splats remain globally sorted and the preview
remains visible.
Consumer validation
The opt-out path was tested in Open Brush with two dynamically imported,
overlapping scene splats and an active model preview on the Panels layer. The
imported scene splats remained in the global set while the preview rendered through
the independent fallback path.