Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Resolved RenderPipelineManager.endCameraRendering and

Discussion in 'Audio & Video' started by NevinAF, Jul 22, 2021.

  1. NevinAF


    May 12, 2021
    [Unity 2020.3 in URP]

    I have been working on blending cameras with different culling masks. I got it working exactly how I wanted, but it stopped working without any changes to the code. I had working versions on the previous git commits, but once I reverted to the commits, it was no longer working.

    I was using and Graphics.Blit() to overlay one camera render texture over another (Note that this is set up for VR using depth layers and WAS working in Multipass and SinglePass):
    Code (CSharp):
    2. // All fields are created in script.
    3. public Camera blendLayerCamera;
    4. public Camera mainCamera;
    5. public RenderTexture leftRenderTexture;
    6. public RenderTexture rightRenderTexture;
    8. // Subscription: RenderPipelineManager.endCameraRendering += RenderPipelineManager_endCameraRendering
    9. private void RenderPipelineManager_endCameraRendering(ScriptableRenderContext context, Camera camera) {
    10.         if (camera == blendLayerCamera)
    11.         {
    12.             RenderTexture active =;
    14.             Graphics.Blit(
    15.                 source: active,
    16.                 dest: leftRenderTexture,
    17.                 sourceDepthSlice: 0,
    18.                 destDepthSlice: 0);
    20.             Graphics.Blit(
    21.                 source: active,
    22.                 dest: rightRenderTexture,
    23.                 sourceDepthSlice: 1,
    24.                 destDepthSlice: 0);
    25.         }
    26.         else if (camera == mainCamera)
    27.         {
    28.             Graphics.Blit(leftRenderTexture,
    29.       ,
    30.                 leftBlendMat, -1, 0);
    32.             Graphics.Blit(rightRenderTexture,
    33.       ,
    34.                 rightBlendMat, -1, 1);
    35.         }
    36. }
    The problem is was originally set to the camera's render, but it is now (and in the commits) is null.
    I'm not sure if something is not being tracked in the project settings, or if this setup is not reliable. Anyone with any insights would be helpful
  2. NevinAF


    May 12, 2021
    I just realized that Unity has built-in camera renderings that differ depending on if a VR headset is connected. I figured this might be a problem at first but I dismissed it because I ran builds of the previous commits without an HMD and everything ran as expected.

    For anyone who is curious, the above only works if a headset is connected. But, if the project is built when the headset is connected, then it will run properly without a headset connected. A little weird which is why it gave me some trouble.