diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 1c66062e0..48c09b769 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -619,6 +619,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) infostream << "GenericCAO::addToScene(): " << m_prop.visual << std::endl; + m_material_type_param = 0.5f; // May cut off alpha < 128 depending on m_material_type + if (m_enable_shaders) { IShaderSource *shader_source = m_client->getShaderSource(); MaterialType material_type; @@ -633,8 +635,12 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL); m_material_type = shader_source->getShaderInfo(shader_id).material; } else { - m_material_type = (m_prop.use_texture_alpha) ? - video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + if (m_prop.use_texture_alpha) { + m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + m_material_type_param = 1.0f / 256.f; // minimal alpha for texture rendering + } else { + m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + } } auto grabMatrixNode = [this] { @@ -1340,7 +1346,7 @@ void GenericCAO::updateTextures(std::string mod) video::SMaterial &material = m_spritenode->getMaterial(0); material.MaterialType = m_material_type; - material.MaterialTypeParam = 0.5f; + material.MaterialTypeParam = m_material_type_param; material.setTexture(0, tsrc->getTextureForMesh(texturestring)); // This allows setting per-material colors. However, until a real lighting @@ -1376,7 +1382,7 @@ void GenericCAO::updateTextures(std::string mod) // Set material flags and texture video::SMaterial &material = m_animated_meshnode->getMaterial(i); material.MaterialType = m_material_type; - material.MaterialTypeParam = 0.5f; + material.MaterialTypeParam = m_material_type_param; material.TextureLayers[0].Texture = texture; material.Lighting = true; material.BackfaceCulling = m_prop.backface_culling; @@ -1420,7 +1426,7 @@ void GenericCAO::updateTextures(std::string mod) // Set material flags and texture video::SMaterial &material = m_meshnode->getMaterial(i); material.MaterialType = m_material_type; - material.MaterialTypeParam = 0.5f; + material.MaterialTypeParam = m_material_type_param; material.Lighting = false; material.setTexture(0, tsrc->getTextureForMesh(texturestring)); material.getTextureMatrix(0).makeIdentity(); diff --git a/src/client/content_cao.h b/src/client/content_cao.h index b090cdc08..8180ceb14 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -130,6 +130,7 @@ private: bool m_is_visible = false; // Material video::E_MATERIAL_TYPE m_material_type; + f32 m_material_type_param; // Settings bool m_enable_shaders = false;