Update a texture during rendering

Hi,

we are using UE4 in a simulation environment where a 2D image is rendered by an external process and then transferred back to Unreal using the following process:

  1. The Player’s Pawn’s tick group is set to PostPhysics
  2. In the Tick() method we send the Pawn’s position to the external process
  3. We are waiting for the image to arrive from the external process
  4. We are updating the 2D texture that will be displayed on a plane in the 3D world rendered by Unreal. The received image contains transparent parts and we are rendering the texture on a translucent mesh.

We would like the 3rd step to happen at the last possible moment during the rendering to give the external process more time to perform the rendering.

At first we were waiting for the image to arrive at the end of the GameThread processing (using an AsyncTask on the game thread). The next option is to submit this code as a command to the render thread, but render commands are executed before the actual rendering process for a frame is started. We are trying to find the place during rendering where we can still update the texture using a direct RHI call just before the actual mesh is being rendered. It is not a problem if we need to modify the engine slightly.

Do you have any suggestion where we should put our hook to update the texture?

Is there a better way than to update a texture to render a 2D image that is generated separately for each new frame?

Thank you for your help in advance.

Best Regards,