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

Resolved Some shaders don't render on asset bundle builds (IOS and Android)

Discussion in 'General Graphics' started by RafaelGomes00, Mar 14, 2022.

  1. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    I'm having a problem in a game that i'm working on that, my shaders simply don't render, most of the cases it just hides the entire game object, or it just sticks on a solid color, both IOS and Android, only when i create a build for the Appstore and Playstore. When I generate an apk, the shaders works just fine.

    Additional info:
    - Shaders are being placed in sprites using Sprite lit shader graph (or code)
    - Using Universal Render Pipeline
    - Unity Version: 2020.3.30f1 (LTS)

    Already tried:
    - Placing shaders into Always include
    - Converting shader graphs to coded shaders
    - Trying to use another Graphic API
    -This one showed me that either OpenGl 2 and OpenGL 3 don't work. Vulkan graphic API do work, but it gets granulated (One pixel renders, Next don't, Next renders...).​
     
  2. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    Solved it!!!

    Just sended all shaders to a Resources folder
     
    Ansink likes this.
  3. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    Actually It solved in parts, when i generate a build with personal license, It Works, but when i generate It with a plus license It doesnt.
     
  4. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Unity depends on materials and shader variant collections to know which shader keyword combinations to compile when building asset bundles and resources. If your materials are in bundles, but the shaders are in resource folders, it can miss out some keywords.

    For guaranteed results, you should place materials and their shaders in the same asset bundle.
     
  5. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
  6. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    How are you organizing and loading things from bundles?
     
  7. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    Actually the bundles are being generated automatically when unity creates a build.
    I just discovered how to create an asset bundle.
     
  8. RafaelGomes00

    RafaelGomes00

    Joined:
    Aug 13, 2020
    Posts:
    73
    Just for future research, the problem was because of my canvases, unity won't render shaders on Screen Space - Overlay canvases, only Screen Space - Camera, because overlay isn't compatible with shaders.
    Why activating the unity splash screen solved the problem, we still don't know. But we just ignored it and changed or canvases that use shaders.