From: Mikko Rasa Date: Tue, 19 Dec 2017 16:15:20 +0000 (+0200) Subject: Rename Lighting::sky_direction to zenith_direction X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=0c1e15e36a46bada35b905b2bdd35f6f48ce7cb0;hp=6109322ffc5dec1a777807fcbefacafe94d1d5eb Rename Lighting::sky_direction to zenith_direction That name more accurately describes its purpose. --- diff --git a/shaderlib/singlepass.glsl b/shaderlib/singlepass.glsl index a1062fed..a80ca339 100644 --- a/shaderlib/singlepass.glsl +++ b/shaderlib/singlepass.glsl @@ -43,7 +43,7 @@ uniform Lighting 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; @@ -113,7 +113,7 @@ void singlepass_transform_and_lighting() 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; @@ -156,12 +156,12 @@ vec3 singlepass_lighting() 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; } diff --git a/source/lighting.cpp b/source/lighting.cpp index ce522ac0..ea59a142 100644 --- a/source/lighting.cpp +++ b/source/lighting.cpp @@ -15,7 +15,7 @@ namespace GL { Lighting::Lighting(): ambient(0.2), - sky_direction(0, 0, 1), + zenith_direction(0, 0, 1), horizon_angle(Geometry::Angle::zero()), fog_color(0.0f, 0.0f, 0.0f, 0.0f), fog_density(0.0f) @@ -31,9 +31,9 @@ void Lighting::set_sky_color(const Color &s) 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 &a) @@ -88,11 +88,14 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix { 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; iupdate_shader_data(shdata, view_matrix, i); diff --git a/source/lighting.h b/source/lighting.h index 931d06d3..40360fc5 100644 --- a/source/lighting.h +++ b/source/lighting.h @@ -22,7 +22,7 @@ class Lighting: public Bindable private: Color ambient; Color sky_color; - Vector3 sky_direction; + Vector3 zenith_direction; Geometry::Angle horizon_angle; Color fog_color; float fog_density; @@ -39,9 +39,12 @@ public: /** 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. */