]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.cpp
Move lighting calculations to world space
[libs/gl.git] / source / effects / shadowmap.cpp
index 488a3427360eeea8fcf7921209632f64cdb8a453..11bb706e6afa3265562e277e3ac899783e888095 100644 (file)
@@ -43,6 +43,7 @@ void ShadowMap::init(unsigned s)
        fbo.require_complete();
 
        set_darkness(0.7);
+       shdata.uniform("shd_world_matrix", Matrix());
 }
 
 void ShadowMap::set_target(const Vector3 &t, float r)
@@ -88,6 +89,8 @@ void ShadowMap::setup_frame(Renderer &renderer)
        shadow_matrix.translate(-0.5, -0.5, depth_bias/size-0.5);
        shadow_matrix.invert();
 
+       shdata.uniform("shd_world_matrix", shadow_matrix);
+
        BindRestore bind_fbo(fbo);
        Bind bind_depth(DepthTest::lequal());
        fbo.clear(DEPTH_BUFFER_BIT);
@@ -112,13 +115,6 @@ void ShadowMap::render(Renderer &renderer, Tag tag) const
        if(!enabled_passes.count(tag))
                return renderer.render(renderable, tag);
 
-       if(const Camera *camera = renderer.get_camera())
-               /* Multiply by camera's object matrix to form a matrix that transforms
-               from eye space to shadow space. */
-               shdata.uniform("shd_eye_matrix", shadow_matrix*camera->get_object_matrix());
-       else
-               shdata.uniform("shd_eye_matrix", shadow_matrix);
-
        Renderer::Push _push_rend(renderer);
 
        renderer.set_texture("shadow_map", &depth_buf, &sampler);