Hello,
DeviceDepth returns the Z value in the 0-1 range. The value is discretized and converted to in an RGBA texture to use the full 32 bits with minimal loss of precision. To reconstruct the 0-1 range, the formula is:
R + G/255 + B/65025 + A/16581375 = Z-value
That is for a RGBA32f render target. If you use in an RGBA (8 bits per channel), you have to divide everything by 255.
If you want the depth in cm, you can use “SceneDepth in R”. This will retrieve the linear depth in cm. The RenderTarget2D texture must be in R32f format. The preview in the editor will be all red as we can’t display HDR texture properly. If you want to validate that you are getting what you want, you can create a simple material to rescale the values in a visible range. See attached image.
Regards,
Martin