I am currently working on a Toon Shader (already a pain to deal with due to the need for custom lighting) and we need baked GI to match the intended look of our project. However, both options to custom lighting (Unlit Graph with a truckload of Keywords, or Lit Graph with black albedo and color plugged into emission) provide no solutions to dealing with GI. Heck, the Unlit option doesn’t even generate a Meta Pass.
I remember reading a year or two ago about using Meta Pass-only defines to compile a different albedo value depending on the pass - this was back in the LWRP days so the Keyword in question was something along the lines of LIGHTWEIGHT_META_INCLUDED. However, I’ve looked for and tried several alternatives within the current implementations (I am on Unity 2020.3 with SG 10.3.2) to no avail.
Does anyone know any workaround (other than doing everything in plain code and being at the mercy of utterly undocumented APIs)?
This is still the case, URP shaders all have an “Meta” pass used for GI/Baking. The Unlit shader has one as well, so I’m surprised to hear Shader Graph doesn’t generate one. The only way around this would be to hand-write the shader, but it’s complexity will explode.
You may have better luck using Amplify Shader Editor, since their templates generally allow you to choose which passes get generated.
I guess Unlit graphs default to some hidden pass, since I don’t think I saw any in the generated code.
Thankfully I dug through the shader files and it seems that checking for UNIVERSAL_META_PASS_INCLUDED does the trick and allows you to sneak in custom Meta Pass logic, at least when building a Lit graph. The downside is zeroing Albedo/Smoothness/etc still leaves a not-quite-black surface, so I am afraid the generated code probably still runs the default light loop on top of any custom lighting… Guess I’ll just swap the shaders before and after baking.
And yes, been looking into ASE! We are currently probably too far in production to easily make the swap, but I will almost definitely opt for it in future projects. Relying on Shader Graph has only brought me pain so far.
If the output is not entirely black, it may be that a fresnel effect is being applied. Shader Graph’s can only emulate the Lit shader lighting model, rather than the Simple Lit shader. The latter does not incorporate the fresnel effect.
If it doesn’t clash too much with the art direction, in the Lighting settings window you can set the “Environment Reflections” source to “Custom”, and leave the field blank. The fresnel effect is based on reflection probes (including the hidden skybox probe). So if there aren’t any, the effect amounts to a black color, so won’t add anything to the final output.