Clustered Lighting Open Beta - Have hundreds of dynamic lights in your scene!

Hi everyone!

Lights are a great way to add realism to your application, but real time lights can come with significant runtime performance cost. This becomes more impactful with a large number of lights, many of which are casting shadows.

Part of the solution is to limit the amount of lights affecting individual meshes. This is often implemented by finding and using lights that are nearby to each object. This has multiple disadvantages:

  • As each object can use different sets of lights, a custom shader needs to be compiled to handle it.
  • Large objects might need to split into smaller objects for this to be effective.
  • Large number of shadow casting lights could cause the shader to run out of its available texture slots used by the shadow maps

PlayCanvas uses the clustered lighting solution to provide a performant implementation of omni and spot lights. This solves the problems listed above by storing information about the lights in textures and allows the GPU to easily use only the lights that are nearby to a fragment getting shaded.

We are in the process integrating the settings and features into the Editor for clustered lighting but in the meantime, @mvaligursky has created a PlayCanvas script that exposes the options and settings needed for this feature.

We will be looking to make clustered lighting the default system in the mid term (with option to revert back) as there is little to any disadvantage from what we have seen so far.

Over the longer term, our aim is to remove the current lighting system from the engine (reducing the file size) and only be using clustered lighting.

Project: https://playcanvas.com/project/915638

We also have some WIP documentation attached here: Clustered Lighting | Learn PlayCanvas

Please do give it a try! Some developers have already started using in projects such @Leonidas Pool Demo

We would love to hear feedback on the feature and documentation below :slight_smile:

12 Likes

If your application uses omni or spot lights, it would be greatly appreciated if you could give this a go … as the plan is for the clustered lighting to be the only lighting solution in the engine in the near future. This allows you to test it out and make sure there are no issues we could fix before the switch.

3 Likes

Great work everyone, clustered lighting is one of the major reasons I use PC (engine only) and its really good. Look forward to it being the only solution!

1 Like

Request from another user: Can we show performance cost in the editor profiler?

Question from another user: @mvaligursky Does toggling lights on/off still trigger a recompilation/processing? Toggling lights on/off with clustered lighting

If the way to ‘disable’ them is still by setting intensity to 0, we should add that to the docs

I think that was a temporary trick we did when clustered lights were first released, it’s not required anymore.

I gave it a try right now, you can freely enable/disable a light and that will not force a re-complication of the clustering system.

2 Likes

Agreed, the limitation is no longer there, even though enabling them is still a little more expensive than changing intensity (this is related to how lights are internally organized for shadow caster culling and similar) … but this will improve further as we fully transition to cluster lighting.

2 Likes

Awesome work on this @mvaligursky. Can’t tell you how much this has helped recently!

1 Like

Awesome to hear @Mark_Lundin - any issues you had using them?

none as yet but will keep you posted

1 Like