Unlit shader + light probe and point lights

I am trying to come up with the surface shader that is totally unlit by light. In other words it should not get affected by light at all.

I do however use light probe to add light to my model, and I do this by calling ShadeSH9 function directly within my shader code.

All works fairly well, until I decided to experiment with adding lights to the scene to see if the shader works as I have intended to.

Results is that everything is fine until I add my fifth point light to the scene. Shader was not getting affected by previous 4 point lights but after adding one more, suddenlt boom… it gets lit by the light.

I have investigated this further and found that result of ShadeSH9 function was containing value that is already affected by the point lights.

This is out of my control and I wish to know if there is way to get around this issue.

I did some reading on forward path rendering of unity and it does sort of mention 4 lights as point where rendering takes in different way (ie going to SH etc) but it does help me little to figure out how to get around this issue.

My shader is calling all sort of pragma to optimise for the exact purpose as below :

#pragma surface surf WrapLambert nolightmap nodirlightmap noforwardadd novertexlights noambient approxview halfasview vertex:separateSH

as you can see I am calling novertexlights and noambient which is what I “thought” supposed to prevent lighting from SH (light probe and such) to be automatically added to the shader code. And I think this does work to a certain extend. (ie up to 4 lights)

appreciate any help.

Thanks!

What is happening is that the lights after 5 are being put into SH. To work around this either bake the lights (will be included in the probes), mark them as important (always per pixel, and you have no forwared-add pass), or increase the number of allowed pixel lights to a number greater then you will ever have.