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 zenith_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 zenith. Defaults to positive Z axis. Has no
43 effect without shaders. */
44 void set_zenith_direction(const Vector3 &);
46 /// Deprecated alias for set_zenith_direction
47 void set_sky_direction(const Vector3 &d) { set_zenith_direction(d); }
49 /** Sets the angle where skylight cuts off, counted from the true horizon.
50 Has no effect without shaders. */
51 void set_horizon_angle(const Geometry::Angle<float> &);
53 /** Sets the fog color, which is blended into distant surfaces. */
54 void set_fog_color(const Color &);
56 /** Sets the density of the fog. Zero means no fog. */
57 void set_fog_density(float);
59 /** Sets the density of the fog so that the blending factor at the given
61 void set_fog_half_distance(float);
63 /** Attaches a light source. If the attachment index is greater than
64 LightUnit::get_n_units, the Lighting can't be bound for legacy mode. */
65 void attach(unsigned, const Light &);
67 /** Detaches a light source. */
68 void detach(unsigned);
70 /** Returns an attached light. If no light is attached at that index, null
72 const Light *get_attached_light(unsigned) const;
74 /** Updates a ProgramData object with the uniforms for the Lighting,
75 including all attached light sources. A view matrix must be passed in. */
76 void update_shader_data(ProgramData &, const Matrix &) const;