X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.h;h=0acb1b64657bc2cc0c5d0837717883fb0bd1b77f;hb=57588abbefc8f0162332ac2310c69b62a14b2404;hp=cb6229935a81806dc3bad9af00b72bed47e739b7;hpb=adc26a2e141a2853b6c5025130c46a46cece4b84;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index cb622993..0acb1b64 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -14,6 +14,7 @@ namespace GL { class DirectionalLight; class Light; +class PointLight; /** Creates shadows on a renderable through a shadow map texture. In the setup @@ -24,37 +25,58 @@ texture coordinate generation to determine whether each fragment is lit. class ShadowMap: public Effect { private: + enum ShadowType + { + NONE, + DIRECTIONAL, + TETRAHEDRON + }; + struct ShadowedLight { const Light *light; unsigned index; Rect region; - Camera shadow_camera; + ShadowType type; + unsigned view_index; + Renderable *shadow_caster; + }; + + struct ShadowView + { + unsigned light_index; + unsigned face; + Camera camera; + Matrix face_matrix; }; unsigned width; unsigned height; const Lighting *lighting; std::vector lights; - Renderable &shadow_caster; + std::vector views; Framebuffer fbo; Texture2D depth_buf; const Sampler &sampler; Vector3 target; - float radius; - float depth_bias; - float darkness; + float radius = 1.0f; + float depth_bias = 4.0f; + float darkness = 1.0f; ProgramData shdata; - bool rendered; + bool rendered = false; std::string debug_name; - ShadowMap(unsigned, unsigned, Renderable &, const Lighting *, Renderable &); + ShadowMap(unsigned, unsigned, Renderable &, const Lighting *); public: ShadowMap(unsigned, Renderable &, const DirectionalLight &, Renderable &); - ShadowMap(unsigned, unsigned, Renderable &, const Lighting &, Renderable &); + ShadowMap(unsigned, unsigned, Renderable &, const Lighting &); - void add_light(const DirectionalLight &, unsigned); + void add_light(const DirectionalLight &, unsigned, Renderable &); + void add_light(const PointLight &, unsigned, Renderable &); +private: + void add_light(const Light &, unsigned, ShadowType, Renderable &); +public: /** Sets the ShadowMap target point and radius. The transformation matrix is computed so that a sphere with the specified parameters will be completely covered by the ShadowMap. */