X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fshadowmap.cpp;h=91c056fe147cc4c994100b5a1aa1e2ec8534c730;hb=fa5b232a16e11d7950e80764497f0167ec9e3b41;hp=c4dd07b03dbdb288fa55bda158dc305386813d70;hpb=db735acce6c9409fabcab80d87930263032af47c;p=libs%2Fgl.git diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index c4dd07b0..91c056fe 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -80,15 +80,10 @@ void ShadowMap::setup_frame() const { /* XXX Not really proper way to support positional lights, but good enough when the light source is far away */ - lpos.x -= target.x; - lpos.y -= target.y; - lpos.z -= target.z; + lpos -= Vector4(target.x, target.y, target.z, 1.0f); } - float l = sqrt(lpos.x*lpos.x+lpos.y*lpos.y+lpos.z*lpos.z); - lpos.x /= l; - lpos.y /= l; - lpos.z /= l; + lpos.normalize(); float matrix[16]; if(abs(lpos.z)>=abs(lpos.x) && abs(lpos.z)>=abs(lpos.y)) @@ -149,7 +144,7 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const if(!enabled_passes.count(tag)) return renderer.render(renderable, tag); - const double *matrix = light_matrix.data(); + const float *matrix = light_matrix.data(); // Has side effect of changing the current unit depth_buf.bind_to(unit);