c++unreal-engine5

ue5 - How to run code inside the render pipeline?


I am working on a plugin (I cannot edit the engine sources) where I need to update a view-dependant texture each frame (in a dll, done in CUDA), and use it in a material.

I use a UPrimitiveComponent to render a mesh, shaded with the view-dependant texture material on one particular camera, and shaded with a black material on other views. My idea was to store the Camera's FSceneView I get from my proxy's GetDynamicMeshElements() and use it later to update the texture, when the frame is actually rendered.

However I cannot find a way to sneak in the render thread to launch the update each time a frame is rendered.

ENQUEUE_UNIQUE_RENDER_COMMAND does not fit my needs because the commands are executed the sooner the thread can, not at the actual "frame rendering pace".

Can anyone give me a lead, or maybe another approach to reach my goal ? Thanks


Solution

  • I ran into a feature called Scene View Extensions, that allows users to hook into multiple stages of the render pipeline.

    Here is a great article to present it.