Fixed issue where objects with bloom disabled would screw up bloom rendering

This commit is contained in:
parax0 2015-07-29 12:49:53 -04:00
parent 4ef940b1f3
commit ae0b6f97df
2 changed files with 21 additions and 12 deletions

View File

@ -67,20 +67,29 @@ bool CMaterial::SetCurrent(ERenderOptions Options)
if (mShaderStatus == eShaderFailed)
return false;
// Set blend equation - force to ZERO/ONE if alpha is disabled
if (Options & eNoAlpha)
glBlendFunc(GL_ONE, GL_ZERO);
else
glBlendFunc(mBlendSrcFac, mBlendDstFac);
// Set RGB blend equation - force to ZERO/ONE if alpha is disabled
GLenum srcRGB, dstRGB, srcAlpha, dstAlpha;
// Set color mask. This is for rendering bloom - bloom maps render to the framebuffer alpha
// We can only render bloom on materials that aren't alpha blended.
if (Options & eNoAlpha) {
srcRGB = GL_ONE;
dstRGB = GL_ZERO;
} else {
srcRGB = mBlendSrcFac;
dstRGB = mBlendDstFac;
}
// Set alpha blend equation
bool AlphaBlended = ((mBlendSrcFac == GL_SRC_ALPHA) && (mBlendDstFac == GL_ONE_MINUS_SRC_ALPHA));
if ((mEnableBloom) && (Options & eEnableBloom) && (!AlphaBlended))
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
else
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
if ((mEnableBloom) && (Options & eEnableBloom) && (!AlphaBlended)) {
srcAlpha = mBlendSrcFac;
dstAlpha = mBlendDstFac;
} else {
srcAlpha = GL_ZERO;
dstAlpha = GL_ZERO;
}
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
// Set konst inputs
for (u32 iKonst = 0; iKonst < 4; iKonst++)

View File

@ -117,7 +117,7 @@ void CScriptNode::Draw(ERenderOptions Options)
if (!mpActiveModel)
{
glBlendFunc(GL_ONE, GL_ZERO);
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ZERO);
glDepthMask(GL_TRUE);
LoadModelMatrix();