_CameraColorAttachmentA and FinalBlit

I’m trying to implement custom Bloom effect in Custom Render Feature, totally bypassing URP’s post-processing stack. I’ve started from the end of pipeline - from tonemapping. So I’ve created simple render pass that grabs _CameraColorAttachmentA (HDR buffer) and tonemaps it into camera color target through custom shader. But I’ve encountered couple problems. Hardcoding _CameraColorAttachmentA does not seem reliable, but I can’t find a workaround. UniversalRenderer has RTHandle for it, but it is internal and not acessible from custom render pass. I see results of my render pass in frame debugger, but UPR’s FinalBlit pass always overwrites it in the end. I needed to push RenderPassEvent to AfterRendering+500, but I’d like to get rid of FinalBlit totally as my tonemapping fulfills all it functions anyway

For non-RenderGraph paths (pre 2023.3) you can use ‘renderingData.cameraData.renderer.cameraColorTargetHandle’ to reliably access _CameraColorAttachmentA (or B, etc, whichever is in use by the camera). Post processing stack should be using _CameraColorAttachment for color input. It usually outputs directly to the screen/backbuffer - you’ll see this as RenderTarget in the Frame Debugger.

At some point in your pipeline, URP will copy from _CameraColorAttachment into _CameraColorTarget. This happens if you specify that you need an opaque texture, and depending on the version of URP there are options for when this occurs (eg after transparents, after opaques). It can also be forced to occur earlier in the pipeline if a pass declares ConfigureInput(Color), which forces the CopyColor to be moved no later than before the pass that has ConfigureInput, ie ‘in time’ for the pass declaring it requires that as input.

For me it works fine to blit copy _CameraColorAttachment into a temporary target with a custom shader, then blit the result back into _CameraColorAttachment after (source and destination cannot be the same for a blit).