Commit 543d6e4b authored by Martin Heistermann's avatar Martin Heistermann

Implement alpha clipping for core renderers

parent 129a63f9
......@@ -925,7 +925,12 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro
_prog->setUniform("g_cAmbient", _obj->ambient);
_prog->setUniform("g_cSpecular", _obj->specular);
ACG::Vec4f materialParams(_obj->shininess, _obj->alpha, 0.0f, 0.0f);
float alphaRef = 0.f;
if (_obj->alphaTest && _obj->alphaFunc == GL_GREATER) {
alphaRef = _obj->alphaRef;
}
ACG::Vec4f materialParams(_obj->shininess, _obj->alpha, alphaRef, 0.0f);
_prog->setUniform("g_vMaterial", materialParams);
_prog->setUniform("g_cLightModelAmbient", globalLightModelAmbient_);
......
......@@ -189,6 +189,7 @@ void RenderObject::setMaterial( const SceneGraph::Material* _mat )
// material node sets the alpha test function to GL_GREATER
alphaFunc = GL_GREATER;
alphaTest = _mat->alphaTest();
alphaRef = _mat->alphaValue();
}
......
......@@ -1073,6 +1073,7 @@ void ShaderProgGenerator::initGenDefines(ShaderGenerator* _gen)
}
_gen->addDefine("SG_ALPHA g_vMaterial.y");
_gen->addDefine("SG_MINALPHA g_vMaterial.z");
_gen->addMacros(desc_.macros);
......@@ -1834,6 +1835,7 @@ void ShaderProgGenerator::addFragmentBeginCode(QStringList* _code)
(ioDesc_.passColor_ && (desc_.shadeMode == SG_SHADE_UNLIT || desc_.colorMaterialMode == GL_EMISSION)))
_code->push_back(QString("sg_cColor = ") + ShaderGenerator::keywords.macro_inputVertexColor + QString(";"));
_code->push_back(QString("if (sg_cColor.a < SG_MINALPHA) discard;"));
if (desc_.shadeMode == SG_SHADE_PHONG)
addLightingCode(_code);
......
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