Search Unity

Resolved RenderPipelineManager.endCameraRendering and

Discussion in 'VR' 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):
    1. // All fields are created in script.
    2. public Camera blendLayerCamera;
    3. public Camera mainCamera;
    4. public RenderTexture leftRenderTexture;
    5. public RenderTexture rightRenderTexture;
    6. // Subscription: RenderPipelineManager.endCameraRendering += RenderPipelineManager_endCameraRendering
    7. private void RenderPipelineManager_endCameraRendering(ScriptableRenderContext context, Camera camera) {
    8.         if (camera == blendLayerCamera)
    9.         {
    10.             RenderTexture active =;
    11.             Graphics.Blit(
    12.                 source: active,
    13.                 dest: leftRenderTexture,
    14.                 sourceDepthSlice: 0,
    15.                 destDepthSlice: 0);
    16.             Graphics.Blit(
    17.                 source: active,
    18.                 dest: rightRenderTexture,
    19.                 sourceDepthSlice: 1,
    20.                 destDepthSlice: 0);
    21.         }
    22.         else if (camera == mainCamera)
    23.         {
    24.             Graphics.Blit(leftRenderTexture,
    25.       ,
    26.                 leftBlendMat, -1, 0);
    27.             Graphics.Blit(rightRenderTexture,
    28.       ,
    29.                 rightBlendMat, -1, 1);
    30.         }
    31. }
    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.