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.
  2. Dismiss Notice

Opaque standard shader is transparent on device

Discussion in 'Android' started by KristoferBoman, Oct 8, 2018.

  1. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    60
    Hi,

    We have our game released on iOS and right now we're preparing the Android version. But we have a problem with several models/materials in our menu scene.

    All the materials on these models are set to use the standard opaque shader, but when we build and run the game on any Android device these models are displayed as transparent (see screenshots)

    Everything works fine in the editor and on iOS.

    The models also display correct if i import them to an empty project and building that to the phone. So it seems to be specific to our main project somehow.

    I have also tried different shaders like the Mobile/BumpedDiffuse, but the models are still transparent when deployed to a device.

    I did a test the other day creating a empty scene in our main project and adding the models to it - still transparent when deployed to an Android device.

    BUT
    The same models are use in our gameplay scenes. In these scenes the models are displayed correct.

    I really dont have a clue what is going on and i've tried a lot of things at this point.

    Please advice!

    Best,
    Kristofer
     

    Attached Files:

  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    Hi!
    Which Unity version are you using? What are the player settings for android and for the camera?
     
  3. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    60
    Hi @aleksandrk,

    We're using Unity 2018.2.8f1, however we had the same problem in 2017.2.0p4. Did some more experimenting yesterday in our main project.

    1. New empty scene. Added our character model with materials and one instance without materials(unit default). Both had the same transparancy problem.
    2. Switched to deferred rendering path on the camera in the empty scene. Both models display correct.

    Attaching our settings.
    Note that i have the Graphics API set to Vulkan, but it does not mather if whatever API i use.

    Thanks,
    Kristofer
     

    Attached Files:

  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    Can you please make a screenshot of the camera settings and presentation settings part in the player settings?
     
  5. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    60
    We have several cameras in the main menu.

    1. For the character
    2. For the weapons and other items
    3. For the map
     

    Attached Files:

  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    So, in the presentation settings you have something interesting: disable depth and stencil is checked. Try unchecking it.
    Also, all the cameras you attached clear only depth, but not color.
     
  7. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    60
    Hi @aleksandrk,

    So enabling the depth and stencil makes everything work on Android. But we do not use the depth and stencil buffer in the game. Your documentation - https://unity3d.com/learn/tutorials/topics/best-practices/framebuffer even suggests turning it of if you do not use it.

    We have actually made sure we do not use the depthbuffer anywhere in our shaders just to be able to turn it of. This works perfectly on iOS.

    So my question now is if this is an Android specific problem? Is it even possible to have the depth buffer turned off on Android? Could it be a combination of settings that makes it not to work on Android?.

    Anyway i'm glad that the problem is solved, but a bit irritated that it was as simple as clicking a checkbox that does not give any problems on other platforms.

    If you have any explenation i'd gladely have it.

    Thanks,
    Kristofer
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    if you're rendering anything 3D, you're using the depth buffer. This is the way the GPU can tell if a fragment is behind another or not.
    I have no idea, why this worked on iOS. It might be that this setting is ignored. It might be something else.
     
  9. KristoferBoman

    KristoferBoman

    Joined:
    Feb 16, 2016
    Posts:
    60
    Still strange because everything works fine in our gameplay scenes with disabled depth buffer setting checked. Well, i'm glad that it's working now and i can continue working getting the Android version released.

    Thanks for the help!