Commit 97a03f6b authored by Christopher Tenter's avatar Christopher Tenter
Browse files

fix color bug in generated shaders that occurred when vertex colors should...

fix color bug in generated shaders that occurred when vertex colors should replace the ambient material color

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@21103 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c72cbf03
......@@ -801,9 +801,7 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro
// material
// modify the emissive color such that it also contains the global ambient light model
ACG::Vec3f emissiveA = _obj->emissive + globalLightModelAmbient_ * _obj->ambient;
_prog->setUniform("g_cEmissive", emissiveA);
_prog->setUniform("g_cEmissive", _obj->emissive);
_prog->setUniform("g_cDiffuse", _obj->diffuse);
_prog->setUniform("g_cAmbient", _obj->ambient);
......@@ -812,6 +810,7 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro
ACG::Vec4f materialParams(_obj->shininess, _obj->alpha, 0.0f, 0.0f);
_prog->setUniform("g_vMaterial", materialParams);
_prog->setUniform("g_cLightModelAmbient", globalLightModelAmbient_);
// Additional Uniforms defined in the render Object
if ( !_obj->uniformPool_.empty() )
......
......@@ -419,6 +419,7 @@ void ShaderGenerator::initDefaultUniforms()
addUniform("vec3 g_cEmissive");
addUniform("vec3 g_cSpecular");
addUniform("vec4 g_vMaterial");
addUniform("vec3 g_cLightModelAmbient");
}
......@@ -1176,7 +1177,10 @@ void ShaderProgGenerator::addVertexBeginCode(QStringList* _code)
}
}
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive, SG_ALPHA);");
if (desc_.vertexColors && (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE))
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * " SG_INPUT_VERTEXCOLOR ".xyz, SG_ALPHA);");
else
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * g_cAmbient, SG_ALPHA);");
if (ioDesc_.inputNormal_)
{
......@@ -1787,7 +1791,10 @@ void ShaderProgGenerator::addFragmentBeginCode(QStringList* _code)
_code->push_back("#endif");
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive, SG_ALPHA);");
if (desc_.vertexColors && (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE))
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * " SG_INPUT_VERTEXCOLOR ".xyz, SG_ALPHA);");
else
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * g_cAmbient, SG_ALPHA);");
if (desc_.shadeMode == SG_SHADE_GOURAUD ||
desc_.shadeMode == SG_SHADE_FLAT ||
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment