]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/shadowmap.h
Refactor ShadowMap to allow different types of lights
[libs/gl.git] / source / effects / shadowmap.h
index 6c4e1e501713d84aa393652b8eefb32912a3a0ec..cf2dec01bc69e90afda1255dd63918fd5b8d5ebc 100644 (file)
@@ -24,19 +24,34 @@ texture coordinate generation to determine whether each fragment is lit.
 class ShadowMap: public Effect
 {
 private:
+       enum ShadowType
+       {
+               NONE,
+               DIRECTIONAL
+       };
+
        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;
+       };
+
        unsigned width;
        unsigned height;
        const Lighting *lighting;
        std::vector<ShadowedLight> lights;
+       std::vector<ShadowView> views;
        Framebuffer fbo;
        Texture2D depth_buf;
        const Sampler &sampler;
@@ -54,7 +69,10 @@ public:
        ShadowMap(unsigned, unsigned, Renderable &, const Lighting &);
 
        void add_light(const DirectionalLight &, 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. */