Search Issue Tracker
By Design
Votes
0
Found in
2020.3.41f1
2021.3.12f1
2022.1.21f1
2022.2.0b13
2023.1.0a16
Issue ID
UUM-18795
Regression
No
Camera clears the depth buffer when the clear flag option is set to don't clear
Reproduction steps:
- Open the user’s attached project (“My Project.zip”)
- Open the “Assets/Scenes/SampleScene.unity” Scene
- In the Hierarchy find both the “First (cube) Camera” and “Second (sphere) Camera” GameObjects
- Observe their Camera Components Settings ( i.e Clear Flags, Culling Mask, depth)
- Observe the “Test.cs” attached to the “RawImage” GameObject
- Enter Play Mode
- Compare the offscreen rendering to the Game View to see the differences
Expected result: The “Cube” and “Sphere” GameObjects will not overlap
Actual result: GameObjects "Cube" and "Sphere" overlap
Reproducible with: 2020.3.41f1, 2021.3.12f1, 2022.1.21f1, 2022.2.0b13, 2023.1.0a16
Reproducible on: Intel macOS 16
Note: The "Second (sphere) Camera" GameObject clears the depth buffer during off-screen rendering, causing the "Cube" and "Sphere" GameObjects to overlap.
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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
Resolution Note:
The renderer can't know the two calls to Camera.Render are connected and allocates a different depth buffer. This is not the case with the main scene as the engine knows all the cameras before rendering and assigns them to the same stack.
A possible workaround is as follows
1) Create new render texture asset in the project
2) Duplicate First & second cam and set them up in the inspector to render to the render texture from (1)
3) Assing the render texture from (1) to the RawImage canvas object
Similar set-up can be achieved from script. Setting it up this way means unity will automatically set up the two cameras as part of a stack and render correctly to them every frame as part of the main update loop. This also doesn't need a script.
I hope this helps.