Performance issue with SpotLights.setEnabled and material.maxSimultaneousLights

You can’t have too many lights affecting a mesh, there are GPU resources involved with each light (one uniform buffer per light), and these resources are quite limited. You should search for maxSimultaneousLights in the forum. For example

Note that you can set engine.disableUniformBuffers = true to avoid using ubo for lights, and you’ll be able to use more lights simultaneously. However, this will also disable ubo for materials, which may result in a slight drop in performance.

Your PG without ubo support:

Note that I’ve disabled projection texture, as you run up against another GPU limitation which is the total number of texture units a fragment shader can use. This is around 16 (depending on your GPU), so if you have too many spots, you’ll get an error like Error: FRAGMENT shader texture image units count exceeds MAX_TEXTURE_IMAGE_UNITS(16).

2 Likes