diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 9a0e0cca1..a3940e9ea 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -424,7 +424,20 @@ void glTF2Exporter::ExportMaterials() mat->Get(AI_MATKEY_TWOSIDED, m->doubleSided); mat->Get(AI_MATKEY_GLTF_ALPHACUTOFF, m->alphaCutoff); - if (mat->Get(AI_MATKEY_GLTF_ALPHAMODE, m->alphaMode) != AI_SUCCESS) { + bool foundAlphaMode = false; + for (size_t i = 0; i < mat->mNumProperties; ++i) { + aiMaterialProperty *prop = mat->mProperties[i]; + if (prop->mKey != aiString("$mat.gltf.alphaMode")) + continue; + + std::string alphaMode; + for (size_t c = 0; c < prop->mDataLength; ++c) + alphaMode += prop->mData[c]; + m->alphaMode = alphaMode; + foundAlphaMode = true; + } + + if (!foundAlphaMode) { float opacity; if (mat->Get(AI_MATKEY_OPACITY, opacity) == AI_SUCCESS) { @@ -435,7 +448,7 @@ void glTF2Exporter::ExportMaterials() } } - bool hasPbrSpecularGlossiness; + bool hasPbrSpecularGlossiness = false; mat->Get(AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS, hasPbrSpecularGlossiness); if (hasPbrSpecularGlossiness) {