X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.h;h=611f56f51040a2204055e29f37d0e67a68d48b7c;hb=c8520aa336e92f2eaf9a38c3430c608520a90324;hp=67f2cf6c30a0b1b264759b0090265b89cec7a5b6;hpb=2b2676392aff2eb6b38c3e463cc67f4d67a4ef8b;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index 67f2cf6c..611f56f5 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -2,18 +2,18 @@ #define MSP_GL_SHADOWMAP_H_ #include "camera.h" -#include "depthtest.h" #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 @@ -24,28 +24,37 @@ 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; - DepthTest depth_test; 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 *, Renderable &); public: - ShadowMap(unsigned, Renderable &, const Light &, Renderable &); - DEPRECATED ShadowMap(unsigned, Renderable &, const Light &); -private: - void init(unsigned); + ShadowMap(unsigned, Renderable &, const DirectionalLight &, Renderable &); + ShadowMap(unsigned, unsigned, Renderable &, const Lighting &, Renderable &); + + void add_light(const DirectionalLight &, unsigned); -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. */ @@ -63,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();