x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.19
Tags:
more ▼

asked Jul 05 '18 at 09:40 AM in C++ Programming

avatar image

NickEast
21 2 3 3

avatar image MaximeDupart Mar 28 '19 at 05:00 PM

Ever found a solution?

avatar image NickEast Mar 28 '19 at 05:33 PM

I did find a solution not long after asking, but later I no longer needed it and it has been two versions back since I last used it. Unfortunately, I no longer have the project and I cannot remember how I solved it. What I do remember is that it did involve creating a second RT just for the shader, executing the shader, and then copy the data from that RT to the actual RT used in the material (either created at runtime in code or Blueprint, or as an asset).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question