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 /** Sets the angle where skylight cuts off, counted from the true horizon.
66 Has no effect without shaders. */
67 void set_horizon_angle(const Geometry::Angle<float> &);
69 /** Sets the fog color, which is blended into distant surfaces. */
70 void set_fog_color(const Color &);
72 /** Sets the density of the fog. Zero means no fog. */
73 void set_fog_density(float);
75 /** Sets the density of the fog so that the blending factor at the given
77 void set_fog_half_distance(float);
79 /** Attaches a light source. */
80 void attach(unsigned, const Light &);
82 /** Detaches a light source. */
83 void detach(unsigned);
85 /** Returns an attached light. If no light is attached at that index, null
87 const Light *get_attached_light(unsigned) const;
89 /** Updates a ProgramData object with the uniforms for the Lighting,
90 including all attached light sources. A view matrix must be passed in. */
91 void update_shader_data(ProgramData &, const Matrix &) const;