Light culling mask limit

Hello, I’m using the light culling mask filter on a light to only light the Player layer and I get this warning:

Too many layers used to exclude objects from lighting. Up to 4 layers can be used to exclude lights, while your lights use 31: etc…

The strange thing is it actually seems to work fine. Is there a reason this should be a problem? And if not, then why is Unity complaining about it?

The mask is a 32 bit field. As the warning says you can exclude a maximum of 4 layers. When you are only including one layer in the mask you are excluding the other 31.

This 4 exluded mask value also appears to be the sum total of masks used by all the lights in the scene
I’ve certainly had cases where it moaned but everything still worked OK, it’s just not guaranteed to. For example consider something like using 2 bits somewhere in the G buffer as a mask that allows up to 4 different sets of lights to be rendered… or something like that.

As for only effecting a parent with lights, if the masks don’t suffice you could do sometihng like add your only lighting equation to a custom shader, pass in the lighting info and deal with it as forward rendered… admittedly not an ideal solution & you’d certainly end up with a light limit per parent object. Such a solution is also unlikely to work properly with GI etc.