- Bind bind_fbo(fbo, true);
- fbo.clear(DEPTH_BUFFER_BIT);
- renderable.render("shadow");
- }
+ BindRestore bind_fbo(fbo);
+ Bind bind_depth(DepthTest::lequal());
+ fbo.clear(DEPTH_BUFFER_BIT);
+ renderable.render("shadow");
+}
+
+void ShadowMap::finish_frame() const
+{
+ renderable.finish_frame();
+ rendered = false;
+}
+
+void ShadowMap::render(Renderer &renderer, const Tag &tag) const
+{
+ if(!enabled_passes.count(tag))
+ return renderer.render(renderable, tag);
+
+ Renderer::Push _push_rend(renderer);
+
+ unsigned unit = renderer.allocate_effect_texunit();
+ int iunit = unit;
+ shdata.uniform("shadow", iunit);
+
+ Bind _bind_depth(depth_buf, unit);
+
+ 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);