- Home /
Image coordinate and Z buff to World Space Position
I export the depth from Unity (GetComponent().depthTextureMode = DepthTextureMode.Depth), in the range [0,1], to exploit it in C language. After rendering, I need to find the World Space Position of a 2D image point located at (u,v) in my texture. (It seams to be equivalent to the function ComputeWorldSpacePosition of the SRP). My understanding is that, I have to : 1/ express u, v and the depth from Unity in the range [-1,+1]. 2/ transform this point by the Inverse projection matrix. 3/ transform the point by the camera to projection matrix. Is it that simple ?
Thanks for your help.
Answer by Bunny83 · Feb 18 at 03:28 PM
Yes, pretty much ^^.Is it that simple ?
- ViewPort space (0 to 1) to NDC space (-1 to 1 ).
- Unproject by the inverse of the projection matrix. (make sure to use MultiplyPoint as it does perform the homogeneous divide by w automatically).
- Use the cameraToWorldMatrix of the camera to transform from camera space to worldspace.
This should do it.
Ohh boy, UA is now even more broken than it ever was before. Now simple numbered lists do not work anymore...
Thank you Bunny83 for your quick reply! I thought I have to divide by w at the end, after the cameraToWorldMatrix transformation to obtain the [XYZ1] 3D point. Why do I have to divide by w before the cameraToWorldMatrix ?
Your answer
Follow this Question
Related Questions
Objects with same position appear in different places 2 Answers
Physics in Local Space rather than World Space 2 Answers
Convert Unity position to Maya position 1 Answer
Rotate and transform in local space 2 Answers
Object only rotates in local space 1 Answer