1 #ifndef MSP_GL_LIGHTING_H_
2 #define MSP_GL_LIGHTING_H_
5 #include <msp/geometry/angle.h>
8 #include "programdata.h"
16 Encapsulates global lighting parameters and any number of individual light
22 class Loader: public DataFile::ObjectLoader<Lighting>
28 void ambient(float, float, float);
29 void fog_color(float, float, float);
30 void fog_density(float);
31 void fog_half_distance(float);
32 void horizon_angle(float);
34 void sky_color(float, float, float);
35 void zenith_direction(float, float, float);
41 Vector3 zenith_direction;
42 Geometry::Angle<float> horizon_angle;
45 std::vector<const Light *> lights;
46 std::vector<Light *> owned_data;
52 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
53 void set_ambient(const Color &);
55 const Color &get_ambient() const { return ambient; }
57 /** Sets the color of the sky at zenith. Has no effect without shaders. */
58 void set_sky_color(const Color &);
60 /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
61 effect without shaders. */
62 void set_zenith_direction(const Vector3 &);
64 /** Sets the angle where skylight cuts off, counted from the true horizon.
65 Has no effect without shaders. */
66 void set_horizon_angle(const Geometry::Angle<float> &);
68 /** Sets the fog color, which is blended into distant surfaces. */
69 void set_fog_color(const Color &);
71 /** Sets the density of the fog. Zero means no fog. */
72 void set_fog_density(float);
74 /** Sets the density of the fog so that the blending factor at the given
76 void set_fog_half_distance(float);
78 /** Attaches a light source. */
79 void attach(unsigned, const Light &);
81 /** Detaches a light source. */
82 void detach(unsigned);
84 /** Returns an attached light. If no light is attached at that index, null
86 const Light *get_attached_light(unsigned) const;
88 /** Updates a ProgramData object with the uniforms for the Lighting,
89 including all attached light sources. A view matrix must be passed in. */
90 void update_shader_data(ProgramData &, const Matrix &) const;