diff --git a/include/EMaterialTypes.h b/include/EMaterialTypes.h index 75f95d36..086ca345 100644 --- a/include/EMaterialTypes.h +++ b/include/EMaterialTypes.h @@ -101,7 +101,7 @@ namespace video EMT_TRANSPARENT_ALPHA_CHANNEL, //! Makes the material transparent based on the texture alpha channel. - /** If the alpha channel value is greater than a certain value (default 127), a + /** If the alpha channel value is greater than 127, a pixel is written to the target, otherwise not. This material does not use alpha blending and is a lot faster than EMT_TRANSPARENT_ALPHA_CHANNEL. It is ideal for drawing @@ -109,12 +109,7 @@ namespace video blurry but sharp. Only first texture is used. If you are using this material with small textures and 3d object, it is a good idea to load the texture in 32 bit mode - (video::IVideoDriver::setTextureCreationFlag()). - By changing SMaterial::MaterialTypeParam you can control the value which is used - to seperate transparent and opaque pixels. The range is 0-1 (corresponding to 0-255 values - for the alpha-channel test). 0 is special and like 0.5 interpreted as 127 - (if you really want no transparency at all use a very small value above 0) - */ + (video::IVideoDriver::setTextureCreationFlag()). */ EMT_TRANSPARENT_ALPHA_CHANNEL_REF, //! Makes the material transparent based on the vertex alpha value. diff --git a/source/Irrlicht/CD3D8MaterialRenderer.h b/source/Irrlicht/CD3D8MaterialRenderer.h index bb1ba011..2b257bb3 100644 --- a/source/Irrlicht/CD3D8MaterialRenderer.h +++ b/source/Irrlicht/CD3D8MaterialRenderer.h @@ -350,9 +350,7 @@ public: { services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - if (material.MaterialType != lastMaterial.MaterialType - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam - || resetAllRenderstates) + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { setTextureColorStage(pID3DDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_CURRENT); @@ -362,7 +360,8 @@ public: pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, material.MaterialTypeParam == 0 ? 127 : material.MaterialTypeParam * 255.f); + // 127 is required by EMT_TRANSPARENT_ALPHA_CHANNEL_REF + pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); } diff --git a/source/Irrlicht/CD3D9MaterialRenderer.h b/source/Irrlicht/CD3D9MaterialRenderer.h index c5e4b825..9241116d 100644 --- a/source/Irrlicht/CD3D9MaterialRenderer.h +++ b/source/Irrlicht/CD3D9MaterialRenderer.h @@ -381,9 +381,7 @@ public: { services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - if (material.MaterialType != lastMaterial.MaterialType - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam - || resetAllRenderstates) + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { setTextureColorStage(pID3DDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_CURRENT); @@ -393,7 +391,8 @@ public: pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, material.MaterialTypeParam == 0 ? 127 : material.MaterialTypeParam * 255.f); + // 127 is required by EMT_TRANSPARENT_ALPHA_CHANNEL_REF + pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); } diff --git a/source/Irrlicht/COpenGLMaterialRenderer.h b/source/Irrlicht/COpenGLMaterialRenderer.h index 1d552841..e4dee3c3 100644 --- a/source/Irrlicht/COpenGLMaterialRenderer.h +++ b/source/Irrlicht/COpenGLMaterialRenderer.h @@ -495,12 +495,10 @@ public: Driver->disableTextures(1); Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - if (material.MaterialType != lastMaterial.MaterialType - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam - || resetAllRenderstates) + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { Driver->getBridgeCalls()->setAlphaTest(true); - Driver->getBridgeCalls()->setAlphaFunc(GL_GREATER, material.MaterialTypeParam == 0 ? 0.5 : material.MaterialTypeParam); + Driver->getBridgeCalls()->setAlphaFunc(GL_GREATER, 0.5f); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } @@ -508,7 +506,7 @@ public: virtual void OnSetBaseMaterial(const SMaterial& material) _IRR_OVERRIDE_ { Driver->getBridgeCalls()->setAlphaTest(true); - Driver->getBridgeCalls()->setAlphaFunc(GL_GREATER, material.MaterialTypeParam == 0 ? 0.5 : material.MaterialTypeParam); + Driver->getBridgeCalls()->setAlphaFunc(GL_GREATER, 0.5f); } virtual void OnUnsetMaterial() _IRR_OVERRIDE_