I’ve been searching for this for a while but haven’t been able to find a definitive answer:
Is it possible to add a custom base materials (such as Lit, Unlit, or any other of the selectables) for use with shadergraph in HLSL/CG/ShaderLab, prefentiably inside a existing Render Pipeline?
At work we’ve been using HLSL shaders with fairly minimal BRDFs and some custom effects for our project, but in order to allow Technical and VFX artists (some of which may not be familiar with HLSL) in our team to extends those shaders, I would love to make them into options for shader graph so that they can be extended nodally. Is this possible? And is this possible without defining a whole new SRP?
It’s my understanding that this is all SRP territory. I would suggest just making a custom HLSL file with all the inputs/outputs you want as a sort of “baseline” that artists could pass their values into and plug all the outputs into the URP base shader’s ports.
For URP with ShaderGraph if you are doing ALL your lighting in a custom way, you can just use an Unlit shader and output your color, so a simple intermediate SubGraph with your inputs that calls a CustomFunction (that accepts .hlsl files) will work.
If you need access to the URP lighting libraries and kind of inherit all their base lighting Keywords & variables, you can use a Lit ShaderGraph and still use your custom lighting subgraph. The important thing here is that you hardcode 0 (rgb(0,0,0) baseColor, float3(0,0,0) normals, etc) (it is important that is hardcoded, not a variable) into the ShaderGraph outputs, and only output your final calculated color (from your lighting model) through the Emissive channel.
This is because internally in URP, the emissive is just added through a simple sum to the final lighting calculation. If all your inputs for the URP lighting are hardcoded to 0, the compiler will strip out everything from the default unity URP code, and just leave your emissive at the end. So in the end, all that remains is whatever you pass to emissive.