# Reading Render Targets without blocking game thread

**URL:** <https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 20, 2018, 11:45pm UTC](https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831 "2018-04-20T23:45:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeavyBullets](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeavyBullets](https://forums.unrealengine.com/u/HeavyBullets)\
**Post date:** [April 20, 2018, 11:45pm UTC](https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831/1 "2018-04-20T23:45:41Z")

</div>

Hey guys, i’m trying to read the data from render targets that i use to simulate water reactiveness like this:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/9/ed93454d9de074ab6265ff6f76f7ee85eb8e121a.jpeg "LostForest: ReactiveWaterTest") ](https://www.youtube.com/watch?v=RWI1CRieWLs)

Now, i want to add buoyancy to this generated waves, for this i have to re-read the render target info.

The problem is that the only info i have found at the moment is this one:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

With some adjustments, mainly getting the render target like this:  
FRenderTarget \*RenderTarget = Heightfields[CurrentHeightfieldIndex]-\>GameThread\_GetRenderTargetResource();

I have been able to recover the render target info without any kind of crashes… but is veeeery slow, from 120 fps to 30fps (even limiting the updates to 30 fps TOP).  
This line:

RHICmdList.ReadSurfaceData(  
Context.SrcRenderTarget-\>GetRenderTargetTexture(),  
Context.Rect,  
\*Context.OutData,  
Context.Flags  
);

is really slow, and i need to know if there’s a way to get the pixel data quickly… does anybody have an idea on how i can achieve something like that? or is it imposible right now?

I’m doing other things with RenderTarget like FFT/IFFT calculus, and is pretty mandatory to be able to queue data to be read from the render target at some point, even for basic buoyancy.

Cheers!

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [April 21, 2018, 12:00am UTC](https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831/2 "2018-04-21T00:00:36Z")

</div>

Even if you create a separate thread to do this, the action of reading pixels will probably lock the render thread until finished, so I’m not sure if there’s a workaround other than reduce resolution of the captured texture.

---

<div class="post-metadata">

**Author:** ![HeavyBullets](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeavyBullets](https://forums.unrealengine.com/u/HeavyBullets)\
**Post date:** [April 21, 2018, 12:04am UTC](https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831/3 "2018-04-21T00:04:04Z")

</div>

The problem is the “copying” of the data itself? would it be better if i read specific pixels instead ?

---

<div class="post-metadata">

**Author:** ![HeavyBullets](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeavyBullets](https://forums.unrealengine.com/u/HeavyBullets)\
**Post date:** [April 21, 2018, 12:48am UTC](https://forums.unrealengine.com/t/reading-render-targets-without-blocking-game-thread/109831/4 "2018-04-21T00:48:40Z")

</div>

I have found that disabling HDR does an idiotic performance boost, for this we should use RTF\_RGBA8

There’s an issue though, if we use any other value than RTF\_RGBA\_SOMETHING, the Render thread will crash, most probably because it assumes the 4 channels to always be allocated.  
Does anyone knows why such a massive improvement from not using HDR?
