X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Flight.cpp;h=2825b81eaa745f70b9d5aa4ed6009e499c4dce5c;hp=e910411f276e27ebd305f507513177787caebb25;hb=a266f0f915827b20591f6244ccc36129e844f408;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266 diff --git a/source/materials/light.cpp b/source/materials/light.cpp index e910411f..2825b81e 100644 --- a/source/materials/light.cpp +++ b/source/materials/light.cpp @@ -11,8 +11,8 @@ namespace Msp { namespace GL { Light::Light(): - diffuse(1), - specular(1), + color(1), + transmittance(1), position(0, 0, 1, 0), spot_dir(0, 0, -1), spot_exp(0), @@ -40,14 +40,14 @@ void Light::update_matrix() matrix = Matrix::from_columns(columns); } -void Light::set_diffuse(const Color &c) +void Light::set_color(const Color &c) { - diffuse = c; + color = c; } -void Light::set_specular(const Color &c) +void Light::set_transmittance(const Color &t) { - specular = c; + transmittance = t; } void Light::set_matrix(const Matrix &m) @@ -107,8 +107,7 @@ void Light::update_shader_data(ProgramData &shdata, const Matrix &view_matrix, u { string base = format("light_sources[%d]", i); shdata.uniform(base+".position", view_matrix*position); - shdata.uniform(base+".diffuse", diffuse); - shdata.uniform(base+".specular", specular); + shdata.uniform(base+".color", color.r*transmittance.r, color.g*transmittance.g, color.b*transmittance.b); } @@ -116,12 +115,15 @@ Light::Loader::Loader(Light &l): DataFile::ObjectLoader(l) { add("attenuation", &Loader::attenuation); - add("diffuse", &Loader::diffuse); + add("color", &Loader::color); add("position", &Loader::position); - add("specular", &Loader::specular); add("spot_direction", &Loader::spot_direction); add("spot_exponent", &Loader::spot_exponent); add("spot_cutoff", &Loader::spot_cutoff); + + // Deprecated + add("diffuse", &Loader::color); + add("specular"); } void Light::Loader::attenuation(float c, float l, float q) @@ -129,9 +131,9 @@ void Light::Loader::attenuation(float c, float l, float q) obj.set_attenuation(c, l, q); } -void Light::Loader::diffuse(float r, float g, float b) +void Light::Loader::color(float r, float g, float b) { - obj.set_diffuse(Color(r, g, b)); + obj.set_color(Color(r, g, b)); } void Light::Loader::position(float x, float y, float z, float w) @@ -139,11 +141,6 @@ void Light::Loader::position(float x, float y, float z, float w) obj.set_position(Vector4(x, y, z, w)); } -void Light::Loader::specular(float r, float g, float b) -{ - obj.set_specular(Color(r, g, b)); -} - void Light::Loader::spot_direction(float x, float y, float z) { obj.set_spot_direction(Vector3(x, y, z));