Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

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?

Product Version: UE 4.17
more ▼

asked Sep 22 '17 at 01:24 PM in Rendering

avatar image

6 1 2 4

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first


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.

alt text



scenecapz.png (343.1 kB)
more ▼

answered Oct 03 '17 at 12:52 PM

avatar image

41 3 2

avatar image Tobs Dec 10 '17 at 05:23 PM

What's with that magic number 0.000556? What does it mean? I am trying to read the depth value in C++ code, like this: FTextureRenderTarget2DResource* resource = (FTextureRenderTarget2DResource*)this->kinectRT->Resource;

this->m_PixelBuffer.Reset(); if (resource->ReadLinearColorPixels(this->m_PixelBuffer) == true) { }

I am not sure is this is the right way to go. But there are some Values in the R-component of the color. But the range is kinda confusing.

Martin can you give some more information about how to get depth values in code?

Cheers, Tobi.

avatar image Tobs Dec 10 '17 at 06:04 PM

Just playing around and I noticed the Depth Values in R correspond to cm, but when the object is farther away that 1m the depth values are lost. R will show a value of 65504.0. Any thought?

avatar image rYuxq Mar 09 '18 at 05:51 PM

I followed MartinS instructions and created a material for the user interface domain. I found out that the final color is expected to be in the range of 0-1, so it seems like sRGB is being used here. This explains the magic number used by MartinS. The red channel returns the distance in cm from the scene capture component, but we have to get it into a range of 0-1 in order to visualize it. In order to do this you need to divide your red channel by the maximum distance you want to perceive. So dividing by 100 would mean you would visualize everything up to a distance of 1m = 100cm. Multiplying by 0.000556 is the same as dividing by 1/0.000556, so here we go. It's not a magic number, it's a random number to prove his point.

avatar image GlassBeaver Jan 14 '19 at 10:01 PM

Thank you, thank you, thank you! I've spent hours trying to get scene capture with scene depth in R to work. Your advice wrt RTF R32f is gold.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question