diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index a0403ce1b..5a15960cf 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -62,7 +62,6 @@ Material::Material(const XMLNode *node, bool deprecated) m_shader_type = SHADERTYPE_SOLID; m_deprecated = deprecated; m_installed = false; - m_srgb_texture = true; node->get("name", &m_texname); if (m_texname=="") @@ -402,11 +401,11 @@ Material::Material(const XMLNode *node, bool deprecated) m_high_tire_adhesion = true; } // Material //----------------------------------------------------------------------------- -video::ITexture* Material::getTexture() +video::ITexture* Material::getTexture(bool srgb, bool premul_alpha) { if (!m_installed) { - install(); + install(srgb, premul_alpha); } return m_texture; } // getTexture @@ -417,12 +416,10 @@ video::ITexture* Material::getTexture() * \param is_full_path If the fname contains the full path. */ Material::Material(const std::string& fname, bool is_full_path, - bool complain_if_not_found, bool load_texture, - bool srgb) + bool complain_if_not_found, bool load_texture) { m_deprecated = false; m_installed = false; - m_srgb_texture = srgb; init(); if (is_full_path) @@ -493,30 +490,30 @@ void Material::init() } // init //----------------------------------------------------------------------------- -void Material::install() +void Material::install(bool srgb, bool premul_alpha) { // Don't load a texture that are not supposed to be loaded automatically if (m_installed) return; m_installed = true; - if (m_complain_if_not_found && m_full_path.size() == 0) + if (StringUtils::getPath(m_full_path).empty()) { - Log::error("material", "Cannot find texture '%s'.", m_texname.c_str()); + if (m_complain_if_not_found) + { + Log::error("material", "Cannot find texture '%s'.", + m_texname.c_str()); + } m_texture = NULL; } - else { #ifndef SERVER_ONLY if (CVS->isGLSL()) { m_texture = STKTexManager::getInstance()->getTexture - (m_full_path, m_srgb_texture, - m_shader_type == SHADERTYPE_ALPHA_BLEND || - m_shader_type == SHADERTYPE_ADDITIVE ? - true : false/*premul_alpha*/, - false/*set_material*/, m_srgb_texture/*mesh_tex*/); + (m_full_path, srgb, premul_alpha, false/*set_material*/, + srgb/*mesh_tex*/); } else #endif diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index d0080dcf1..c8df14cff 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -266,11 +266,8 @@ private: bool m_installed; - /** If Layer 1 texture is srgb. */ - bool m_srgb_texture; - void init (); - void install (); + void install (bool srgb = false, bool premul_alpha = false); void initCustomSFX(const XMLNode *sfx); void initParticlesEffect(const XMLNode *node); @@ -279,8 +276,7 @@ public: Material(const std::string& fname, bool is_full_path=false, bool complain_if_not_found=true, - bool load_texture = true, - bool srgb = false); + bool load_texture = true); ~Material (); void unloadTexture(); @@ -294,7 +290,7 @@ public: void isInitiallyHidden(scene::IMeshBuffer* who); /** Returns the ITexture associated with this material. */ - video::ITexture *getTexture(); + video::ITexture *getTexture(bool srgb = true, bool premul_alpha = false); // ------------------------------------------------------------------------ bool isIgnore () const { return m_ignore; } // ------------------------------------------------------------------------ diff --git a/src/graphics/material_manager.cpp b/src/graphics/material_manager.cpp index c49862f42..2e7e3d907 100644 --- a/src/graphics/material_manager.cpp +++ b/src/graphics/material_manager.cpp @@ -335,8 +335,7 @@ Material *MaterialManager::getMaterial(const std::string& fname, bool is_full_path, bool make_permanent, bool complain_if_not_found, - bool strip_path, - bool srgb) + bool strip_path) { if(fname=="") { diff --git a/src/graphics/material_manager.hpp b/src/graphics/material_manager.hpp index 6d7d8fd32..bd113008d 100644 --- a/src/graphics/material_manager.hpp +++ b/src/graphics/material_manager.hpp @@ -76,8 +76,7 @@ public: bool is_full_path=false, bool make_permanent=false, bool complain_if_not_found=true, - bool strip_path=true, - bool srgb=false); + bool strip_path=true); void addSharedMaterial(const std::string& filename, bool deprecated = false); bool pushTempMaterial (const std::string& filename, bool deprecated = false); bool pushTempMaterial (const XMLNode *root, const std::string& filename, bool deprecated = false); diff --git a/src/graphics/particle_kind.cpp b/src/graphics/particle_kind.cpp index 0833a55c8..662d63dfb 100644 --- a/src/graphics/particle_kind.cpp +++ b/src/graphics/particle_kind.cpp @@ -257,7 +257,7 @@ Material* ParticleKind::getMaterial() const if (material_manager->hasMaterial(m_material_file)) { Material* material = material_manager->getMaterial(m_material_file); - if (material->getTexture() == NULL) + if (material->getTexture(true/*srgb*/, true/*premul_alpha*/) == NULL) { throw std::runtime_error("[ParticleKind] Cannot locate file " + m_material_file); } diff --git a/src/graphics/stk_tex_manager.cpp b/src/graphics/stk_tex_manager.cpp index 90c021879..299829831 100644 --- a/src/graphics/stk_tex_manager.cpp +++ b/src/graphics/stk_tex_manager.cpp @@ -108,10 +108,12 @@ void STKTexManager::addTexture(STKTexture* t) } // addTexture // ---------------------------------------------------------------------------- -void STKTexManager::dumpAllTexture() +void STKTexManager::dumpAllTexture(bool mesh_texture) { for (auto p : m_all_textures) { + if (!p.second || (mesh_texture && !p.second->isMeshTexture())) + continue; Log::info("STKTexManager", "%s loc: %p", p.first.c_str(), p.second); } } // dumpAllTexture diff --git a/src/graphics/stk_tex_manager.hpp b/src/graphics/stk_tex_manager.hpp index ae352a77c..b66b927cd 100644 --- a/src/graphics/stk_tex_manager.hpp +++ b/src/graphics/stk_tex_manager.hpp @@ -53,7 +53,7 @@ public: // ------------------------------------------------------------------------ void removeTexture(STKTexture* t); // ------------------------------------------------------------------------ - void dumpAllTexture(); + void dumpAllTexture(bool mesh_texture); // ------------------------------------------------------------------------ int dumpTextureUsage(); // ------------------------------------------------------------------------