Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.4
2020.2.1f1
2020.3
2021.1
2021.2
2022.1
Issue ID
1345588
Regression
No
"unity_WorldToObject" is not the inverse of "unity_ObjectToWorld" when applied to a mesh
How to reproduce:
1. Open the user's attached project "MatrixBug.zip"
2. Load the Scene "MatrixBug"
3. In the Hierarchy select the "Cube" GameObject
4. In the Inspector enable only the "Apply Correct Object To World" and "Apply Correct World To Object"
5. Notice how the Cube looks in the Scene view
6. Back in the Inspector enable only "Apply Unity Object to World" and "Apply Unity World To Object"
Expected result: The Cube looks the same way it did with the user's custom transformations
Actual result: The "Apply Correct World To Object" does not inverse the object, the cube is left in a broken shape
Reproducible with: 2018.4.36f1, 2019.4.29f1, 2020.3.14f1, 2021.1.14f1, 2021.2.0b3, 2022.1.0a1
Reproducible on:
Windows Standalone
Notes:
- For "Apply Correct Object To World" and "Apply Correct World To Object" float4x4 matrix and matrix.inverse are used
- For "Apply Unity Object to World" and "Apply Unity World To Object" "unity_ObjectToWorld" and "unity_WorldToObject" are used
- Shader setup can be found in "MatrixBug.cs" and "MatrixBug.shader"
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
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
- EmptyAdditionalLightShadowmapTexture leaks from memory when URP quality level is changed using QualitySettings.SetQualityLevel
- Referenced ScriptableObject field does not get updated and cannot be set to "None" when there are no Objects of that type
Resolution Note:
When using Graphics.DrawMesh<xxx>, the matrix is supposed to be a "3D transformation matrix (not perspective)". If not (as in this sample project), then the internal invert matrix is wrong (and the cube is poorly displayed). In sample project, the "correct_WorldToObject" code path is working because it uses "matrix.inverse", that is a generic but slow matrix inverter. You get the exact same rendering issue if you use matrix.Inverse3DAffine instead (and that is what unity_WorldToObject is using internally). To sum up, DrawMesh should be used with the classic 3D transform matrix