X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fshadowmap.h;h=502480122fc68354e45c85adec5b8a3d22c328de;hb=523c854119b40a6b603c5980420c3c923999ffd4;hp=cf2dec01bc69e90afda1255dd63918fd5b8d5ebc;hpb=bace0b24414abc7b3ba46df3a9fd7408d7479a5e;p=libs%2Fgl.git diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index cf2dec01..50248012 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 @@ -23,11 +24,60 @@ texture coordinate generation to determine whether each fragment is lit. */ class ShadowMap: public Effect { +public: + struct Template: Effect::Template + { + class Loader: public DataFile::DerivedObjectLoader + { + private: + static ActionMap shared_actions; + + public: + Loader(Template &, Collection &); + private: + virtual void init_actions(); + + void light(const std::string &); + void size_square(unsigned); + void target(float, float, float); + }; + + struct ShadowedLight + { + class Loader: public DataFile::ObjectLoader + { + private: + static ActionMap shared_actions; + + public: + Loader(ShadowedLight &); + private: + virtual void init_actions(); + }; + + const Light *light = 0; + unsigned size; + std::string shadow_caster_name; + }; + + unsigned width = 2048; + unsigned height = 2048; + const Lighting *lighting = 0; + std::vector lights; + Vector3 target; + float radius = 1.0f; + float depth_bias = 4.0f; + float darkness = 1.0f; + + virtual ShadowMap *create(const std::map &) const; + }; + private: enum ShadowType { NONE, - DIRECTIONAL + DIRECTIONAL, + TETRAHEDRON }; struct ShadowedLight @@ -45,6 +95,7 @@ private: unsigned light_index; unsigned face; Camera camera; + Matrix face_matrix; }; unsigned width; @@ -69,6 +120,7 @@ public: ShadowMap(unsigned, unsigned, Renderable &, const Lighting &); void add_light(const DirectionalLight &, unsigned, Renderable &); + void add_light(const PointLight &, unsigned, Renderable &); private: void add_light(const Light &, unsigned, ShadowType, Renderable &);