Tiles, Lighting, and Stress-Testing

Hey Folks! Hope everyone had a good weekend. Not a lot to report from mine. Mostly a quiet one, which can often be just fine!

I continued pushing the limits of the ship editor today, finishing up the largest layout yet. It's the same 80x50 tile ship from last week, now with floor grates and lighting. As of the end of the day, the ship has (roughly):

Wall Tiles: 750
Floor Tiles: 500
Lights: 80

And we're definitely over our limit. Framerate is lucky to be ~30fps when zoomed into a room, and down near 15-20 when viewing the whole ship. I was able to find and fix a few bottlenecks and performance hogs in my scripting, but I think this new limit is rendering. Specifically, dynamic shadows.

80 lights casting shadows is a lot. Probably more than reasonable. I can see there being more lights on a ship in practice, but not all of them need to cast shadows.

Even so, I'm not sure there is much I can do to improve this number. I've tried reducing the light ranges, which helps a lot. But it also undermines the point of the lights: illuminating the rooms. Turning off shadows works, too, but then we have light spilling into unlit rooms and around corners. None of these things are terrible, they would just mean giving up nice lighting.

On the other hand, this is good info. Part of the reason I spent time building a large ship layout was to see what pitfalls I'd be facing. And now I have a better idea. I can also see how zooming and scrolling around the ship feels, which is currently tedious. (Though, made worse by low framerate.)

I'll have to give this some thought, and see what my options are. E.g. go back to larger tiles, no dynamic lighting, or some sort of clever lightmapping/culling/quadtree magic.


Malacodor's picture

Use electroluminescent foil for regular lighting. Each ceiling panel with such a foil would illuminate the tile beneath it, but would not cast any shadows. If we assume that the whole ceiling is covered with the foil you can simply use ambient lighting. Then only big screens, reactor parts or other technical doodads would cast shadows, and the number of those can be kept low easily.

There could also be emergency lighting which uses a small number of faint old-fashioned lamps, just enough to allow navigating through the ship and to create an eerie atmosphere. In case of a blackout people don't complain about bad lighting, they are happy to have light at all.

Or detect enclosed rooms and handle lighting for each room independently. Most walls wouldn't have to cast a shadow, only those at which light is shining from behind (corners, U-shaped rooms). As for doors, use airlocks with two doors each. This will both make the ship safer and avoid light shining through doors. It would also be cool if we could move entire rooms around in build mode and save/load them.

Ran around with a clown mask before it was cool

ra1's picture

What CPU/GPU are you using? Given a timeframe of ~2? years of development, will most target devices at that point be powerful enough to handle what you are doing?

dcfedor's picture

@Malacodor, I like the EL foil idea. I was trying to think of ways to keep lighting ambient and maybe just have a lit/unlit sprite for each, and this might be a way to explain it. I'll have to see how performance feels with a lower number of lights, and what my thresholds are like.

The room system may be necessary at some point too, whether for line of sight, lighting, environmental containment, or all of the above. It's a system that has yet to be built, though :)

@ra1, it's a fairly modern system. i5-4430 3GHz and a GeForce GTX 660. I'd like to make this playable on low, or at least medium power systems, so I think this code would still be too slow in 2 years.

Dan Fedor - Founder, Blue Bottle Games