I was wondering what is the best practice to modify some of Unity’s existing shaders snippets.
To be more precise, I’m currently looking at the Standard and Standard (Specular setup) shaders because I wish to change how their Opacity output is managed.
My goal is to build a ghost/spirit shader based on Unity 5 physically based shader, meaning I wish to make it so that the Z-buffer is read and only the first faces of the mesh is shown through the transparency. It’s nothing that strange and it has been done plenty of times with the legacy shaders.
It’s not only for my project, but also to learn more about Unity physically based shaders management so please, don’t post anything about some shaders from the store asset as it’s not the point of my question.
Okay. Now the thing is that I now understand how the default standard shader is working in Unity as I looked up the .shader and .cginc files. That much is clear and I’m able to work with it.
But the thing is that I would like to modify some of them for a project, but as .cginc files aren’t directly within the project files like the ones you can get for learning purpose, I’m not sure how I can replace the content of the shaders’ snippets within a project without risking some conflict between the hidden and modified snippets.
Does importing a .cginc file in the unity project with snippets automatically replace the existing default snippets or will I have to literally recreate the whole standard shader and its whole set of .cginc files with modified snippets references just for the sake of modifying a single part of the rendering process?
(That’s 1 shader + 9 .cginc files to recreate and modify with different snippets names. That’s would be a huge pain in the butt to be honest and I’m not even thinking about the risk of errors.)
Thanks in advance!
P.S. The reason why I’m trying to do it this way instead of just building the shader from scratch is because I would like to add this within the Rendering Modes of the Standard and Standard (Specular Setup) shaders. I think about adding a X-Ray (0 to 1) slider that makes overlapping parts from the same mesh invisible if behind another part of the same mesh. (So that it’s possible to make a material that is like the current fade or transparent, but using the same shader to make z-based fade and transparency.
If this is possible and I succeed, I’ll add the file as free asset on the Asset Store.