Can I capture scene depth to a render target?

Pretty straight forward really. I’d like to capture the depth of the scene from above. I’ll be using it to occlude sheets of when you’re under cover. Is there anyway to simply capture a depth buffer?

Hey Skuvnar -

You can set up a Post Process Material which calls a SceneTexture:SceneDepth into the Emissive and add it in as a Blendable to a SceneRender Camera. This will render a Texture target which shows scene depth.

Thank You

Eric Ketchum

1 Like

Thank you Eric. That’s perfect.

Does this work in 4.3.3? I can’t seem to get it to work.

Some Clarification, Take your Scene Texture:Scene Depth and Divide by the Range you want to test (I was using a value of 15000 in my test map) then clamp the value between 0 and 1.

Let me know if you are still having problems -

Thank You

Eric Ketchum

I’m running into a similar issue, and there is definitely something wrong happening. I made a related post on the UDN licensee boards yesterday, and it sounds like it’s being looked into?

For reference, here is my post from UDN:

According to all of the documentation I have read, and also according this AnswerHub thread… Can I capture scene depth to a render target? - Programming & Scripting - Unreal Engine Forums …a SceneCapture2D camera should be able to have a PostProcess material assigned to it (as a Blendable), resulting in a post-process modified texture than can then be used in a material network…

But in all of my testing, I am unable to get the render target to actually respect the Post Process Blendable at all… It’s acting as if it’s simply ignoring the Blendables.

[link text]Here is a Sample Scene (.zip file)1 for reference… in this sample case, I’m attempting to render the SceneCapture2D with a basic SceneDepth Post Process applied.

Am I missing something, or is this a bug? Please advise.

Hello all -

I want to correct myself and thank edoublea for his test level. I was incorrectly testing this issue and it is a known issue with using blendables in scene capture actors. I have updated our bug report with the new information, it is TTP# 332352.

I will keep everyone informed as we track a solution down -

Thank You

Eric Ketchum

Any news? Bummed into this today (4.5.1)…

UE4.6 should have this fixed (Blendables work in SceneCaptures). Make sure bCaptureEveryFrame is enabled (it is by default) as it is required for that to work (at the moment, might change)

as of 4.7.1 I still cannot get blendables to work with SceneCapture2Ds…

Hey Chosker -

Have you insured that you are using the SceneCapture2D with the CaptureEveryFrame checked true and that the blendable is assigned to the capture actor itself in the details panel?

Thank You

Eric Ketchum

yep. everything looks correct

my M_PPDepth is meant to capture the scene from above as depth (but as you see in the capture thumbnail it really just captures the color). I tried putting a red color instead of depth and nothing changed

This was definitely resolved in 4.6.1 (haven’t switched to 4.7.x yet), just FYI.

https://dl.dropboxusercontent.com/u/3405058/UDN/PPRendTarg01.png

https://dl.dropboxusercontent.com/u/3405058/UDN/PPRendTarg01.png

ok I figured it out!

I had selected Scene Color (HDR), but postprocesses only seem to work with Final Color (LDR with PostProcess)

Hey Chosker -

What does your Post Process Material look like? Can you upload a screenshot?

Thank You

Eric Ketchum

sorry for hijacking the thread (I’ll take advantage of the fact that mr. Ketchum is answering!)

now that I’ve setup the capturing I cannot manage to get a proper view.

like I said before, what I want is a top-down heightmap of my scene. the problem now is I have a depth precision vs. FoV tradeoff. the more FOV the more distorted the scene is (as opposed to being top-down), but the less FOV the less Z-precision I get.

using a FoV of 26.0 this is what I get (already some FoV distortion and horrible depth precision)

is there a way I can set up a near and far plane? or some other workaround?

thanks

Hey Chosker -

I have not tested your exact methodology but you could try to adjust the SceneCapture2D Actor’s Max View Distance Override to set your ground level and then use that distance to divide by the Scene Depth in the Post Process Blendable to get a range and then you would probably want to normalize it to between 0 to 1 (though if I am not mistaken Scene Depth already normalizes, so you may only have to Clamp it).

Eric Ketchum

EDIT: You will probably also have to layer several render targets together to get a full un-distorted view.

hello Eric,

the picture above is with the Max View Distance Override already set to be my ground level.

the scene depth doesn’t seem normalized and the Max View Distance Override only culls objects in the distance but doesn’t have any effect on the range of depth at all.

to make it have the desired range I had already tried everything I thought about (multiply by small numbers, add the min expected distance) and the picture above was the best I could get.

I just tried a divide node as well (both as dividend and divisor) but the results are not very different from the picture above

I think if the Max View Distance Override would have an impact on the range of depth I’d probably get better results