tested and slightly improved shadow casting algorithm