From 34eebd3de4c373f8c55b381f49847ddd81134c3f Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Wed, 11 Nov 2020 00:30:56 +0700 Subject: [PATCH] fix: Improve mesh transparency identification This fixes certain visual artifacts, e.g. in danm16. --- src/render/mesh/modelmesh.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/render/mesh/modelmesh.cpp b/src/render/mesh/modelmesh.cpp index 13dd4151..3a96385a 100644 --- a/src/render/mesh/modelmesh.cpp +++ b/src/render/mesh/modelmesh.cpp @@ -88,12 +88,17 @@ bool ModelMesh::shouldRender() const { } bool ModelMesh::isTransparent() const { - if (!_diffuse || _envmap) return false; + if (_transparency > 0) return true; + + TextureFeatures features = _diffuse->features(); + if (features.blending == TextureBlending::Additive) return true; + + if (_envmap || _bumpyShiny || _bumpmap) return false; PixelFormat format = _diffuse->pixelFormat(); - TextureFeatures features = _diffuse->features(); + if (format == PixelFormat::RGB || format == PixelFormat::BGR || format == PixelFormat::DXT1) return false; - return features.blending == TextureBlending::Additive || format == PixelFormat::DXT5 || format == PixelFormat::BGRA; + return true; } bool ModelMesh::hasDiffuseTexture() const {