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
- "Initialization Mode" and "Update Mode" drop-downs are not localized in the Custom Render Texture asset
- Switching Graphics Default or DevLook Profile to “NightSkyRenderingSettings Profile” throws “KeyNotFoundException” error in the Console window
- Section separator renders in the wrong place in Search Journaling and Archetypes windows
- [D3D12][UWP] Additional persistent shadows are drawn in UWP builds when using D3D12
- Search Journaling window link to Journal Manager documentation isn’t working
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