Hi,
I’ve googled around and I know roughly what goes on with bundled materials that use custom shaders, but I still have issues with then rendering properly once unbundled.
I understand that shaders are not included inside asset bundles…but I’m still confused as to how they actual hook up once they are unbundled, I’m under the impression they just reference the shader in the project but I’m getting some odd behaviour.
For example,
I have an object with a custom shader, called CustomShader for example and this is bundled into an AssetBundle. I have this shader also in my Resources/Shaders folder to ensure it gets built/compiled. When I unbundle an object the object (this is on iOS), I can see that the material does indeed have “CustomShader” as its shader…but its not displaying correctly.
If I then go to “Edit” the current shader, it only gives me an option to “Open compiled shader”. If however I pick “CustomShader” from the drop down list, it then displays correctly and when I click “Edit” it open up in Visual Studio as expected.
So…whats going on here? Why does it display differently when I select the same shader from the drop down box? I was under the impression if I included the shaders in Resources, then the bundle will reference these. This doesn’t appear to be the case, especially as it only lets me edit the compiled shader. Also my shaders usually display the “Shader might be expensive on this platform” warning, but not on the ones in the bundle. Again if I select the same shader from the drop down, it then displays correctly and I again get the expensive shader warning.
Is there anything else I can do to ensure the bundled materials display correctly? I tried creating a game object in the scene with all the material attached to it to see if that forced it to work, but again no luck.
What I can resort to is, after unbundling the asset, going through ALL renderers->materials and doing a “Get shader name” and then setting it to be the same shader (basically, doing the equivalent of selecting the same shader from the drop down box).
Again, this only appears to happen in iOS mode, windows mode (and windows bundles) seem to work ok.
Hope that made some sense to someone.
EDIT: When I say it renders wrong, it looks like it might just be going to the Diffuse fallback shader in the compiled version (referenced by the AssetBundle), but when selecting it from the drop down menu it runs fine.