Graphic.Blit with HDRP issues on Build only

So I have a Graphic.Blit function which is used with a Rendertexture to create tracks in the snow - this works fine in the Editor but not on build. I’m sure it isn’t a problem with the shader as it displays everything else properly just not the Rendertexture (used as a sort of mask) - there are no errors in the console in Editor or in build.

The documentation for Grpahic.Blit Unity - Scripting API: Graphics.Blit - states

“If you are using a Scriptable Render Pipeline (like HDRP or Universal RP), to blit to the screen backbuffer using Graphics.Blit, you have to call Graphics.Blit from inside a method that you register as the RenderPipelineManager.endFrameRendering callback.”

and I’ve googled as much as I can but cannot find much info on this. Can anyone give me a push in the right direction or just a link where I can read up more on this?

Also happy to provide the code if needed but there is a lot of it :slight_smile:

so I’ve tried to put my function into callback as suggested. from what I managed to google it seems this is what I was meant to do

private void OnEnable()
        {
            RenderPipelineManager.endFrameRendering += (context, camera) => { myFunction(); };
          
        }

        private void OnDisable()
        {
            RenderPipelineManager.endFrameRendering -= (context, camera) => { myFunction(); };
        }

Two issues here:

  1. It doesn’t work
  2. whenever i hit the stop play button (so editor is not in play mode) the console keeps printing out errors saying that referenced objects are null and so on as if the function is still running even though I’ve unsubscribed from it onDisable??

I tried this as well. Got so far that something happens, but my RenderTexture gets blitted to the Scene View, not the Game View as I wanted. The callback is working, but Graphics.Blit() seems not to. Could someone maybe try this and tell me what result they get?

    private Camera cam;
    private const RenderTexture rtNull = null;

    private void Start()
    {
        cam = GetComponent<Camera>();
    }

    private void OnEnable()
    {
        RenderPipelineManager.endFrameRendering += BlitCamera;
    }

    private void OnDisable()
    {
        RenderPipelineManager.endFrameRendering -= BlitCamera;
    }

    private void BlitCamera(ScriptableRenderContext context, Camera[] cameras)
    {
        Graphics.Blit(cam.targetTexture, rtNull);
    }