From 047b45d17269e57c5d62862ecb79bddf0867ea2d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 15 Feb 2021 11:51:20 +0100 Subject: [PATCH] Fix apha value - The alpha value in materials using the Tr format must be inverted - closes https://github.com/assimp/assimp/issues/3645 --- code/AssetLib/Obj/ObjFileMtlImporter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp index 283735912..bf1b70c90 100644 --- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp +++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp @@ -122,8 +122,8 @@ void ObjFileMtlImporter::load() { { ++m_DataIt; getColorRGBA(&m_pModel->m_pCurrentMaterial->ambient); - } else if (*m_DataIt == 'd') // Diffuse color - { + } else if (*m_DataIt == 'd') { + // Diffuse color ++m_DataIt; getColorRGBA(&m_pModel->m_pCurrentMaterial->diffuse); } else if (*m_DataIt == 's') { @@ -144,7 +144,9 @@ void ObjFileMtlImporter::load() { } else if (*m_DataIt == 'r') { // Material transmission alpha value ++m_DataIt; - getFloatValue(m_pModel->m_pCurrentMaterial->alpha); + ai_real d; + getFloatValue(d); + m_pModel->m_pCurrentMaterial->alpha = static_cast(1.0) - d; } m_DataIt = skipLine(m_DataIt, m_DataItEnd, m_uiLine); } break;