Use BlendFactor only when MaterialType != EMT_ONETEXTURE_BLEND

The way this was implemented BlendFactor and MaterialTypeParam could conflict otherwise as they both send the blend functions.

We could probably rewrite all places which use EMT_ONETEXTURE_BLEND+MaterialTypeParam to additionally check for BlendFactor, but it would still set the blend-functions twice. 
I'm not sure if BlendFactor works with 2D materials currently? (but we can't set those to shaders yet anyway except in the gles branch...).

I've also started documenting a few things about how I suppose it's working, I hope I got it all right.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6034 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2020-01-03 14:58:46 +00:00
parent 473ab1ea58
commit 0b71328102
7 changed files with 26 additions and 11 deletions

View File

@ -2219,7 +2219,9 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
}
// Blend Factor
if (IR(material.BlendFactor) & 0xFFFFFFFF)
if (IR(material.BlendFactor) & 0xFFFFFFFF // TODO: why the & 0xFFFFFFFF?
&& material.MaterialType != EMT_ONETEXTURE_BLEND
)
{
E_BLEND_FACTOR srcRGBFact = EBF_ZERO;
E_BLEND_FACTOR dstRGBFact = EBF_ZERO;

View File

@ -2759,7 +2759,9 @@ bool CNullDriver::needsTransparentRenderPass(const irr::video::SMaterial& materi
// zwrite disabled and getWriteZBuffer calls this function.
video::IMaterialRenderer* rnd = getMaterialRenderer(material.MaterialType);
if (rnd && rnd->isTransparent())
// TODO: I suspect IMaterialRenderer::isTransparent also often could use SMaterial as parameter
// We could for example then get rid of IsTransparent function in SMaterial and move that to the software material renderer.
if (rnd && rnd->isTransparent())
return true;
return false;

View File

@ -2585,7 +2585,9 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
// Blend Factor
if (IR(material.BlendFactor) & 0xFFFFFFFF)
if (IR(material.BlendFactor) & 0xFFFFFFFF // TODO: why the & 0xFFFFFFFF?
&& material.MaterialType != EMT_ONETEXTURE_BLEND
)
{
E_BLEND_FACTOR srcRGBFact = EBF_ZERO;
E_BLEND_FACTOR dstRGBFact = EBF_ZERO;

View File

@ -21,7 +21,7 @@ namespace video
class COpenGLDriver;
class IShaderConstantSetCallBack;
//! Class for using vertex and pixel shaders with OpenGL
//! Class for using vertex and pixel shaders with OpenGL (asm not glsl!)
class COpenGLShaderMaterialRenderer : public IMaterialRenderer
{
public: