X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fshadowmap.cpp;h=9dadb8fe16ee4991eda732ceb0219373d8267bfe;hb=927a1aa0a3a27e463ec0efc08bd08e7c4e969909;hp=5f66d8984279ce55f9cfc98fcf2298d34fa31337;hpb=98c810b6d2256aa65986bbde12c38917678121bb;p=libs%2Fgl.git diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index 5f66d898..9dadb8fe 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -54,9 +54,19 @@ void ShadowMap::set_texture_unit(unsigned u) void ShadowMap::prepare() { - const Vector4 &lpos=light.get_position(); + Vector4 lpos=light.get_position(); if(lpos.w) - throw Exception("Non-directional lights not supported at the moment"); + { + /* 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; + float d=sqrt(lpos.x*lpos.x+lpos.y*lpos.y+lpos.z*lpos.z); + lpos.x/=d; + lpos.y/=d; + lpos.z/=d; + } float matrix[16]; if(abs(lpos.z)>=abs(lpos.x) && abs(lpos.z)>=abs(lpos.y))