Write Texture2DRHI or UAV to Render Target
Based on some code from the Fluid Surface Plugin and the UE4 Shader Plugin Demo I've written a compute shader which writes to an Unordered Access View that is part of an FTexture2DRHIRef instance.
I need to write the output from the compute shader to a UTextureRenderTarget2D, or just a UTexture2D. What is the most efficient way of achieving this? The Shader Plugin Demo uses a pixel shader to render the UAV output to the Render Target, while the Fluid Surface merely sends the RHIRef to the Vertex Factory; the former seems overkill and not very optimized, while the latter doesn't apply here as I need a texture and not a mesh. One other alternative I've seen is to copy the raw data from the UAV into the Render Target using Memcpy, but this requires me to lock the RT, access both data and copy it, then unlock the RT and call UpdateResource on it.
The goal is to send a reference to a Render Target from an Actor (which is set in a Dynamic Material) to a class that executes the compute shader and writes the output to that Render Target to update the material.
asked Jul 05 '18 at 09:40 AM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here