I’m trying to add GTLFast to my basic Unity PolySpatial project.
GLTFast provides URP Shader Graph shaders. I’ve integrated GLTFast using unity package manager. I added a new node to my scene, added the Gltf Asset
MonoBehaviour and set the Url to https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/2CylinderEngine/glTF-Binary/2CylinderEngine.glb
. I also set the scale of the GameObject to 0.001 so that the model displayed at a reasonable scale.
This works just fine in play mode, rendering correctly.
I then went to Project Settings
→ Graphics
and then under Currently tracked:
clicked Save to asset...
. I then added that asset to the list of preloaded shaders.
When I build for VisionOS and run in the simulator the model geometry shows, but is rendered in hot pink. There is logging in the Xcode console:
[Platform] [PolySpatialUnitySimulation] Could not load ShaderGraph material 'Shader Graphs/glTF-pbrMetallicRoughness' from file:///Users/Casey/Library/Developer/CoreSimulator/Devices/01679CEB-B0B6-4301-921F-CCF8963C6C4A/data/Containers/Data/Application/F482849A-EB69-46A3-BED8-1359A58516C1/tmp/F48EF0DC-E6FC-4343-AE6F-E56803F02734.usda: invalidTypeFound
I then went back to Unity’s Project Settings
→ Graphics
and added gtlf-pbrMetallicRoughness
to the list of Always Included Shaders
.
I then build for VisionOS and see this warning in Unity’s build log:
Shader warning in ‘Shader Graphs/glTF-pbrMetallicRoughness’: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them at /Applications/Unity/Hub/Editor/2022.3.6f1/Unity.app/Contents/CGIncludes/UnityCG.cginc(513) (on metal)
Compiling Subshader: 1, Pass: BuiltIn Forward, Fragment program with DIRECTIONAL SHADOWS_SCREEN STEREO_INSTANCING_ON _ADDITIONAL_LIGHTS _MAIN_LIGHT_SHADOWS_CASCADE _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT
Platform defines: UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_NO_DXT5nm 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_EXP2 FOG_LINEAR INSTANCING_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING LIGHTPROBE_SH SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING 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_VERTEX _ADDITIONAL_LIGHT_SHADOWS _ADDITIONAL_OFF _BUILTIN_ALPHAPREMULTIPLY_ON _BUILTIN_ALPHATEST_ON _BUILTIN_AlphaClip _BUILTIN_SURFACE_TYPE_TRANSPARENT _EMISSIVE _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_SCREEN _OCCLUSION _TEXTURE_TRANSFORM _TRANSMISSION
In the VisionPro simulator the results are the same as before: pink geometry with a log about unable to load the ShaderGraph material.
How do I go about debugging this problem? Is there a tool which will check whether the ShaderGraph shader is compatible with VisionOS?
I have saved copies of the .usda files mentioned by the logs if those can help for debugging.
–
Casey