Theories about lighting a dungeon

jwatte's picture

So, I'm generating a dungeon-like structure procedurally (in Rogue-like tradition).

Initially, I just lit it using a "sunlight" type directional light. However, that looks approximately like ass. Mainly because that's not how dungeons are actually lit, I guess :-)

I probably want to place hundreds of point lights along the walls, in the form of torches. However, I can't really do that with real-time lighting, because that would require either significant shadow mapping overhead (which I don't want to pay), or some nasty run-time cell/portal division to figure out which lights are allowed to hit which walls/floors/ceilings. I rather like it that I have a single vertex buffer and a single draw call per material to draw the entire dungeon -- it reduces batching overhead significantly.

So the next thought is to go to trusty old light mapping, which lets me do the lighting calculation/shadowing once, offline. Unfortunately, these are procedurally generated maps, so I'd have to have a GPU accelerated light map generator that runs while the user is waiting. This rules out things like using Giles or Max to light map, and rules out slower, nicer-looking effects like per-pixel ambient occlusion and radiosity inter-reflection.

My next thought down the ladder (I'm working my way towards the ghetto here!) is to map a "darkening corners" texture across the walls and floors, with texture coodinates based on close to the corner you are. This is almost like vertex coloring, but can be done per-pixel because it's a texture, so I don't need to tesselate the walls or floors. (I may want to do that later anyway, to get rid of the too-regular look, but that's a later issue). The idea is to have a texture that's white in the middle and has darkness along the edges. Then drape it across each wall/ceiling/floor surface to get some ambient occlusion darkness in the corners. Corners that bend "inward" (such as the right-hand opening in the right hand wall in the screen shot) should not be mapped with darkness, because there is nothing there to occlude them. However, that would probably be fairly easy to calculate.

For specular reflections, I'd probably still need the "sun-like" light. Perhaps pull it down a bit, so it's more like as if there was some invisible torch behind and to the right of the camera, perhaps?

Or maybe I should like the dungeon like a flashlight/torch you carry? A single spotlight with shadow mapping might work out pretty well, and would certainly lend ambience to the place.

Please comment with your ideas! The goals are simple:

  • Easy to implement for load-time procedurally generated content.
  • Looks better than the current "sunlight" lighting.

There will be a player (third person) in this screen at some point, too, so any flashlight/torch may need to come "from the shoulder of the cameraman" to work out okay, but I think that can be managed. The more I think about that option, the more I like it, because it would be easy to play with distant glowing eyes of monsters and stuff. Maybe a bit like a Horror/Roguelike slasher experience?

bad-lighting-dungeon.jpg100.44 KB