Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved "Clear Depth" field on overlay camera doesn't affect render

Discussion in 'Universal Render Pipeline' started by bremeadev, Aug 3, 2023.

  1. bremeadev

    bremeadev

    Joined:
    Jun 21, 2021
    Posts:
    6
    Hi, my base camera has one overlay camera in the camera stack. This overlay camera is only rendering items on a specific layer without post-processing. All of these items are World-Space Canvases. Despite the "Clear Depth" field being set to false in the inspector, all items on this layer continue to render on top of the those rendered by the base camera - the depth buffer seems to have been cleared. Toggling the field doesn't make any difference. Am I using this property wrong, or is this a bug?

    Base Camera: (Note: this camera also has a Cinemachine Brain component attached)


    Overlay Camera:


    In-Game:
     
  2. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    214
    Your near and far planes are different for the two cameras, so raw depth buffer values in each case refer to different view space distances. Does it work when the near/far are the same?
     
    kro11 likes this.
  3. bremeadev

    bremeadev

    Joined:
    Jun 21, 2021
    Posts:
    6
    Hey, I didn't even notice they were different until you pointed it out! I've updated them to match and everything works as expected now. Thanks for catching this silly mistake :)
     
    ElliotB likes this.