Search Issue Tracker
By Design
Votes
2
Found in [Package]
12.0.0
Issue ID
1323760
Regression
No
[HDRP] Glitches appear on GameObject when another GameObject with Opaque Shader and checked Alpha Clipping overlaps it
How to reproduce it:
1. Open the attached project "1323760.zip"
2. Load the "SampleScene" Scene
3. Move the camera around and observe the plane in the Scene view
Expected result: "Cube (1)" GameObject's is not visible on the "Cube" GameObject
Actual result: "Cube (1)" GameObject's glitches are visible on the "Cube" GameObject
Reproducible with: 7.5.3 (2019.4.24f1), 10.4.0 (2020.3.3f1), 11.0.0 (2021.1.1f1), 12.0.0 (2021.2.0a12)
Could not test with: 4.10.0-preview (2018.4.33f1) - due to the missing shaders
Notes:
- Reproducible, when "Cube (1)" GameObject's Shader is "HDRP/Unlit", "HDRP/TerrainLit", "HDRP/Lit",
- Reproducible, when "Cube (1)" GameObject's Surface Type is set to Opaque, and Alpha Clipping is checked
- Not reproducible when "Cube (1)" GameObject's Surface Type is Transparent
Comments (3)
-
oliver-fs
Dec 02, 2022 11:59
For those encountering this issue in the future, a better solution than the one suggested to is to instead add a depth offset to the material (thankfully supported by the Lit stack) rather than fighting with normal or scale offsets.
-
FOXAcemond
Apr 12, 2021 08:33
Having a dirty micro diff in position cannot be the only solution, I changed something somewhere and this glitch appeared, only recently. That means there is a way to "rollback" this change and get the desired behavior.
-
FOXAcemond
Apr 07, 2021 14:09
This is weird that the bug is also present in 2020 and older versions. I've used this strategy to hide my meshes since forever and never had that bug before.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Opening Terrain Prefab in Prefab Editing Mode throws "NullReferenceException" error
- [Search] Dragging query pills put them behind the search text field
- A CustomPropertyDrawer that returns a PropertyField for a property named the same as a child field will not render all child fields
- Graphics Settings shows default values instead of the real values in the Rendering Debugger when Volume.profile is assigned via script
- Deleting multiple Tags throws “NullReferenceException”, and "Retrieving array element that was out of bounds" errors when holding the Enter key
Resolution Note:
The behavior seen in this repro is actually expected but needs some explanation.
For performance reasons, Alpha tested geometry always needs to be rendered in two passes
- Depth prepass
- Color pass with depth test set as EQUAL and no alpha test.
The reason for this is that on most modern GPUs, whenever a shader contains a clip/discard instructions, the HiZ optimization is disabled causing huge performance loss for layered alpha tested geometry like foliage. By rendering alpha tested geometry as described above the color pass (which is the heaviest in term of performance) does not use clip instruction anymore and can be rendered efficiently.
The consequence is that with two perfectly overlapping objects, the alpha tested color pass will pass the depth tests making it visible. The artefacts displayed in this bug are actually regular z-fighting artefacts.
The only solution in this case is to add a small offset/scale to avoid the perfect overlap.