0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.