1 #ifndef MSP_GL_LIGHTING_H_
2 #define MSP_GL_LIGHTING_H_
5 #include <msp/geometry/angle.h>
9 #include "programdata.h"
17 Encapsulates global lighting parameters and any number of individual light
23 class Loader: public DataFile::ObjectLoader<Lighting>
29 void ambient(float, float, float);
30 void fog_color(float, float, float);
31 void fog_density(float);
32 void fog_half_distance(float);
33 void horizon_angle(float);
35 void sky_color(float, float, float);
36 void zenith_direction(float, float, float);
42 Vector3 zenith_direction;
43 Geometry::Angle<float> horizon_angle;
46 std::vector<const Light *> lights;
47 std::vector<Light *> owned_data;
53 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
54 void set_ambient(const Color &);
56 const Color &get_ambient() const { return ambient; }
58 /** Sets the color of the sky at zenith. Has no effect without shaders. */
59 void set_sky_color(const Color &);
61 /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
62 effect without shaders. */
63 void set_zenith_direction(const Vector3 &);
65 /// Deprecated alias for set_zenith_direction
66 void set_sky_direction(const Vector3 &d) { set_zenith_direction(d); }
68 /** Sets the angle where skylight cuts off, counted from the true horizon.
69 Has no effect without shaders. */
70 void set_horizon_angle(const Geometry::Angle<float> &);
72 /** Sets the fog color, which is blended into distant surfaces. */
73 void set_fog_color(const Color &);
75 /** Sets the density of the fog. Zero means no fog. */
76 void set_fog_density(float);
78 /** Sets the density of the fog so that the blending factor at the given
80 void set_fog_half_distance(float);
82 /** Attaches a light source. */
83 void attach(unsigned, const Light &);
85 /** Detaches a light source. */
86 void detach(unsigned);
88 /** Returns an attached light. If no light is attached at that index, null
90 const Light *get_attached_light(unsigned) const;
92 /** Updates a ProgramData object with the uniforms for the Lighting,
93 including all attached light sources. A view matrix must be passed in. */
94 void update_shader_data(ProgramData &, const Matrix &) const;