Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[2D URP] Overlay Camera don's work well

Discussion in '2D Experimental Preview' started by FishFly, Apr 14, 2022.

  1. FishFly

    FishFly

    Joined:
    Nov 15, 2013
    Posts:
    8
    Hi,When Camera 's type be setted to overlay, and putted in camera stack, there is only gray on screen, and some warning log show as :

    CommandBuffer: temporary render texture _CameraColorTexture not found while executing (SetRenderTarget color buffer)
    CommandBuffer: temporary render texture _CameraDepthAttachment not found while executing (SetRenderTarget depth buffer)

    3D URP is perfect . it only be happenned in 2D URP.

    My Unity Version is 2022.1.0b14.2951, And URP Package Version is 13.1.7

    Thanks.
     
  2. FishFly

    FishFly

    Joined:
    Nov 15, 2013
    Posts:
    8
    Code (CSharp):
    1.  void CreateRenderTextures(...)
    2. {
    3.      if (cameraData.renderType == CameraRenderType.Base)
    4.     {
    5.         ....
    6.     }
    7.     else
    8.     {
    9.                 // These render textures are created by the base camera, but it's the responsibility of the last overlay camera's ScriptableRenderer
    10.                 // to release the textures in its FinishRendering().
    11. /*                m_CreateColorTexture = true;
    12.                 m_CreateDepthTexture = true;
    13.  
    14.                 m_ColorTextureHandle?.Release();
    15.                 m_DepthTextureHandle?.Release();
    16.                 m_ColorTextureHandle = RTHandles.Alloc("_CameraColorTexture", name: "_CameraColorTexture");
    17.                 m_DepthTextureHandle = RTHandles.Alloc("_CameraDepthAttachment", name: "_CameraDepthAttachment");*/
    18.  
    19.                 colorTargetHandle = m_ColorTextureHandle;
    20.                 depthTargetHandle = m_DepthTextureHandle;
    21.     }
    22. }
    In the Sourcecode Overlay camera always recreate RT shared with base camera and set createTag, and CameraData.resolveFinalTarget can also recreate RT in each renderframe, Is it neccery to recreate RT in Overlay.
    Fanaly After i commented the code up, Overlay Camera worked well. But i still have no idea whether Im right.
     
  3. xenotime

    xenotime

    Joined:
    Apr 27, 2010
    Posts:
    12
    Hi. I can confirm that in my 2D multi-camera setup, perfectly functional on 2021.2 I get the same result (gray screen, same warnings...) on 2022.1.0f1 with URP 13.1.8.
    By trying to reproduce the bug on a basic test scene, I find myself with other bugs.

    Structure :
    Camera1 (Render Type: Base, Orthographic, Culling Mask: Layer1, Stack: Camera2, Camera3)
    -> Sprite1 (Layer1)
    Camera2 (Render Type: Overlay, Orthographic, Culling Mask: Layer2)
    -> Sprite2 (Layer2)
    Camera3 (Render Type: Overlay, Orthographic, Culling Mask: Layer3)
    -> Sprite3 (Layer3)

    Bugs (visible on the attached video) :
    - selecting one of the cameras in the hierarchy changes the game view (pixelated, distorted, low definition display of what is rendered by the camera)
    - changing the scene view from 2D to 3D also modifies the Game view.
    - enlarging the Game window, modifies the rendered image.
    - out of the Play mode, the Game window display is grey.



    In short, 2D stacking is no longer functional and has not been properly tested.
    It is incomprehensible that the Alpha/Beta phases did not highlight these bugs.

    I wanted to take advantage of the 2022.1 improvements but this critical issue forces me to do a rollback to Unity 2021.2.X.

    Let's hope a quick patch...
     
  4. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    We will look into this. If you can submit a bug report with your project, that will help us.
     
  5. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    82
  6. xenotime

    xenotime

    Joined:
    Apr 27, 2010
    Posts:
    12
    Thank you, version 2022.1.1f1 indeed fixes all the above mentioned problems