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;
- Renderable &shadow_caster;
+ std::vector<ShadowView> views;
Framebuffer fbo;
Texture2D depth_buf;
const Sampler &sampler;
bool rendered = false;
std::string debug_name;
- ShadowMap(unsigned, unsigned, Renderable &, const Lighting *, Renderable &);
+ ShadowMap(unsigned, unsigned, Renderable &, const Lighting *);
public:
ShadowMap(unsigned, Renderable &, const DirectionalLight &, Renderable &);
- ShadowMap(unsigned, unsigned, Renderable &, const Lighting &, Renderable &);
+ ShadowMap(unsigned, unsigned, Renderable &, const Lighting &);
- void add_light(const DirectionalLight &, unsigned);
+ 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. */