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;
29 std::vector<const Light *> lights;
34 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
35 void set_ambient(const Color &);
37 const Color &get_ambient() const { return ambient; }
39 /** Sets the color of the sky at zenith. Has no effect without shaders. */
40 void set_sky_color(const Color &);
42 /** Sets the direction of the sky. Defaults to positive Z axis. Has no
43 effect without shaders. */
44 void set_sky_direction(const Vector3 &);
46 /** Sets the angle where skylight cuts off, counted from the true horizon.
47 Has no effect without shaders. */
48 void set_horizon_angle(const Geometry::Angle<float> &);
50 /** Sets the fog color, which is blended into distant surfaces. */
51 void set_fog_color(const Color &);
53 /** Sets the density of the fog. Zero means no fog. */
54 void set_fog_density(float);
56 /** Sets the density of the fog so that the blending factor at the given
58 void set_fog_half_distance(float);
60 /** Attaches a light source. If the attachment index is greater than
61 LightUnit::get_n_units, the Lighting can't be bound for legacy mode. */
62 void attach(unsigned, const Light &);
64 /** Detaches a light source. */
65 void detach(unsigned);
67 /** Returns an attached light. If no light is attached at that index, null
69 const Light *get_attached_light(unsigned) const;
71 /** Updates a ProgramData object with the uniforms for the Lighting,
72 including all attached light sources. A view matrix must be passed in. */
73 void update_shader_data(ProgramData &, const Matrix &) const;