]> git.tdb.fi Git - libs/gl.git/blobdiff - source/shadowmap.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / shadowmap.cpp
index 0e32210f49a044a36f4977fc1e069854ee42f57a..eaf6e1373cb126a387d535e9e2b1352199eed2e7 100644 (file)
@@ -12,6 +12,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
+WeakPtr<Sampler> ShadowMap::shadow_sampler;
+
 ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l):
        Effect(r),
        size(s),
@@ -20,11 +22,16 @@ ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l):
        depth_bias(4),
        rendered(false)
 {
-       depth_buf.set_min_filter(LINEAR);
-       depth_buf.set_compare_enabled(true);
-       depth_buf.set_compare_func(LEQUAL);
-       depth_buf.set_wrap(CLAMP_TO_EDGE);
-       depth_buf.storage(DEPTH_COMPONENT, size, size, 1);
+       sampler = shadow_sampler;
+       if(!sampler)
+       {
+               sampler = new Sampler;
+               sampler->set_filter(LINEAR);
+               sampler->set_compare(LEQUAL);
+               sampler->set_wrap(CLAMP_TO_EDGE);
+               shadow_sampler = sampler;
+       }
+       depth_buf.storage(DEPTH_COMPONENT32F, size, size, 1);
        fbo.attach(DEPTH_ATTACHMENT, depth_buf, 0);
        fbo.require_complete();
 
@@ -101,6 +108,7 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const
        int iunit = unit;
        shdata.uniform("shadow_map", iunit);
 
+       Bind _bind_sampler(*sampler, unit);
        Bind _bind_depth(depth_buf, unit);
 
        if(const Camera *camera = renderer.get_camera())