Shader value always null
See original GitHub issueWhen trying to export any model the exporter always gives an exception that Shader value cannot be null when creating a new material.
The error lies in GLTFSceneExporter.cs line 90
line 90: var metalGlossChannelSwapShader = Resources.Load("MetalGlossChannelSwap", typeof(Shader)) as Shader;
line 91: _metalGlossChannelSwapMaterial = new Material(metalGlossChannelSwapShader);
line 92: var normalChannelShader = Resources.Load("NormalChannel", typeof(Shader)) as Shader;
line 93: _normalChannelMaterial = new Material(normalChannelShader);
This is on the latest release. Any idea on how I can make it work?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How can I use If or is NULL statement in Shader Graph? ...
There is no such thing as a null in a shader. Well, there is, but it just crashes the GPU if it exists....
Read more >unity Shader returns a NULL when using Shader.Find
First, go to unity editor: Edit->Project Settings-> Graphics Then in the inspector where it says "Always Included Shaders" add ...
Read more >I have unity telling me the code isn't working because I can' ...
That tells you Shader.Find("Hidden/BWDiffuse") is returning a null value. The best way to handle this is probably to add a Shader variable ......
Read more >What is a 0 "null" normal map? Or Unlit shader
1 Answer. In the most common normal map encoding, an RGB value of (0.5,0.5,1) would be uniformly flat. If the shader is meant...
Read more >Null Reference Exceptions
A NullReferenceException happens when you try to access a reference variable that isn't referencing any object. If a reference variable isn't referencing an ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For me the root problem was that I used https://github.com/KhronosGroup/UnityGLTF/releases/download/v1.0.1/UnityGLTF.unitypackage to add GLTF capability to a new, existing project. It turns out that this is not enough. The gltf export also needs a copy of the Resources folder from the repo or source.zip (https://github.com/KhronosGroup/UnityGLTF/archive/v1.0.1.zip) to be available in the project’s Assets folder. Without it line 90 in GLTFSceneExporter.cs does not find the “MetalGlossChannelSwap” shader resource and Resources.Load returns null (should there be guard ?). So just copying that Resources folder into the project’s Assets folder should fix this issue.
Ultimately, that is a packaging issue since neither UnityGLTF.unitypackage nor the upm package at https://github.com/KhronosGroup/UnityGLTF/releases/download/v1.0.1/org.khronos.UnityGLTF.zip currently contain the Resources folder although they probably should. In other words, it might work to move the Resources folder into the Assets/UnityGLTF folder, in the repo ?
I moved the Resources folder into Assets/UnityGLTF folder in this branch: https://github.com/andreasplesch/UnityGLTF/tree/linux-build The built unity package: UnityGLTF.unitypackage.zip works now also for exporting gltf after being imported into a project.