- Home /
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?
And to extend your question - what if I want to have more than 1 game object with lights, set as children, that only affect its parent? And so that even lights on same type objects do not affect each other? Any ideas anyone? $$anonymous$$uch appreciated.
Answer by RandomThought · Jan 08, 2016 at 05:08 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613182815im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
culling mask on camera ignores layer on lights? 1 Answer
What's the best way to animate a transparent image descending over a circular image? 0 Answers
How to compute camera culling mask via script to show two layers 1 Answer
Changing Camera Culling Mask in Script *Javascript* 0 Answers
How to create mask channels (RGBA) textures for 2D rim lighting in URP? 0 Answers