Hello!
I’m attempting to use a custom scene view extension to save off the stencil buffer to its own texture so it can be used later. The code looks something like this
FScreenPassTexture FSavedFramebufferSceneViewExtension::PostProcessPassAfterTonemap_RenderThread(FRDGBuilder& GraphBuilder, const FSceneView& View, const FPostProcessMaterialInputs& InOutInputs)
{
if (InOutInputs.CustomDepthTexture)
{
// CustomDepthTexture is a pointer to a R8G8B8A8 texture I've created with UTextureRenderTarget2D::InitCustomFormat
FRDGTextureRef DestinationCustomDepthTexture = RegisterExternalTexture(GraphBuilder, CustomDepthTexture->GetResource()->TextureRHI, TEXT("ORSavedFramebuffer_CustomDepth"));
FIntVector CustomDepthSize = InOutInputs.CustomDepthTexture->Desc.GetSize();
AddDrawTexturePass(
GraphBuilder,
View,
InOutInputs.CustomDepthTexture,
DestinationCustomDepthTexture,
FIntPoint::ZeroValue,
FIntPoint::ZeroValue,
FIntPoint(CustomDepthSize.X, CustomDepthSize.Y)
);
}
}
However this doesn’t seem to work - I can read the depth value but the stencil value is always 0. Is there something else I need to do here? I’ve seen other places in the code create an SRV based on the CustomDepth texture using PF_X24_G8, but that didn’t seem to work all - giving me neither the stencil nor the depth.
[Attachment Removed]