I just created this PR Clustered lighting does not use lights with intensity of zero by mvaligursky · Pull Request #3271 · playcanvas/engine · GitHub
Which ignores lights by clustered lighting that have intensity of 0. So that would avoid having to disable the lights which has a cost. At the moment, till the clustered lights are fully implemented (with shadows …), the existing lighting solution is still the driving one and at the moment it rebuilds the shaders if the number of lights change, even though the shader does not use those lights at all. All this code will change when clustered lights are the fully supported lights.
What the clustered lighting does: it gets a list of lights it needs to use per frame (they need to be visible, intensity > 0), creates a bounding box around those, and subdivides that box into a number of cells as you specified. So another way to keep this fast is to keep only the lights around the camera with intensity >0 (for example don’t have one light on another island), as that would stretch the bounds a lot and you’d likely need higher cell subdivision.
And when you have that, use small number of cells, as updating those is costly. Perhaps you could do with 10x3x10 cells or similar.
You can keep an eye on the performance of clusters update by looking at
app.stats.frame.lightClustersTime
app.stats.frame.lightClusters
see here on how to use it with mini-stats engine/clustered-lighting.tsx at master · playcanvas/engine · GitHub
(needs debug or profile build of the engine)
to see how long it takes to update them. And also how many clusters you have … ideally it should be just one … that would need all lights to have the same layer settings.