Search Unity

Question (Unity 2020.3) What is best practice to include shaders?

Discussion in 'General Graphics' started by PhanyFany, Mar 24, 2021.

  1. PhanyFany

    PhanyFany

    Joined:
    Jan 5, 2021
    Posts:
    1
    I am developing an mobile AR application with Unity AR Foundation. After a successful android build, I was told one of the shaders was not found.

    ShaderNotFoundException: GLTF/PbrMetallicRoughness not found. Did you forget to add it to the build?


    I realized I forgot to include one of the shaders that is only loaded at runtime.

    I searched the internet and was taught to include the shader under Project Settings -> Graphics -> Always Included Shaders. That totally made sense but I was faced with the same problem everybody faced, the building takes ages as it compiles all my shader variants.

    I stopped the build and opted for a method that was not mentioned by the internet, I went to Project Settings -> Player -> Optimization and included the shader under Preloaded Assets. The build was much faster and the shader was loaded correctly in my application.

    At this point, my build error is solved but I can't help wondering if it is correct to do so. I am not seeing anyone mentioning about this method and there is not official documentation recommending including shaders under Preloaded Assets.

    Could anybody help me out by explaining (hopefully) what these 2 methods actually do to my build, and what is considered the best practice to include the shaders?

    I am using Unity 2020.3
     
    KyryloKuzyk likes this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    Because this looks to be more a Graphics issue than an AR one, I'm going to move this thread to our Graphics Forums.