I have a render feature where Im interacting with multiple RTs but for this example Ill assume we have 2, the camera texture and a custom RTHandle.
Currently its works fine with a single SetRenderTarget:
buffer.SetRenderTarget(new RenderTargetIdentifier[]{BuiltinRenderTextureType.CurrentActive, _handle}, BuiltinRenderTextureType.CurrentActive);
buffer.ClearRenderTarget(false, false, Color.clear);
This renders properly on both textures. But I’d like to clear “_handle” and not the camera texture. When I try this:
cmd.SetRenderTarget(_handle, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare);
cmd.ClearRenderTarget(false, true, Color.red);
cmd.SetRenderTarget(new RenderTargetIdentifier[]{BuiltinRenderTextureType.CurrentActive, _handle}, BuiltinRenderTextureType.CurrentActive);
cmd.ClearRenderTarget(false, false, Color.clear);
SetRenderTarget does not work a second time. If I move the first two calls to OnCameraSetup, or FrameCleanup, the texture always stays the color red, nothing is drawn into it. Which I dont understand because drawing is still occurring inside Execute(). What can I do to clear this RTHandle properly prior to draw?