From a06d9e858b33d8d61007cf8f997ed15a5ac1e900 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 5 Jan 2018 23:46:23 +0800 Subject: [PATCH] Add some fallback --- src/graphics/material.cpp | 41 ++++++++++++++++++++++++++++++++++----- src/graphics/material.hpp | 4 ---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 509223840..912afad70 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -262,24 +262,36 @@ Material::Material(const XMLNode *node, bool deprecated) bool b = false; node->get("additive", &b); if (b) + { + m_shader_name = "alphablend"; m_shader_type = SHADERTYPE_ADDITIVE; + } b = false; node->get("transparency", &b); if (b) + { + m_shader_name = "alphatest"; m_shader_type = SHADERTYPE_ALPHA_TEST; + } //node->get("lightmap", &m_lightmap); b = false; node->get("alpha", &b); if (b) + { + m_shader_name = "alphablend"; m_shader_type = SHADERTYPE_ALPHA_BLEND; + } b = true; node->get("light", &b); if (!b) + { + m_shader_name = "unlit"; m_shader_type = SHADERTYPE_SOLID_UNLIT; + } b = false; node->get("smooth-reflection", &b); @@ -289,10 +301,26 @@ Material::Material(const XMLNode *node, bool deprecated) if (node->get("compositing", &s)) { - if (s == "blend") m_shader_type = SHADERTYPE_ALPHA_BLEND; - else if (s == "test") m_shader_type = SHADERTYPE_ALPHA_TEST; - else if (s == "additive") m_shader_type = SHADERTYPE_ADDITIVE; - else if (s == "coverage") m_shader_type = SHADERTYPE_ALPHA_TEST; + if (s == "blend") + { + m_shader_name = "alphablend"; + m_shader_type = SHADERTYPE_ALPHA_BLEND; + } + else if (s == "test") + { + m_shader_name = "alphatest"; + m_shader_type = SHADERTYPE_ALPHA_TEST; + } + else if (s == "additive") + { + m_shader_name = "additive"; + m_shader_type = SHADERTYPE_ADDITIVE; + } + else if (s == "coverage") + { + m_shader_name = "alphatest"; + m_shader_type = SHADERTYPE_ALPHA_TEST; + } else if (s != "none") Log::warn("material", "Unknown compositing mode '%s'", s.c_str()); } @@ -380,7 +408,10 @@ Material::Material(const XMLNode *node, bool deprecated) // ---- End backwards compatibility } - m_shader_name = s.empty() ? "solid" : s; + if (m_shader_name == "solid" && !s.empty()) + { + m_shader_name = s; + } if (m_shader_name == "solid") { if (!normal_map_tex.empty()) diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index fa36364b5..80fd86773 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -49,19 +49,15 @@ public: enum ShaderType { SHADERTYPE_SOLID = 0, - SHADERTYPE_SOLID_SKINNED_MESH, SHADERTYPE_ALPHA_TEST, - SHADERTYPE_ALPHA_TEST_SKINNED_MESH, SHADERTYPE_ALPHA_BLEND, SHADERTYPE_ADDITIVE, SHADERTYPE_SOLID_UNLIT, - SHADERTYPE_SOLID_UNLIT_SKINNED_MESH, /** Effect that makes grass wave as in the wind */ SHADERTYPE_VEGETATION, SHADERTYPE_WATER, SHADERTYPE_SPHERE_MAP, SHADERTYPE_NORMAL_MAP, - SHADERTYPE_NORMAL_MAP_SKINNED_MESH, SHADERTYPE_DETAIL_MAP, SHADERTYPE_SPLATTING, SHADERTYPE_COUNT,