Does a large number of layers affect performance?

Hi! i need to use layerculldistances for better performance so i need to create some extra layers. Right now there are not many models in the scene but when i add more into their respective layers then will it cause any frame rate drop due to objects being rendered in lot of different layers?

Thanks for reading!

2 Answers

2

@NOAA_Julien - Your link doesn’t work.

I personally don’t think they do. I’ve been working with games that have over 100 layers, and nothing is affected, its merely a way to reference things, so I don’t see how it would effect performance.

Hope that helps

Oliver - the duplicate must have been deleted. Removing that comment. I agree that they probably have no affect. All the code that uses layers does the check for layers regardless of whether you have 1 or 100, so there's no extra overhead for it to check and see that layer=1 vs layer=16.

For posterity, the above answer may be referring to tags? The maximum number of layers is 32, and they most definitely have performance implications. For each layer in the matrix of layers, Unity must evaluate collisions based on every other layer. Here is an excellent blog post that goes into detail about the cost of layers: 1

then it's better to add more layers and change the collision mask for the layer, since lots of colliders can be triggers for specific objects.