Download

Better Render Target lookup and/or blueprint support

I’ve already implemented a quick method in C++ to read from a render target using ReadPixel but it is dreadfully slow.

You can see the results here

Is there a better way to read values from a render target?

If not can we get faster access to the data?

For textures we can already lock the buffer and do a direct read but for the render target if we don’t use ReadPixel we have to generate texture which internally calls ReadPixel.

It would also be nice to be able to drive all of this through blueprints too.

Thank you

May I ask for details of your algorythm? Why do you need to read from render target? How do you generate the render target? (What’s the data on it?) I think we can make some tricks around it (f.e. for my FFT approach I’m using buffers which can be read directly very fast).

-May I ask for details of your algorythm?
Most of the details are here https://wiki.unrealengine.com/Render_Target_Lookup

-How do you generate the render target?
It’s generated with a SceneCapture2D Component and a billboard, all blueprint for this part. If I could find a way to render a material directly to a memory buffer in C++ I would use that instead.

-What’s the data on it?
Material driven Heightmap generated blending and panning a series of noise textures.

-Why do you need to read from render target?
To get the water height value at a specific location to my blueprint actors.

When I did this in XNA I had used a purely mathematical solution and effect that needed render targets ran really fast. A mathematical solution here would completely remove the need to do a Render Target lookup but I wanted to do something quick and dirty last weekend.
I am very opened to better solutions as reading from a render target always felt like there was a better way. Still new to UE4.

You mentioned buffers for your FFT approach, how are you filling them and where do they live?

As I can see, you use the pre-rendered textures and then apply panner and scale to UVs. In this case, you can duplicate the logic in C++ while reading “source” textures and count the result. I’m doing it that way for my ocean. It count the height with the same algorythm and values as it used in shader.

UAVs mostly. They created on CPU and then filled by compute shader on GPU.

Thank you for your answers.

I agree with you that my current wave setup could easily be duplicated in C++ but this was just my first quick and dirty implementation. I am looking for faster access to a dynamic heightmap for all applications, not just ocean rendering. The ocean simulation seems to be best simulated through other means like you guys are doing.

I still would like a fast way to read buffers updated within the blueprint system. The same render target lookup system is necessary anything where actors modify the world and that those modifications need to be accumulated. Like explosions changing landscape or ice melting after an actor goes over a section of the ice sheet.. For the ocean scenario it can be used to generate wakes or other wave sources though.