1 #ifndef MSP_GL_SHADOWMAP_H_
2 #define MSP_GL_SHADOWMAP_H_
5 #include "framebuffer.h"
6 #include "programdata.h"
17 Creates shadows on a Scene through a shadow map texture. In the preparation
18 phase, the scene is rendered to a depth texture from the point of view of the
19 lightsource. This texture is then used in the rendering phase together with
20 texture coordinate generation to determine whether each fragment is lit.
22 class ShadowMap: public Effect
27 mutable Framebuffer fbo;
28 mutable Matrix shadow_matrix;
33 mutable ProgramData shdata;
34 mutable bool rendered;
37 ShadowMap(unsigned, const Renderable &, const Light &);
39 /** Sets the ShadowMap target point and radius. The transformation matrix is
40 computed so that a sphere with the specified parameters will be completely
41 covered by the ShadowMap. */
42 void set_target(const Vector3 &, float);
44 /** Sets the darkness of shadows. Must be in the range between 0.0 and 1.0,
45 inclusive. Only usable with shaders, and provided through the
46 shadow_darkness uniform. */
47 void set_darkness(float);
49 /** Sets a distance beyond objects from which the shadow starts. Expressed
50 in pixel-sized units. Must be positive; values less than 1.0 are not
51 recommended. Larger values produce less depth artifacts, but may prevent
52 thin objects from casting shadows on nearby sufraces. */
53 void set_depth_bias(float);
55 virtual void setup_frame() const;
56 virtual void finish_frame() const;
58 virtual void render(Renderer &, const Tag &) const;