From d6a8b546e4d97f1d6537747e250aeac742ab8694 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 22 Nov 2023 16:18:09 +0100 Subject: [PATCH] Enable clean transparent filter in more cases It was determined that this fixes scaling artifacts that can happen with bilinear, trilinear or anisotropic filtering alone. Since the previous commit did not bring back the relevant setting, we fix this shortcoming by just enabling it in all cases where it is known to help. --- src/client/tile.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/tile.cpp b/src/client/tile.cpp index e04b11621..55a34d432 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -437,6 +437,7 @@ private: bool m_setting_mipmap; bool m_setting_trilinear_filter; bool m_setting_bilinear_filter; + bool m_setting_anisotropic_filter; }; IWritableTextureSource *createTextureSource() @@ -458,6 +459,7 @@ TextureSource::TextureSource() m_setting_mipmap = g_settings->getBool("mip_map"); m_setting_trilinear_filter = g_settings->getBool("trilinear_filter"); m_setting_bilinear_filter = g_settings->getBool("bilinear_filter"); + m_setting_anisotropic_filter = g_settings->getBool("anisotropic_filter"); } TextureSource::~TextureSource() @@ -702,10 +704,9 @@ video::ITexture* TextureSource::getTexture(const std::string &name, u32 *id) video::ITexture* TextureSource::getTextureForMesh(const std::string &name, u32 *id) { // Avoid duplicating texture if it won't actually change - static thread_local bool filter_needed = - m_setting_mipmap || - ((m_setting_trilinear_filter || m_setting_bilinear_filter) && - g_settings->getS32("texture_min_size") > 1); + const bool filter_needed = + m_setting_mipmap || m_setting_trilinear_filter || + m_setting_bilinear_filter || m_setting_anisotropic_filter; if (filter_needed) return getTexture(name + "^[applyfiltersformesh", id); return getTexture(name, id); @@ -1741,7 +1742,8 @@ bool TextureSource::generateImagePart(std::string part_of_name, } // Apply the "clean transparent" filter, if needed - if (m_setting_mipmap) + if (m_setting_mipmap || m_setting_bilinear_filter || + m_setting_trilinear_filter || m_setting_anisotropic_filter) imageCleanTransparent(baseimg, 127); /* Upscale textures to user's requested minimum size. This is a trick to make