Optimizing Scene Lighting: Balancing Performance vs Visuals

Hi!

I’m currently experimenting with different lighting setups to optimize the visuals while keeping the performance in check. It’s proving to be quite a challenge, especially with the indoor levels. I was wondering if there are any best practices or tricks I might have overlooked.

So far, I’ve tried out several options. I started with a basic lighting setup using just a few Directional Lights. This gives the best framerate, 60fps+, but it’s not the most visually appealing, especially for the indoor levels.

Next, I experimented with Clustered lighting, where I used a bunch of Omni lights that affect dynamic and cast shadows (once). Unfortunately, this led to a significant performance drop, with frame rates as low as 20fps, even lower when shadows were enabled.

And lastly using lightmapping with baked Omni lights. This yielded decent FPS of 40+, but it came with its challenges.
Batch groups don’t work with lightmapping, which is unfortunate.
Additionally, it required a lot of work to achieve a good look and had issues with artifacting.
Baking also significantly increased scene loading time.
And as we load levels additively, runtime lightmapper baking was required, which also added loading.

I’d really appreciate any advice or tips on optimizing lighting for better performance without sacrificing visual quality.

Thanks in advance!

Hi @Nickneem,

Omni lights are quite expensive when they cast shadows, they need to render 6 unique shadowmaps per light. Usually most devs use real time shadows for directional/spot lights only.

An optimization you can do if your gameplay allows it and your scene is mostly static, is to render the shadows only when the lights/player come into view. There is an option in the light component to render shadows only once. You can toggle that in code when the lights/objects come into view. That will save up performance.

Regarding dynamic lightmaps, yes they don’t support batching.

1 Like

Right, that makes sense.
Biggest ‘issue’ right now is to get indoor maps to look good. Even with no shadows the Omni lights are impacting performance too much.

Our environments are almost completely static, with separate lighting for the environment and players.

Outside of Lightmapping, there is no such thing as casting a light just once for static environments right?

Yes, you can set the runtime lights to render shadows just once:

Another suggestion is to use a SSAO post effect, although that is not cheap either so it depends how it performs on your scene:

https://playcanvas.github.io/#/graphics/post-effects

Ah I meant just the lighting, not the shadows.

Yeah if we could get cheap SSAO that would be amazing.
Visually really nice on our high end systems, but unfortunately not acceptable on the low end devices.

1 Like

About the lighting running it only once, I don’t think you can anything else other lightmaps. The objects to render require lighting.

Although I’m thinking if your lights don’t cast shadows per frame, they shouldn’t be that expensive even on lower end devices.

1 Like