Search Issue Tracker
By Design
By Design in 6000.1.X
Votes
2
Found in
2021.3.46f1
2022.3.53f1
6000.0.27f1
6000.1.0a5
Issue ID
UUM-87456
Regression
No
Rendering into RenderTexture is affected by Camera transforms when using DrawMeshNow
Reproduction steps:
1. Open the attached “DrawMeshDebug.zip” project
2. Open the “Scene” Scene
3. Enter the Play mode
4. Observe the Game view
5. Now Build and Run the Project (File > Build and Run)
6. Observe the Player
Expected result: Game view matches the Player, a red static square is visible while the Camera is moving
Actual result: In the Player, the red texture is drawn based on Camera position
Reproducible with: 2021.3.46f1, 2022.3.53f1, 6000.0.27f1, 6000.1.0a5
Reproducible on: Windows 11
Not reproducible on: no other environment tested
Note:
- Only reproduces in the Player
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
- Localization Group Rules bypasses Locale logic when SharedGroup asset provided
- UI Toolkit World UI Text Field unfocuses immediately when clicking on it using XR Controller
- Crash on CallWindowProcW when entering Play mode for the second time and running the Editor in the background while using System.Windows.Forms functions
- 2D Freeform Light shadows disappear when light center is offset from shape bounds
- Crash on MarkAllDependencies when opening scenes with Assets from the YarnSpinner package
Resolution Note:
DrawMeshNow happens outside the usual render loop. At the point in time when it is executed, no camera is actively being rendered. As a result, camera-related data, like the projection matrix, should be treated as uninitialized data, and not be used by the shader. No guarantees are given to what camera-related shader properties are set to, and any value incidentally set should not be relied upon. The behavior of these properties can change at any point in time.
The repro project also uses GL.LoadProjectionMatrix. This function is not intended to be used together with DrawMeshNow, and only affects subsequent GL.xxx calls like GL.Begin / GL.End. Note that the use of the entire GL class is discouraged, and usually not very performant.
The recommendation to resolve the issue is to use a custom shader that does not access camera matrices for the DrawMeshNow call
Resolution Note (6000.1.X):
DrawMeshNow happens outside the usual render loop. At the point in time when it is executed, no camera is actively being rendered. As a result, camera-related data, like the projection matrix, should be treated as uninitialized data, and not be used by the shader. No guarantees are given to what camera-related shader properties are set to, and any value incidentally set should not be relied upon. The behavior of these properties can change at any point in time.
The repro project also uses GL.LoadProjectionMatrix. This function is not intended to be used together with DrawMeshNow, and only affects subsequent GL.xxx calls like GL.Begin / GL.End. Note that the use of the entire GL class is discouraged, and usually not very performant.
The recommendation to resolve the issue is to use a custom shader that does not access camera matrices for the DrawMeshNow call