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

Bug Unity Graphics bug on Mac M1 chip

Discussion in 'General Graphics' started by IndieMarc, Feb 10, 2022.

  1. IndieMarc

    IndieMarc

    Joined:
    Jan 16, 2017
    Posts:
    183
    I think i found a Unity bug. This bug is only present on Mac with M1 chip. It works fine on Windows or older Mac with AMD graphic card.

    The bug happens when you try to layer more than 1 camera on top of each other. In my case i had the UI layer on one camera, and the sprites (default layer) on another camera. The UI camera is only displaying UI stuff (through a canvas) while the sprite camera is displaying objects in the scene, but not the UI.

    Basically the bug is that none of the sprite are displaying, instead the whole screen is glitching with graphics jumping everywhere very fast (most of the screen is black, but you can see some random glitch appearing everywhere) Basically nothing can render correctly.

    Unity 2020.3.25
    Mac Montery 12.0.1
    Using URP (Universal render pipeline)

    Sprite Camera
    Priority: -1
    Culling Mask: Default
    Background Type: Solid Color (black)

    UI Camera
    Priority: 1
    Culling Mask: UI
    Background Type: Unitialized

    IMPORTANT: The glitch only appear in the build. Not if you play from Unity.

    Both camera are Orthographic since its a 2D game, I guess to reproduce the error you could just add some UI images in the UI layer, and then some 2D sprites in the default layer.

    The idea to have 2 camera was to have post processing only on the sprite (not on the UI) which works on other devices, i also tried to deactivate the post processing but the glitch is still there, so the issue is not related to post processing. The only thing that solved the problem is to have only one camera with Solid Color as background type. I think the issue comes from having a camera with the Unitialized backgroud type. But this was important in my use case because the idea was to render the UI on top of the post processed sprites.
     
    odaimoko likes this.
  2. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Exactly, uninitialized means that the background can be anything including garbage, it does not mean that it's going to be previous camera output. The fact that it works like you expect on some machines is just a coincidence.
    That is not a bug, but by design. To properly combine multiple camera rendering you have to use camera stacking https://docs.unity3d.com/Packages/c...es.universal@13.1/manual/camera-stacking.html
     
    IndieMarc likes this.
  3. IndieMarc

    IndieMarc

    Joined:
    Jan 16, 2017
    Posts:
    183
    Well i've been doing that forever and it has always worked on all device including mobile, desktop, mac, linux, everything. The M1 chip mac is the first one I encountered with this issue.
    What would be the utility of Unitialized? I thought it meant the previous camera.
     
  4. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Uninitialized is usefull for when you are going to render to all pixels in the screen, so that no memory bandwidth is wasted to write the intial values, when you are going to replace them all anyway.
     
    mabulous likes this.
  5. mabulous

    mabulous

    Joined:
    Jan 4, 2013
    Posts:
    198
    I doubt this worked for you on mobile before (in particular with having post-processing on the lower camera, which forces multiple render passes), since tile-based renderering architectures (most mobile phones today, as well as M1) would have to reload the output of the previous camera from device memory into GMEM, which is slow, so they don't do that for invalidated render targets (on Immediate mode renderers, which most desktop GPUs are, there usually is still the old content in the render target - but this is undefined behavior)
     
  6. gszczesz

    gszczesz

    Joined:
    Sep 8, 2019
    Posts:
    2
    I'm seeing the same problem with 2019.3.11: I don't want to stack cameras using the new stacking algorithm because it applies post rendering to it which I don't want (bloom in particular is not good on the GUI overlay). The manual says multiple Base cameras are allowed and it follows the rendering priority, so I have uninitialized GUI camera as the very top priority and by the time it gets to it, all the screen has been drawn on already. Has always worked before and now on MacOS it's broken.
     
    odaimoko likes this.
  7. odaimoko

    odaimoko

    Joined:
    Jun 28, 2020
    Posts:
    8
    Have you solved this yet? I have tried manually split the rendering and combine them afterwards, but on Windows not Mac.