# How to read from a RTF\_R32f rendertarget

**URL:** <https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146>\
**Category:** C++\
**Tags:** unreal-engine, crash, render-target, CPP, question\
**Created:** [July 24, 2018, 12:43pm UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146 "2018-07-24T12:43:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_897e28be](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_897e28be](https://forums.unrealengine.com/u/anonymous_user_897e28be)\
**Post date:** [July 24, 2018, 12:43pm UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146/1 "2018-07-24T12:43:28Z")

</div>

Hello everyone,  
I’m having a bit of a problem with getting the data out of a TextureRenderTarget2D with the format RTF\_R32f. I can’t find a perfect match for that problem in the methods of any related class and when I do

```
    TArray<FColor> Data;
    	auto DepthRenderTargetResource = DepthRenderTarget->GameThread_GetRenderTargetResource()->GetTextureRenderTarget2DResource();
    	DepthRenderTargetResource->ReadPixels(Data);
    	UE_LOG(LogTemp, Display, TEXT("some point: %f"), *reinterpret_cast<float*>(&Data[1000]) );

```

in the Tick method of an actor with

```
UPROPERTY(EditAnywhere)
		UTextureRenderTarget2D* DepthRenderTarget;

```

in the header I get an exception. When setting breakpoints it seems to crash at the line with the ReadPixels(Data).  
I would just like to have a virtual depth camera in Unreal without the RGB luggage.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7c7e59e7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7c7e59e7](https://forums.unrealengine.com/u/anonymous_user_7c7e59e7)\
**Post date:** [May 23, 2019, 8:20am UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146/2 "2019-05-23T08:20:14Z")

</div>

Not sure if it’s the canonical way but I succeeded with the following code:

```
for (auto& Color : Data) {
    auto depth = Color.FromRGBE().R;
    // ...
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0c620da21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0c620da21](https://forums.unrealengine.com/u/anonymous_user_0c620da21)\
**Post date:** [October 30, 2019, 1:26pm UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146/3 "2019-10-30T13:26:00Z")

</div>

Hey I am running into this issue as well!

I tried to use your solution, but I am confused on how you managed to get anything in your data code based on what I have read here. To my knowledge you are doing:

//start  
TArray Data;  
auto DepthRenderTargetResource = DepthRenderTarget-\>GameThread\_GetRenderTargetResource()-\>GetTextureRenderTarget2DResource();

DepthRenderTargetResource-\>ReadPixels(Data);

for (auto& Color : Data) {  
auto depth = Color.FromRGBE().R;  
// …  
}

//end

But I also get an exception thrown when I try to run ReadPixels.

I am curious what portion I am missing, because I have been stuck on this for hours now.

Thank you ahead of time!

---

<div class="post-metadata">

**Author:** ![wyd111](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wyd111](https://forums.unrealengine.com/u/wyd111)\
**Post date:** [November 30, 2024, 2:05am UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146/4 "2024-11-30T02:05:10Z")

</div>

Set **CaptureSource = ESceneCaptureSource::SCS\_SceneColorSceneDepth;**  
Set **RenderTargetFormat = ETextureRenderTargetFormat::RTF\_RGBA32f;**  
Use **Color.A As Depth**

---

<div class="post-metadata">

**Author:** ![fallhasbegun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fallhasbegun](https://forums.unrealengine.com/u/fallhasbegun)\
**Post date:** [April 15, 2026, 2:57pm UTC](https://forums.unrealengine.com/t/how-to-read-from-a-rtf-r32f-rendertarget/430146/5 "2026-04-15T14:57:21Z")

</div>

I manage to get it working by using ReadLinearColorPixels instead of ReadPixels, it work for 32 bit texture formats as RTF\_R32f  
My setup:  
ESceneCaptureSource : SceneDepth in R  
ETextureRenderTargetFormat : RTF\_R32f
