diff --git a/include/EMaterialTypes.h b/include/EMaterialTypes.h index a845a1b..cdbd499 100644 --- a/include/EMaterialTypes.h +++ b/include/EMaterialTypes.h @@ -187,7 +187,9 @@ namespace video EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, //! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC ) - /** Using only first texture. Generic blending method. */ + /** Using only first texture. Generic blending method. + The blend function is set to SMaterial::MaterialTypeParam with + pack_textureBlendFunc (for 2D) or pack_textureBlendFuncSeparate (for 3D). */ EMT_ONETEXTURE_BLEND, //! This value is not used. It only forces this enumeration to compile to 32 bit. diff --git a/include/SMaterial.h b/include/SMaterial.h index 3661f7e..29bc332 100644 --- a/include/SMaterial.h +++ b/include/SMaterial.h @@ -19,7 +19,8 @@ namespace video { class ITexture; - //! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) BlendFunc = source * sourceFactor + dest * destFactor + //! Flag for MaterialTypeParam (in combination with EMT_ONETEXTURE_BLEND) or for BlendFactor + //! BlendFunc = source * sourceFactor + dest * destFactor enum E_BLEND_FACTOR { EBF_ZERO = 0, //!< src & dest (0, 0, 0, 0) @@ -431,8 +432,8 @@ namespace video f32 Shininess; //! Free parameter, dependent on the material type. - /** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID - and EMT_TRANSPARENT_ALPHA_CHANNEL. */ + /** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID, + EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_ONETEXTURE_BLEND. */ f32 MaterialTypeParam; //! Second free parameter, dependent on the material type. @@ -474,8 +475,14 @@ namespace video //! Store the blend factors /** textureBlendFunc/textureBlendFuncSeparate functions should be used to write - properly blending factors to this parameter. If you use EMT_ONETEXTURE_BLEND - type for this material, this field should be equal to MaterialTypeParams. */ + properly blending factors to this parameter. + Due to historical reasons this parameter is not used for material type + EMT_ONETEXTURE_BLEND which uses MaterialTypeParam instead for the blend factor. + It's generally used only for materials without any blending otherwise (like EMT_SOLID). + It's main use is to allow having shader materials which can enable/disable + blending after they have been created. + When you set this you usually also have to set BlendOperation to a value != EBO_NONE + (setting it to EBO_ADD is probably the most common one value). */ f32 BlendFactor; //! DEPRECATED. Will be removed after Irrlicht 1.9. Please use PolygonOffsetDepthBias instead. diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 03a4586..c376ac8 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -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; diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 3c4d745..f2c8d73 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -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; diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 8d233c2..c7e183e 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -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; diff --git a/source/Irrlicht/COpenGLShaderMaterialRenderer.h b/source/Irrlicht/COpenGLShaderMaterialRenderer.h index 50e70f1..7cae915 100644 --- a/source/Irrlicht/COpenGLShaderMaterialRenderer.h +++ b/source/Irrlicht/COpenGLShaderMaterialRenderer.h @@ -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: diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index d47378a..5016da9 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Fri Jan 03 10:49:15 2020 +Test suite pass at GMT Fri Jan 03 14:40:24 2020