KhronosGroup / UnityGLTF

Runtime glTF 2.0 Loader for Unity3D
MIT License
1.82k stars 490 forks source link

Shaders do not compile in Unity 2022.3.5f1 #771

Open GregKabza opened 2 months ago

GregKabza commented 2 months ago

I'm using UnityGLTF 2.13.0 and when I try to compile PBRGraph it ends with errors:

UnityGLTF/PBRGraph has too many Shader variants (2359296). To resolve this, go to Project Settings > Graphics and remove this Shader from the Always Included Shaders list. For more explicit control over how Unity includes specific Shader variants in a build, use a ShaderVariantCollection.

UnityGLTF/PBRGraph has too many Shader variants (1916928). To resolve this, go to Project Settings > Graphics and remove this Shader from the Always Included Shaders list. For more explicit control over how Unity includes specific Shader variants in a build, use a ShaderVariantCollection.

And a warning:

Shader warning in 'UnityGLTF/PBRGraph': pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them at Editors/2022.3.5f1/Editor/Data/CGIncludes/UnityCG.cginc(513) (on d3d11)

Compiling Subshader: 0, Pass: BuiltIn Forward, Fragment program with DIRECTIONAL FOG_EXP2 LIGHTPROBE_SH SHADOWS_SCREEN _ADDITIONAL_LIGHTS_VERTEX _VERTEX_COLORS_ON _VOLUME_TRANSMISSION_OFF Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_FORWARDBASE UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS Disabled keywords: DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON FOG_EXP FOG_LINEAR INSTANCING_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS _ADDITIONAL_OFF _BUILTIN_ALPHAPREMULTIPLY_ON _BUILTIN_ALPHATEST_ON _BUILTIN_AlphaClip _BUILTIN_SURFACE_TYPE_TRANSPARENT _CLEARCOAT_ON _IRIDESCENCE_ON _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT _SPECULAR_ON _TEXTURE_TRANSFORM_ON _VOLUME_TRANSMISSION_ANDDISPERSION _VOLUME_TRANSMISSION_ON

hybridherbst commented 1 month ago

Thanks. Unity seems to have changed how shader variants work (again!) in 2022.3 and we'll need to look at how we can work around that.

pfcDorn commented 2 weeks ago

Hey, these issues should now be fixed. We also added predefined ShaderVariantCollections to make it easy to use UnityGLTF at runtime, can you please try it with them?

One for Built-In RP and one for URP/HDRP: image