X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fshadowmap.cpp;h=eaf6e1373cb126a387d535e9e2b1352199eed2e7;hp=6250f899005b23684f0397b324609a174a858631;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=9087cc0a372b9c739f15398c7a22c0a6eb5041bb diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index 6250f899..eaf6e137 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -12,6 +12,8 @@ using namespace std; namespace Msp { namespace GL { +WeakPtr ShadowMap::shadow_sampler; + ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l): Effect(r), size(s), @@ -20,10 +22,15 @@ ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l): depth_bias(4), rendered(false) { - Sampler &depth_samp = depth_buf.get_default_sampler(); - depth_samp.set_min_filter(LINEAR); - depth_samp.set_compare(LEQUAL); - depth_samp.set_wrap(CLAMP_TO_EDGE); + 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())