Search Unity

3d mesh inside ui canvas rendering white on mobile device only

Discussion in 'Editor & General Support' started by walaber_entertainment, Feb 11, 2018.

  1. walaber_entertainment

    walaber_entertainment

    Joined:
    Jul 10, 2017
    Posts:
    30
    I'm experiencing a strange issue: I have a canvas rendered with a Screen Space - Camera in my project. When the player collects a "coin", I enable an object in the canvas hierarchy (and on the UI layer) that is a 3D mesh of the coin, which I animate up to the top of the screen.

    The mesh's game object is on the UI layer, and there is a separate directional light in the scene that only lights the UI layer.

    Everything looks fine in the editor, but on device (iOS) the coin loses it's texture as it progresses up the screen, turning almost completely white. Frame Debugger isn't giving me any useful hints and I've tried toggling the various options on the mesh renderer to no avail.

    Any idea what could be causing this?
    FloppyFrog_20_ui_bug.jpg

    Unity version: 2017.3.0f3
    iPhone X, iOS 11.2.5
     
  2. Roeliefantje

    Roeliefantje

    Joined:
    Jan 18, 2018
    Posts:
    3
    It looks like something is only lighting up a part of your screen. I think the directional light that is supposed to be lighting up your UI, is also effecting the part of your game that is in the box of your Ui Canvas.
     
  3. walaber_entertainment

    walaber_entertainment

    Joined:
    Jul 10, 2017
    Posts:
    30
    yes, I have a directional light for the main scene, with it's layer mask set to ignore the UI layer, as wall as a separate Directional light set to mask only to the UI layer.

    After some more digging, I think it's related to the scale of the 3D mesh. to make it fit pixel units I have to scale the object up a ton (~80x), and I think the mobile incarnation of the standard surface shader makes some optimizations on mobile that makes the lighting calculations go wonky when such a large scale is involved.

    For now I've just rendered the object out into a sprite and I've replaced with that, which of course works fine.