[RDG] How to sample a RenderTarget drawn with RDG in Materials

Hello,

I need to render a custom scene texture and sample it from Materials.
Ideally I would like to avoid changes in the engine source doe, so I am using ISceneViewExtension to hook into the rendering process.
I render to the texture by implementing my own shader with RDG in PreRenderViewFamily_RenderThread.

My rendertarget is currently created using the RenderGraph (and thus pooled) the following way:

FRDGTextureDesc MyRTDesc = FRDGTextureDesc::Create2D(/*...*/);
FRDGTexture* MyRenderTarget = GraphBuilder.CreateTexture(MyRTDesc, TEXT("MyRenderTarget");

I saw that one may reuse the texture with another RDG using

TRefCountedPtr<IPooledRenderTarget> MyRTExtracted;
GraphBuilder.QueueTextureExtraction(MyRenderTarget, &MyRTExtracted);

but that only works if I reuse it with a custom shader pass, not in a basepass material.

How could I have a material that can sample it ? I would like to avoid copies if possible.

Note: this is similar to this question [RDG] Transfer Result of Compute Shader to Material (RenderTarget?)

2 Likes

got any updates on this? I need to do the same for mobile VR… scene view extension was showing buffers weren’t populating so now I’m digging in RDG in a similar fashion as you describe.