A little optimization around shadows.
Update #24: Performance can be poor when using shadows. Some optimization for simple
cases.