X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.cpp;h=36011107e3d19de1f6aa07eb7235d0fdc9d869bc;hp=1b5f531b913c2d339f8e1aee3830775d576aed58;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=adc26a2e141a2853b6c5025130c46a46cece4b84 diff --git a/source/effects/shadowmap.cpp b/source/effects/shadowmap.cpp index 1b5f531b..36011107 100644 --- a/source/effects/shadowmap.cpp +++ b/source/effects/shadowmap.cpp @@ -17,11 +17,7 @@ ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &r, const Lighting *l, R height(h), lighting(l), shadow_caster(c), - sampler(Resources::get_global().get("_linear_clamp_shadow.samp")), - radius(1), - depth_bias(4), - darkness(1.0f), - rendered(false) + sampler(Resources::get_global().get("_linear_clamp_shadow.samp")) { depth_buf.storage(DEPTH_COMPONENT32F, width, height, 1); fbo.set_format((DEPTH_ATTACHMENT,DEPTH_COMPONENT32F)); @@ -153,10 +149,8 @@ void ShadowMap::setup_frame(Renderer &renderer) l.shadow_camera.set_orthographic(radius*2, radius*2); l.shadow_camera.set_depth_clip(-radius, radius); - Matrix shadow_matrix = l.shadow_camera.get_object_matrix(); - shadow_matrix.scale(radius*2, radius*2, -radius*2); - shadow_matrix.translate(-0.5, -0.5, depth_bias/l.region.width-0.5); - shadow_matrix.invert(); + Matrix to_texcoord = Matrix().translate(Vector3(0.5f, 0.5f, 0.5f-depth_bias/l.region.width)).scale(0.5f); + Matrix shadow_matrix = to_texcoord*l.shadow_camera.get_projection_matrix()*l.shadow_camera.get_view_matrix(); shdata.uniform(format("shadows[%d].shd_world_matrix", l.index), shadow_matrix); }