LightSourceParameters light_sources[1];
vec4 ambient_color;
vec4 sky_color;
- vec3 eye_sky_dir;
+ vec3 eye_zenith_dir;
float horizon_limit;
vec4 fog_color;
float fog_density;
ldir = ldir*eye_tbn_matrix;
out vec3 light_dir = ldir;
- out vec3 tbn_sky_dir = eye_sky_dir*eye_tbn_matrix;
+ out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
out vec3 shadow_coord = (shd_eye_matrix*eye_vertex).xyz;
out float fog_coord = eye_vertex.z;
vec3 ambient_light = ambient_color.rgb;
if(use_sky)
{
- vec3 sky_dir;
+ vec3 zenith_dir;
if(use_normal_map)
- sky_dir = tbn_sky_dir;
+ zenith_dir = tbn_zenith_dir;
else
- sky_dir = eye_sky_dir;
- float skylight_intensity = dot(normal, sky_dir)*0.5+0.5;
+ zenith_dir = eye_zenith_dir;
+ float skylight_intensity = dot(normal, zenith_dir)*0.5+0.5;
ambient_light += skylight_intensity*sky_color.rgb;
}
Lighting::Lighting():
ambient(0.2),
- sky_direction(0, 0, 1),
+ zenith_direction(0, 0, 1),
horizon_angle(Geometry::Angle<float>::zero()),
fog_color(0.0f, 0.0f, 0.0f, 0.0f),
fog_density(0.0f)
sky_color = s;
}
-void Lighting::set_sky_direction(const Vector3 &d)
+void Lighting::set_zenith_direction(const Vector3 &d)
{
- sky_direction = d;
+ zenith_direction = d;
}
void Lighting::set_horizon_angle(const Geometry::Angle<float> &a)
{
shdata.uniform("ambient_color", ambient);
shdata.uniform("sky_color", sky_color);
- shdata.uniform("eye_sky_dir", view_matrix.block<3, 3>(0, 0)*sky_direction);
+ shdata.uniform("eye_zenith_dir", view_matrix.block<3, 3>(0, 0)*zenith_direction);
shdata.uniform("horizon_limit", horizon_angle.radians());
shdata.uniform("fog_color", fog_color);
shdata.uniform("fog_density", fog_density);
+ // For backwards compatibility
+ shdata.uniform("eye_sky_dir", view_matrix.block<3, 3>(0, 0)*zenith_direction);
+
for(unsigned i=0; i<lights.size(); ++i)
if(lights[i])
lights[i]->update_shader_data(shdata, view_matrix, i);
private:
Color ambient;
Color sky_color;
- Vector3 sky_direction;
+ Vector3 zenith_direction;
Geometry::Angle<float> horizon_angle;
Color fog_color;
float fog_density;
/** Sets the color of the sky at zenith. Has no effect without shaders. */
void set_sky_color(const Color &);
- /** Sets the direction of the sky. Defaults to positive Z axis. Has no
+ /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
effect without shaders. */
- void set_sky_direction(const Vector3 &);
+ void set_zenith_direction(const Vector3 &);
+
+ /// Deprecated alias for set_zenith_direction
+ void set_sky_direction(const Vector3 &d) { set_zenith_direction(d); }
/** Sets the angle where skylight cuts off, counted from the true horizon.
Has no effect without shaders. */