X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.h;h=6c4e1e501713d84aa393652b8eefb32912a3a0ec;hb=cdedbb34eff07f188c536167592958e315d53a9b;hp=67103b86f8abfe11ab56ead2ea801759c5138b1c;hpb=f96d553dbf78f9d664d1dbb1fe002fc43f23ad47;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index 67103b86..6c4e1e50 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -5,12 +5,14 @@ #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; /** @@ -22,22 +24,36 @@ texture coordinate generation to determine whether each fragment is lit. class ShadowMap: public Effect { private: - unsigned size; - const Light &light; - Renderable &shadow_caster; + struct ShadowedLight + { + const Light *light; + unsigned index; + Rect region; + Camera shadow_camera; + Renderable *shadow_caster; + }; + + unsigned width; + unsigned height; + const Lighting *lighting; + std::vector lights; Framebuffer fbo; - Camera shadow_camera; - Matrix shadow_matrix; Texture2D depth_buf; const Sampler &sampler; Vector3 target; - float radius; - float depth_bias; + 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 *); public: - ShadowMap(unsigned, Renderable &, const Light &, Renderable &); + ShadowMap(unsigned, Renderable &, const DirectionalLight &, Renderable &); + ShadowMap(unsigned, unsigned, Renderable &, const Lighting &); + + void add_light(const DirectionalLight &, unsigned, Renderable &); /** Sets the ShadowMap target point and radius. The transformation matrix is computed so that a sphere with the specified parameters will be completely @@ -56,7 +72,6 @@ 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();