X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.h;h=cb6229935a81806dc3bad9af00b72bed47e739b7;hb=adc26a2e141a2853b6c5025130c46a46cece4b84;hp=d7b4eef970160f34503bb51ed23096991a4035f7;hpb=7db40551e9197142b0b6cb7fd883b325684bb8c2;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index d7b4eef9..cb622993 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -5,14 +5,15 @@ #include "effect.h" #include "framebuffer.h" #include "programdata.h" +#include "rect.h" #include "texture2d.h" #include "vector.h" namespace Msp { namespace GL { +class DirectionalLight; class Light; -class Resources; /** Creates shadows on a renderable through a shadow map texture. In the setup @@ -23,21 +24,36 @@ texture coordinate generation to determine whether each fragment is lit. class ShadowMap: public Effect { private: - unsigned size; - const Light &light; + struct ShadowedLight + { + const Light *light; + unsigned index; + Rect region; + Camera shadow_camera; + }; + + unsigned width; + unsigned height; + const Lighting *lighting; + std::vector lights; + Renderable &shadow_caster; Framebuffer fbo; - Camera shadow_camera; - Matrix shadow_matrix; Texture2D depth_buf; const Sampler &sampler; Vector3 target; float radius; float depth_bias; - mutable ProgramData shdata; + float darkness; + ProgramData shdata; bool rendered; + std::string debug_name; + ShadowMap(unsigned, unsigned, Renderable &, const Lighting *, Renderable &); public: - ShadowMap(Resources &, unsigned, Renderable &, const Light &); + ShadowMap(unsigned, Renderable &, const DirectionalLight &, Renderable &); + ShadowMap(unsigned, unsigned, Renderable &, const Lighting &, Renderable &); + + void add_light(const DirectionalLight &, unsigned); /** Sets the ShadowMap target point and radius. The transformation matrix is computed so that a sphere with the specified parameters will be completely @@ -56,12 +72,13 @@ public: void set_depth_bias(float); const Texture2D &get_depth_texture() const { return depth_buf; } - const Matrix &get_shadow_matrix() const { return shadow_matrix; } virtual void setup_frame(Renderer &); virtual void finish_frame(); virtual void render(Renderer &, Tag = Tag()) const; + + virtual void set_debug_name(const std::string &); }; } // namespace GL