I’m having to face a tough reality: My current approach to lighting is killing performance, and making my game nearly unplayable on lower end hardware. So I’m revisiting my lighting solution, and I’m looking for suggestions on approaches I might take.
My current approach is probably almost as bad as it gets for performance: I’m using HDRP, Realtime GI, all lights are Realtime (not mixed), and all lights are shadow casters. The aesthetic of my game is realistic sci-fi, so I wanted the lighting to be accurate. Here’s an example of a fairly simple room in my game, which has two lights (spotlights) on the ceiling, illuminating the room:
Most rooms get more complex than this, and it gets more difficult in rooms with hallways and passages, as I need more light to keep things visible. The worse rooms end up with 10-12 of these lights in them. On a good GPU it’s not an issue, but on lower end hardware this lighting is taking the game from 45-60 FPS down to 12-15 FPS. Something has to change. I realize HDRP is not intended for 10-year-old hardware, but right now I’m just doing the lighting badly, and I know the performance can be better. Here are some ideas I have, but I’d love to know what other people are doing.
A single, directional shadow casters
A common approach I’ve seen is to bake all lighting except for a single directional light. The directional light only casts shadows on dynamic objects, and is generally oriented straight down. This isn’t very realistic, but as long as there aren’t a lot of other shadow casters in the scene, the lack of realistic lighting isn’t so noticeable. I’m not actually sure how to get this in Unity. In a scene with Baked lighting, if I add a directional light and set it to Realtime, it still illuminates static geometry. So maybe there’s a trick to just getting shadows without illuminated anything else.
Enabled/Disable lights based on proximity
Here I’d go with a baked light approach, but then choose one (or maybe two) shadow casting lights to be active at any given time. Other lights would have their realtime shadows disabled unless they’re closest to the camera.
I’m not sure what else to try. It’s not just the shadows, it’s the presence of realtime lights in the scene. Each one adds a pretty serious performance hit. But many of my scenes have a lot of moving objects, and I worry that a big element of realism will be lost if I remove this. I’ve considered approaches where I can support multiple lighting approaches depending on graphics settings. But I’m not sure if I can dynamically switch like that. For example, maybe on “High” settings, I would just use Realtime GI, and on low settings I’ve use Baked lightmaps and a single shadow caster. That would mean having both kinds of light maps and light data, and having to bake both. But maybe that’s the best approach?
Any guidance would be welcome.