Fix: Enable Z-Write for Depth Occlusion & Fix Divide-by-Zero in Composite Shader #211
+9
−6
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.
Summary This PR updates the rendering pipeline to enable Z-Write and adjusts the blending mode. These changes ensure that Gaussian Splat objects interact correctly with the depth buffer, allowing multiple GS objects to properly occlude each other and integrate better with the rest of the scene. Additionally, a potential divide-by-zero error in the composite shader has been fixed.
Key Changes
Enabled Depth Occlusion (Z-Write)
Modified RenderGaussianSplats.shader to set ZWrite On and updated the Blend mode to One OneMinusSrcAlpha.
This ensures splats write to the depth buffer, which is critical for handling occlusion between different objects.
Adjusted Rendering Sort Order
Updated GaussianSplatRenderer.cs to invert the sorting logic for both render order and camera distance.
This reordering is necessary to support the changes in blending and depth writing.
Fixed Divide-by-Zero in Shader
Added a safety check in GaussianComposite.shader to verify if col.a > 0 before division.
This prevents NaN or invalid color values from appearing when the alpha channel is zero.
Impact
Inter-Object Occlusion: Multiple Gaussian Splat objects can now correctly occlude each other based on depth.
Scene Integration: Improved depth sorting and occlusion against other opaque scene geometry.
Stability: Eliminated rendering artifacts caused by invalid alpha division in the composite pass.
Before

After
