Create an array of a rendered image with each pixels xyz position Lets say I have a 3d scene with some objects in it
When I render the scene to an image, I would like to have an array of each pixels position of the image, each position or pixel filled with the x,y,z value of the objects surface that appears in that specific pixel in the 2d rendered image.
What would be the best way to do it ?
You can use the &quot;Position&quot; output from the &quot;Geometry&quot; node to get the pixel world position, but the color will only contain values between 0 and 1 (units).
My solution would be to scale the values. For instance if you know for sure your objects will be constrained in a cube going from -20 to +20 in each axis, you could use this setup to &quot;remap&quot; the values between 0 and 1.
Each channel of the RGB value of each pixel will then represent their X, Y and Z real position. You would just have to remap like this : XYZ(real) = (RGB -0.5) * 20

Result with a double array of cubes

You can CTRL + Right Click to get the RGB values once rendered. Notice how only 2 values change when scrubbing along a face of a cube.