Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multi-camera rendering, clear flags, frame debugger, and URP contributing

Discussion in 'Universal Render Pipeline' started by Jonathan_L, Nov 2, 2019.

  1. Jonathan_L

    Jonathan_L

    Joined:
    Jan 26, 2016
    Posts:
    43
    Hi, I am trying to render a second camera in another one's clear space, or the space that no objects are being rendered to. This is achievable in the standard pipeline but not URP.

    To explain what I mean, in the image below I have a cube with a shader that renders nothing (ColorMask=0) but depth (ZWrite=On). I have another camera (lower depth) at another location which renders underneath. ClearFlags for both camera is skybox.

    upload_2019-11-2_12-16-46.png .

    Now when I switch to URP I get the following:
    upload_2019-11-2_12-20-53.png

    Even though clear is on skybox, it is using the background color to clear.

    So I am working with the open source ScriptableRenderPipeline project under the universal/camera-stacking branch (I thought this branch would be better to work with) and I came across ScriptableRenderer.cs and found the following while creating this post:
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.             // We need public API to tell if FrameDebugger is active and enabled. In that case
    3.             // we want to force a clear to see properly the drawcall stepping.
    4.             // For now, to fix FrameDebugger in Editor, we force a clear.
    5.             cameraClearFlags = CameraClearFlags.SolidColor;
    6. #endif
    When I commented out that line, the camera clear flag gets properly set from the background type "Skybox" and everything works as expected.

    So my questions are: What is exactly happening in the code above? I would like to comment out that code to fix this problem but I don't want to run into any issues this might cause later down the line. Might there be another way to set the correct camera clear flags without running into that frame debugger issue? I am new to open-source contributing so I am not sure where to ask this question or how to raise or view issues on that matter. Any guidance?
     
  2. Bazilikum

    Bazilikum

    Joined:
    Mar 10, 2018
    Posts:
    3
    Did you ever get an answer to this?
    I also stumbled across this wondering why my targets are cleared even though I specified they shouldn't.
     
  3. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    URP uses camera stacking instead
     
  4. Bazilikum

    Bazilikum

    Joined:
    Mar 10, 2018
    Posts:
    3
    Camera stacking is great, and we use it as well.

    Unfortunately, that doesn't help me.
    the problem I am facing is that any camera in the scene has to have a renderer. that means, that when it passes through the ScriptableRenderer its target is being cleared (on mobile it's even always cleared). I have a camera in the scene that I use to draw to a render texture that is not layered (stacked) and I don't want it to be cleared. From what I see, there is no way to do that and I have to use draw commands that don't use a camera, which makes it a bit more complicated.
     
    Orimay likes this.