# Simulate depth camera. Depth settings not working as expected

**URL:** <https://forums.unrealengine.com/t/simulate-depth-camera-depth-settings-not-working-as-expected/408086>\
**Category:** Asset Creation\
**Tags:** scenecapturecomponen, scenecapture2d, depth, unreal-engine, question\
**Created:** [October 27, 2017, 10:18am UTC](https://forums.unrealengine.com/t/simulate-depth-camera-depth-settings-not-working-as-expected/408086 "2017-10-27T10:18:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_450880d0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_450880d0](https://forums.unrealengine.com/u/anonymous_user_450880d0)\
**Post date:** [October 27, 2017, 10:18am UTC](https://forums.unrealengine.com/t/simulate-depth-camera-depth-settings-not-working-as-expected/408086/1 "2017-10-27T10:18:06Z")

</div>

Hi

I’m trying to simulate a depth camera.

After some research I found that this should be possible with a ASceneCapture2D object and set CaptureSource to SCS\_SceneDepth or SCS\_DeviceDepth.

Following [this post](https://answers.unrealengine.com/questions/708727/what-does-devicedepth-option-under-scenecapturecom.html) SCS\_SceneDepth should output values in cm, but I get values in [0,1].  
The calculation with SCS\_DeviceDepth seems to work (but alpha is always 1).

I setup the TextureTarget as following:

```
renderTarget = UCanvasRenderTarget2D::CreateCanvasRenderTarget2D(GetWorld(), UCanvasRenderTarget2D::StaticClass(), PictureResolutionX, PictureResolutionY);
renderTarget->bHDR = 1;
renderTarget->InitAutoFormat(PictureResolutionX, PictureResolutionY);

```

And read the pixels in the FLinearColor struct.

If I read the red value of a SCS\_SceneDepth pixel I get values in [0,1] on the contrary to the promised cm values.  
This wouldn’t be a problem by itself, but the [0,1] values from SCS\_SceneDepth (and also from SCS\_DeviceDepth) don’t seem to be linear, so I don’t know how to convert them back to cm values.

As I’m trying to simulate a max range on the camera this is a problem. I need to scale the values that the colors white to black map linear from 0cm to e.g. 350cm.

I tried to make some measurements with accurately placed planes and discovered an other problem. The cm range behind the [0,1] values do not seem to be static. If a plane fills the whole field of view the values get rescaled so that the planes is displayed in white.

* * *

So my Questions are:

1. How to I read the cm values from a SCS\_SceneDepth pixel?
2. As I would like to have the best possible precision. How to i convert the [0,1] values back to cm?
3. And last how do I prevent the above described rescaling?

* * *

Thanks for any information to my questions. I found near to nothing to this topic that seems to work and site like [this](https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Depth/index.html#scenedepth) are not helping at all.

---

<div class="post-metadata">

**Author:** ![pygospa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pygospa](https://forums.unrealengine.com/u/pygospa)\
**Post date:** [July 2, 2018, 2:04am UTC](https://forums.unrealengine.com/t/simulate-depth-camera-depth-settings-not-working-as-expected/408086/2 "2018-07-02T02:04:06Z")

</div>

Hi,  
as I am working on something similar - did you manage to find a solution? If so, might you share your findings?

---

<div class="post-metadata">

**Author:** ![mslitto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mslitto/32/580324_2.png) [@mslitto](https://forums.unrealengine.com/u/mslitto)\
**Post date:** [March 15, 2023, 1:33am UTC](https://forums.unrealengine.com/t/simulate-depth-camera-depth-settings-not-working-as-expected/408086/3 "2023-03-15T01:33:12Z")

</div>

Hey there here is a great tutorial

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/6/6164134d19c110e316aad10220eda3a0853a67ce.jpeg "Unreal Niagara - 3D Hologram effect (FULL TUTORIAL)") ](https://www.youtube.com/watch?v=K4CHg0LL5_o)

I hope this is what you ment
