Optimization for light calculations