Copy result of pass to another pass of the same shader

Just checking. Is this correct?

My shader has 3 passes:

  • First one is an horizontal gaussian blur:

  • The second a vertical gaussian blur applied to the previous (it is separable, so It’s O(2n) instead of O(n^2).

  • After that, I apply a bloom, which is applying the blurred image to the original texture.

     // Apply Gaussian blur
     RenderTexture temp1 = RenderTexture.GetTemporary(source.descriptor);
     Graphics.Blit(source, temp1, bloomMaterial, 0);
    
     RenderTexture temp2 = RenderTexture.GetTemporary(source.descriptor);
     Graphics.Blit(temp1, temp2, bloomMaterial, 1);
    
     // Apply bloom. The additional texture will be the result of those two steps
     bloomMaterial.SetTexture("_MainTex2", temp2);
     Graphics.Blit(source, destination, bloomMaterial, 2);
    

I’m having problems with DX11 and Unity is crashing. No idea if this is the reason.

OK. I didn’t release the textures. I thought this was similar to other features of Unity.

RenderTexture.ReleaseTemporary(temp1); ...

Not is works.