A light post
Lighting is at a pretty good place right now. It hasn't gone through a bunch of optimization, but it’s pretty fast. It works sort of like flow. Say we have a situation like this with a light inside a little tunnel:
The flow starts at the position of the light (of course).
The light flows through cubes that are light transparent and touches the faces of cubes that are not, and sets their color along the way.
The “flow” distance is limited by the falloff of the light. For each face the “flow” touches, I calculate the distance and the intensity, the dot product of the light vector and the normal of the face. This means that if light isn't “pointed toward” the face, it doesn't get lit. This alone works OK, but doesn't take into account solid objects, like walls.
If shadows are enabled, then before we set a face light, we check to make sure it has line-of-sight with the source. This is a bit more processing intensive. However, what’s cool is we only have to do it once! We only have to compute it again if a cube in range of the light is added or removed. Otherwise the light is “baked” into the texture of the cube. Plus I already had solid picking code, and can use it here too.
This is actually really fast, considering. The lighting is done without noticeable delay. Check out the screenshots of it in game on the gallery page. The shadows produced are a bit chunky, since it’s a per face lighting, not even per vertex or per pixel. But it’s fast and it works for me!
Perhaps later I’ll do something nifty like Minecraft and have smooth lighting.
Also, who doesn’t love SketchUp?