1 #ifndef MSP_GL_SHADOWMAP_H_
2 #define MSP_GL_SHADOWMAP_H_
7 #include "framebuffer.h"
8 #include "programdata.h"
19 Creates shadows on a renderable through a shadow map texture. In the setup
20 phase, the scene is rendered to a depth texture from the point of view of the
21 lightsource. This texture is then used in the rendering phase together with
22 texture coordinate generation to determine whether each fragment is lit.
24 class ShadowMap: public Effect
29 Renderable &shadow_caster;
35 const Sampler &sampler;
43 ShadowMap(unsigned, Renderable &, const Light &, Renderable &);
45 /** Sets the ShadowMap target point and radius. The transformation matrix is
46 computed so that a sphere with the specified parameters will be completely
47 covered by the ShadowMap. */
48 void set_target(const Vector3 &, float);
50 /** Sets the darkness of shadows. Must be in the range between 0.0 and 1.0,
51 inclusive. Only usable with shaders, and provided through the
52 shadow_darkness uniform. */
53 void set_darkness(float);
55 /** Sets a distance beyond objects from which the shadow starts. Expressed
56 in pixel-sized units. Must be positive; values less than 1.0 are not
57 recommended. Larger values produce less depth artifacts, but may prevent
58 thin objects from casting shadows on nearby sufraces. */
59 void set_depth_bias(float);
61 const Texture2D &get_depth_texture() const { return depth_buf; }
62 const Matrix &get_shadow_matrix() const { return shadow_matrix; }
64 virtual void setup_frame(Renderer &);
65 virtual void finish_frame();
67 virtual void render(Renderer &, Tag = Tag()) const;
69 virtual void set_debug_name(const std::string &);