What does DeviceDepth option under SceneCaptureComponent2D capture?
I find the depth values to be wrapped between 0.0 to 1.0 as bands. And this wrapping is different for each of the RGB channels of the DeviceDepth captured.
How can I get the absolute depth value in UE4?
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.
answered Oct 03 '17 at 12:52 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here