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
20 class Lighting: public Bindable<Lighting>
25 Vector3 sky_direction;
26 Geometry::Angle<float> horizon_angle;
27 std::vector<const Light *> lights;
32 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
33 void set_ambient(const Color &);
35 const Color &get_ambient() const { return ambient; }
37 /** Sets the color of the sky at zenith. Has no effect without shaders. */
38 void set_sky_color(const Color &);
40 /** Sets the direction of the sky. Defaults to positive Z axis. Has no
41 effect without shaders. */
42 void set_sky_direction(const Vector3 &);
44 /** Sets the angle where skylight cuts off, counted from the true horizon.
45 Has no effect without shaders. */
46 void set_horizon_angle(const Geometry::Angle<float> &);
48 /** Attaches a light source. If the attachment index is greater than
49 LightUnit::get_n_units, the Lighting can't be bound for legacy mode. */
50 void attach(unsigned, const Light &);
52 /** Detaches a light source. */
53 void detach(unsigned);
55 /** Returns an attached light. If no light is attached at that index, null
57 const Light *get_attached_light(unsigned) const;
59 /** Updates a ProgramData object with the uniforms for the Lighting,
60 including all attached light sources. A view matrix must be passed in. */
61 void update_shader_data(ProgramData &, const Matrix &) const;