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
- Error “Shader error in 'YSCloudCover': call to 'tex3D' is ambiguous at Assets/YSCloudCoverText.shader(606) (on d3d11)“ is present when compiling tex3D shader with DXC
- Placeholder asset is not loaded with Advertisement Legacy sample when using the latest version of the package
- Addressables content build fails but the Player build is successful when building a development build
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
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