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?

AttachmentSize
bad-lighting-dungeon.jpg100.44 KB

Comments

some ideas

idea 1 - why not go deferred - keep point lights local
idea 2 - use cubemaps - when filterred correctly you can use them as fake specular and it can look a lot richer than a single light source; you render just the light sources in the cubemap; results may vary :)
idea 3 - depending on your complexity maybe you have a simpler problem and can precompute a lot (not all) information; looking from the screenshot above it looks like a precomputed 2D map of light influence can get you a long way; sort of texture of you dungeon (top down) that tells you were the lights have influence including precomputed shadows; not sure I'm explaining it correctly - it's like lightmap of the whole dungeon... topdown view... showing influence of your point lights in 2D... so you get shadow information form that for free. Then when you actually rende and have the actual position of the light you can use that information to shadow the light and the 3rd dimention will come from the light attenuation algo you use. would work a treat with deferred I imagine. will not work great for small objects
idea 4: cascaded light volumes - crytek guys had a paper on this recently but theirs is a lot more invovled

also seems like a good candidate for SSAO to me :)

-y

jwatte's picture

Yes, I've been considering

Yes, I've been considering those. I've also thought about dusting off my GPU enabled light map renderer, and just generate the maps at runtime -- however, come to think of it, as you say, because it's 2D, I can probably do something smart with flat mappings and an analog of stencil shadows... I'll have to think about that.