]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.cpp
Redesign depth and stencil test and blend state management
[libs/gl.git] / source / effects / shadowmap.cpp
index a6d431bc200da86e025dcc2b640aa9d2a342d0e0..cf73e810070581d8c03c6e5f3c61391d127d1551 100644 (file)
@@ -6,7 +6,6 @@
 #include "resources.h"
 #include "scene.h"
 #include "shadowmap.h"
-#include "tests.h"
 
 using namespace std;
 
@@ -42,6 +41,9 @@ void ShadowMap::init(unsigned s)
        fbo.attach(DEPTH_ATTACHMENT, depth_buf, 0);
        fbo.require_complete();
 
+       depth_test.enabled = true;
+       depth_test.compare = LEQUAL;
+
        set_darkness(1.0f);
        shdata.uniform("shd_world_matrix", Matrix());
 }
@@ -92,11 +94,11 @@ void ShadowMap::setup_frame(Renderer &renderer)
        shdata.uniform("shd_world_matrix", shadow_matrix);
 
        BindRestore bind_fbo(fbo);
-       Bind bind_depth(DepthTest::lequal());
        fbo.clear(DEPTH_BUFFER_BIT);
 
        Renderer::Push push(renderer);
        renderer.set_camera(shadow_camera);
+       renderer.set_depth_test(&depth_test);
 
        renderer.render(shadow_caster);
 }