Commit a7d24e4b authored by hybrid's avatar hybrid

Fixed an issue with alpha values in 2d opengl mode.

Changed the interpretation of MaterialTypeParam==0 in transparent materials. Before, it was interpreted as 0.5, now it's used as 0 (perfectly smooth transparency). This is slower than the old value, but you can achieve the same effect by specifying 0.5 as MaterialTypeParam.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1512 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 682a1200
......@@ -297,11 +297,7 @@ public:
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
s32 refValue = core::floor32(material.MaterialTypeParam * 255.f);
if ( !refValue )
refValue = 127; // default value
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue);
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255.f));
pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
}
......@@ -348,11 +344,7 @@ public:
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
s32 refValue = core::floor32(material.MaterialTypeParam * 255.f);
if ( !refValue )
refValue = 127; // default value
pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue);
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255.f));
pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
}
......
......@@ -322,14 +322,9 @@ public:
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
s32 refValue = core::floor32(material.MaterialTypeParam * 255.f);
if ( !refValue )
refValue = 127; // default value
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue);
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255.f));
pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
}
((SMaterial&)material).ZWriteEnable = false;
......@@ -376,11 +371,7 @@ public:
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
s32 refValue = core::floor32(material.MaterialTypeParam * 255);
if ( !refValue )
refValue = 127; // default value
pID3DDevice->SetRenderState(D3DRS_ALPHAREF,refValue);
pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255));
pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
}
......
......@@ -1922,6 +1922,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
{
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.f);
}
else
{
......
......@@ -132,6 +132,7 @@ public:
glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) );
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.f);
glEnable(GL_BLEND);
if ( getTexelAlpha(srcFact) || getTexelAlpha(dstFact) )
......@@ -359,11 +360,7 @@ public:
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
f32 refValue = material.MaterialTypeParam;
if ( refValue == 0.0f )
refValue = 0.5f;
glAlphaFunc(GL_GREATER, refValue);
glAlphaFunc(GL_GREATER, material.MaterialTypeParam);
}
}
......@@ -400,7 +397,7 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);
glAlphaFunc(GL_GREATER, 0.5f);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
}
......
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