Closed andybak closed 1 month ago
Hey, which version if Unity are you using? There have been bugs in some 2021 + 2022 versions on Unity's side regarding shader variant stripping from Shader Graph, which resulted in far too many variants.
I tried 2021.3.30f1 and the 2022 LTS (2022.3.27f1)
The ShaderVariant thing seemed to work. I've no idea if the list it came up with is sufficient and I don't have time to test against a ton of sample GLTFs at the moment
UnityGLTF currently supports way more material features than glTFast, so we end up with more shader variants at runtime.
We will likely have to either reduce the number of keywords (at some runtime performance cost for dynamic switching), or provide some means to choose which shader features are expected to work at runtime, or both.
Hey, we now have two predefined ShaderVariantCollection with the latest update One is for BuildIn RP, the other for URP and HDRP.
Also you can find in the Gltf Settings new Shader Pass Stripping options to reduce it even more:
I will close this, when you have still issues with the shaders, please create a new issue. thanks :)
I'm hitting a problem with UnityGLTF that seems to be perfectly solved by this PR: https://github.com/KhronosGroup/UnityGLTF/pull/120
Except that code was removed ages ago - so I presume there's a better approach now.
The problem:
In a build UnityGLTF throws an exception on import because it says it's shaders are missing. So the obvious solution is to add them to Unity's "Always Include" list.
Except that gives this error when building for Android.
No idea if desktop builds work as they never seem to finish!
I don't really understand how I'm meant to use ShaderVariantCollection - how do I know what set of variants are needed? I'm aiming to support any GLTF that the user supplies.
For comparison GLTFast seems to handle this fine - it adds itself to the "Always Include" list and doesn't seem to generate a huge number of variants.
I've reproduced this in a minimal project that simply loads a single GLTF at runtime from the Streaming Assets folder.
My current plan is to add every model from https://github.com/KhronosGroup/glTF-Sample-Assets to the project and use this to generate a ShaderVariantCollection - but that seems a bizarre direction to be forced into.
I suspect I'm doing something stupid or unusual but I genuinely have no idea what it might be.