How can I extract and export SceneDepth and SceneColor from SceneCapture2D in a Blueprint?

Hello, I’m trying to export SceneDepth and SceneColor with SceneCapture2D component in runtime. I’m using SceneColor (HDR) in RGB, SceneDepth in A capture source option to do that.

After many tries, I found that I can use ExportRenderTarget to export render target. But problem I have with it is that I cannot split SceneDepth and SceneColor from RenderTarget when I export.

I’m currently using materials to extract those like



which seems to work when I use that material on some components
image

And I’m referring to to draw and export the material


Currently my blueprint looks like this, and it exports blank png files right now. Export Render Target seems to work when I chose the RenderTarget that corresponds to the SceneCapture2D component directly, instead of RenderTarget2D created in the Blueprint. However, as I said earlier I want to get separate images for SceneDepth and SceneColor.

Any help on how to fix this or alternative way to do what I’m trying would be really helpful!

Maybe I’m getting you wrong, but SceneDepth in a Material is a value, that holds the distance from the camera to a mesh in the rendered scene - a 3D information.
A Scene Capture is just an image captured from the scene, but holds no information about distance - a 2D information, as SceneCapture2D implies.

So, you will not be able to extract the desired information from this.

What I thought is that SceneDepth holds the distance from the camera to the mesh that is shown on the corresponding pixel of the captured scene (And with the given option it would be stored in alpha layer as a floating point value).

The way I tried seemed to work since the captured scene on the left side of 3rd image does look like a depth map I expected, but maybe I got it wrong.

Hi, it looks like I was terribly wrong - just did a test and added a SceneCapture2D component to an actor - yes, it can set to keep the SceneDepth in the Alpha channel.

grafik

I tried to get more into this and recreate your issues. I only used RenderTargets quite some time ago for some cameras in scene and never with scenedepth - so good to know, that Alpha can be used for this.

Unfortunately, I cannot even call the CreateRenderTarget2D and run into ugly crashes:

Direct3DDevice->CreateUnorderedAccessView fails with E_INVALIDARG

Now I found it is caused by the RTF_RGBA8 format. Running on 4.26 for my tests. Looks like I am hitting this one

image

I’m currently using RTF RGBA16f format (RTF RGBA32f seemed to work as well, I guess it requires floating point value to represent depth), RTF RGBA8 didn’t seem to work correctly with that capture source option, I’m currently using UE 5 so not sure about that issue…

oh well I forgot that I was using RGBA8 for the render target to use for exporting, RGBA8 is needed for exporting as a PNG format. But even when I try with RGBA16f and export the render target (where material is drawn on) as EXR file, it still exports empty image