# Performance issue with SpotLights.setEnabled and material.maxSimultaneousLights

**URL:** <https://forum.babylonjs.com/t/performance-issue-with-spotlights-setenabled-and-material-maxsimultaneouslights/47473>\
**Category:** Questions\
**Tags:** performance, spotlight\
**Created:** [January 23, 2024, 8:12pm UTC](https://forum.babylonjs.com/t/performance-issue-with-spotlights-setenabled-and-material-maxsimultaneouslights/47473 "2024-01-23T20:12:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [January 24, 2024, 11:11am UTC](https://forum.babylonjs.com/t/performance-issue-with-spotlights-setenabled-and-material-maxsimultaneouslights/47473/3 "2024-01-24T11:11:57Z")

</div>

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

- [Light material limit - #8 by Evgeni\_Popov](https://forum.babylonjs.com/t/light-material-limit/17391/8)
- [Limit to number of spotlights](https://forum.babylonjs.com/t/limit-to-number-of-spotlights/47170)

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:

> **[Babylon.js Playground](https://playground.babylonjs.com/#20OAV9%2312983)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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)`.

---

_[View the full topic](https://forum.babylonjs.com/t/performance-issue-with-spotlights-setenabled-and-material-maxsimultaneouslights/47473)._
