Question by
popuppirate · Nov 04, 2018 at 03:05 PM ·
cameradistance
Pixel to z-Distance in Unity
I am looking to build a script to create an array of the z-distances of each pixel from a screenshot of the camera in a 3D, such that each pixel has an associated depth value.
To be clear, this has to be the absolute distance and not the 0-1 value associated with the pixels of a depth image. I see two points of attack:
Using the Camera.ScreentoWorldPoint class to iterate through the pixels and obtain the z value;
Get the depth image and normalise the pixel values to the field of view of the Camera.
Can I be advised which of these methods would best suit my needs, or if there is a better method I am not aware of yet?
Comment