Custom lighting in shader graphs no way that the shader contribute to GI?

I’m trying to create a pipeline in shader graph that allows me to do custom lighting. I’m using unlit shaders generated by the template.

I noticed that the shaders are not sampling or contributing to GI.

In the picture at the right, I’m using lit shader, at the left my custom light shader

I resolved the sampling using the bool keyboard PROBE_VOLUMES_L1 hack, but I have no way to make shader contribute to GI generation (adaptive volumes / lightmaps).

Research has point me, that this is because unlit shaders are not generating code for the META pass, any hack or approach to solve this?

Is there any plan to allow at least be able to add shader code for the special passes for unlit shaders ? (that way we could check for definitions in custom functions)

This is probably the same problem as in the DepthNormalsPass, where normals are not outputted on Unlit targets. You probably need to use a Lit shader, doing the “hardcode 0 in everything except emission” trick. But having a “PassFilter” node that will let you output through color, emission, normal outputs, or whatever is needed ONLY in the required passes (Like Meta and DepthNormals)

I think Unity should consider writing this passes whenever the new “KeepLightingVariants” option is checked on the Unlit Master Node if they really want to support custom lighting on ShaderGraph. Its not propper support, but at least will let us have “something” to work with in the meantime

Thanks!

At the end I changed to use LIT Shaders, for this

  • As you mention, all goes through the emissive channel, all other stuff, except ambient occlusion, set to 0
  • Added the _SPECULARHIGHLIGHTS_OFF to be able to get pitch black
  • For Meta pass, I pass the base color and separate the emissive illumination with a costume function

Where

  • Base Color: Is my base/albedo color
  • Emission: My emission lighting
  • Lit: The lit surface (all lights, ambient, lightmaps, shadows, reflections, etc)
#if (SHADERPASS == SHADERPASS_META)
	OutBaseColor = BaseColor;
	OutEmission = Emission;
#else
	OutBaseColor = float3(0,0,0);
	OutEmission = Lit + Emission;
#endif

The Outxxxx are then connected to the shader graph Fragments Nodes Base Color and Emission

1 Like