Dynamic Lighting and Fog of War

Dynamic Lighting and Fog of War

Clint Bellanger's picture

I'm creating this thread to get a discussion going about Dynamic Lighting and Fog of War.

By simply darkening areas the player can't see, games add a ton of atmosphere.  Players quickly get a "survival horror" feel when they can't see what's around the corner.

Some notes:

  • It isn't strictly necessary for games of this genre -- e.g. Torchlight doesn't really do this.
  • It's resource-intensive and tricky to make pretty.
  • Fancier implementations could require additional data for every tile in the game (e.g. 2.5d geometry shadow calculations).
  • Flare uses simple 2D blitting and not OpenGL.  This won't change for Flare 1.0.
  • When done well, it's sexy!

Because it's not strictly necessary, it's low on my priority list.  Reminder: I'm talking about Alpha on a 1.0 version of an engine.  This would be pre-alpha tool creation on a regular video game timeline.

Now.  Flare sticks to the tile system pretty closely, so a simple per-tile lighting algorithm (as seen in Diablo 1) would probably work okay.  The basic algorithms are easy to understand.  What I lack in plain SDL is a blit function that draws a sprite with lower luminance.  I could pre-render those at lower light levels and keep them in memory instead, at the cost of long map load times and more memory usage.

Anyway, I haven't given this much thought because it isn't a high priority for me right now.  But feel free to discuss ideas, post links to existing algorithms, etc.