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.

Bug Unity Graphics bug on Mac M1 chip

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

  1. Marc477

    Marc477

    Joined:
    Jan 16, 2017
    Posts:
    129
    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.
     
  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
     
    Marc477 likes this.
  3. Marc477

    Marc477

    Joined:
    Jan 16, 2017
    Posts:
    129
    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.