At long last I'm done with the lighting engine for my indie game, Non-Essential Personnel. For now, anyway.
I've finally crossed that glorious rendering threshold where screenshots of my game compress better as JPG images than PNG images! =D
What can the lighting system do?
NEP's lighting system has a lot of nifty prettiness-inducing features. Here's a quick overview.
Thousands of simultaneous sources! Each sky block is actually a light source.
(Don't worry, that stone texture isn't final.)
Shiny! How does it work?
Lighting systems are tricky. People are really good at looking at things. I mean really good. If something doesn't look right, you usually notice pretty quickly. Take a look at these two light sources.
The one on the left looks pretty good, but the one on the right looks weird. It's hard to say why it's wrong though. It looks too bright somehow. Turns out, I changed the shape of the falloff function for light intensity. Physically, light intensity falls off exponentially from the source and anything else just doesn't look right. Lighting systems are full of little details like this, and if you don't get them just right, things just look weird.
On top of just looking good, the game has to run without any hiccups or pauses, so the lighting system needs to run in real-time. Voxel games in particular are extra tricky, because any block could be a light source. That means one scene in the game could have thousands of light sources in it. Designing a lighting system that runs at 60+ fps with potentially thousands of light sources is definitely challenging.
Lighting systems are hard, and I don't claim to be an expert at this, but here's one way I got something that looks pretty good. If you want to get into the nitty gritty details of my lighting system and how it works, read on. =)