From: Mikko Rasa Date: Sat, 27 Sep 2014 15:42:35 +0000 (+0300) Subject: Move the reflectivity parameter to material X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=99ffd618b531395fe369b33fb029855d57547365;p=libs%2Fgl.git Move the reflectivity parameter to material Logically it belongs there, even if OpenGL has no fixed-function support for it. --- diff --git a/source/material.cpp b/source/material.cpp index 13f2d1d9..feb97bfa 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -12,6 +12,7 @@ Material::Material() set_specular(0); set_emission(0); set_shininess(0); + set_reflectivity(0); } void Material::update_parameter(int mask) const @@ -66,6 +67,12 @@ void Material::set_shininess(float s) update_parameter(SHININESS); } +void Material::set_reflectivity(float r) +{ + reflectivity = r; + shdata.uniform("reflectivity", reflectivity); +} + void Material::bind() const { if(set_current(this)) @@ -97,6 +104,7 @@ void Material::Loader::init() add("specular", &Loader::specular); add("emission", &Loader::emission); add("shininess", &Loader::shininess); + add("reflectivity", &Loader::reflectivity); } Color Material::Loader::make_color(float r, float g, float b, float a) @@ -132,5 +140,10 @@ void Material::Loader::shininess(float s) obj.set_shininess(s); } +void Material::Loader::reflectivity(float r) +{ + obj.set_reflectivity(r); +} + } // namespace GL } // namespace Msp diff --git a/source/material.h b/source/material.h index a38dddd6..a149f6d4 100644 --- a/source/material.h +++ b/source/material.h @@ -33,6 +33,7 @@ public: void specular(float, float, float, float); void emission(float, float, float, float); void shininess(float); + void reflectivity(float); }; private: @@ -50,6 +51,7 @@ private: Color specular; Color emission; float shininess; + float reflectivity; ProgramData shdata; public: @@ -64,11 +66,13 @@ public: void set_specular(const Color &s); void set_emission(const Color &e); void set_shininess(float s); + void set_reflectivity(float); const Color &get_ambient() const { return ambient; } const Color &get_diffuse() const { return diffuse; } const Color &get_specular() const { return specular; } const Color &get_emission() const { return emission; } float get_shininess() const { return shininess; } + float get_reflectivity() const { return reflectivity; } const ProgramData &get_shader_data() const { return shdata; } void bind() const; }; diff --git a/source/programbuilder.cpp b/source/programbuilder.cpp index 6d6a117e..db9809c4 100644 --- a/source/programbuilder.cpp +++ b/source/programbuilder.cpp @@ -135,7 +135,7 @@ const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] = { UNIFORM, "normalmap", "sampler2D", 0, 0 }, { UNIFORM, "environment", "samplerCube", 0, 0 }, { UNIFORM, "EnvMap::env_eye_matrix", "mat3", 0, 0 }, - { UNIFORM, "EnvMap::reflectivity", "float", 0, 0 }, + { UNIFORM, "Material::reflectivity", "float", 0, 0 }, { UNIFORM, "eye_obj_matrix", "mat4", "gl_ModelViewMatrix", 0 }, { UNIFORM, "eye_obj_normal_matrix", "mat3", "gl_NormalMatrix", 0 }, { UNIFORM, "projection_matrix", "mat4", "gl_ProjectionMatrix", 0 },