Implemented square-based lighting algorithm