X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.cpp;h=bbf602bc60f2ed483215074c0727eba0e8ea2634;hb=7ab8bc0724f40b46d7f5da1bcb05ab6d0cecbb43;hp=ddb78aeb6ff5a3c07aa59cb07548604089b48e8d;hpb=bdcae47bf2f4e49d2d9e4ba15e6f17171ce5fa0c;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.cpp b/source/effects/shadowmap.cpp index ddb78aeb..bbf602bc 100644 --- a/source/effects/shadowmap.cpp +++ b/source/effects/shadowmap.cpp @@ -24,7 +24,7 @@ ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &c, const Lighting *l): fbo.attach(DEPTH_ATTACHMENT, depth_buf, 0); set_darkness(1.0f); - for(unsigned i=0; i<4; ++i) + for(unsigned i=0; i<6; ++i) { string base = format("shadows[%d]", i); shdata.uniform(base+".type", 0); @@ -196,7 +196,7 @@ void ShadowMap::setup_frame(Renderer &renderer) { float distance = (sqrt(2.0f/3.0f)-sqrt(3.0f/8.0f))*2.0f; float bias = depth_bias*2.0f/(distance*l.region.width); - shdata.uniform(base+".bias", -1001.0f/999.0f, 1.0f-bias); + shdata.uniform(base+".bias", views[l.view_index].camera.get_projection_matrix()(2, 2), 1.0f-bias); } } @@ -219,7 +219,7 @@ void ShadowMap::setup_frame(Renderer &renderer) v.camera.set_depth_clip(radius/1000.0f, radius); } - Matrix to_texcoord = Matrix().translate(Vector3(0.5f, 0.5f, 0.5f)).scale(0.5f); + Matrix to_texcoord = Matrix().translate(Vector3(0.5f, 0.5f, 0.0f)).scale(Vector3(0.5f, 0.5f, 1.0f)); shadow_matrices.push_back(to_texcoord*v.camera.get_projection_matrix()*v.camera.get_view_matrix()); } @@ -298,6 +298,8 @@ ShadowMap *ShadowMap::Template::create(const map &renderab throw invalid_operation("ShadowMap::Template::create"); } + create_base(*shadow_map); + return shadow_map.release(); }