From 3274df9923a4c70b96262778cbfb8178c18ee138 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 22 Mar 2016 16:18:51 -0700 Subject: [PATCH] Fixing the missing field for blender translucent map --- libraries/fbx/src/FBXReader.cpp | 5 +++-- libraries/fbx/src/FBXReader_Material.cpp | 8 ++++++-- libraries/model/src/model/Material.cpp | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index b2ede33e01..c3364f90f8 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1098,8 +1098,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else if (type.contains("tex_color_map")) { diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); - } else if (type.contains("transparentcolor")) { // it should be TransparentColor... - // THis is how Maya assign a texture that affect diffuse color AND transparency ? + } else if (type.contains("transparentcolor")) { // Maya way of passing TransparentMap + transparentTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); + } else if (type.contains("transparencyfactor")) { // Blender way of passing TransparentMap transparentTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else if (type.contains("bump")) { bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index fb272a1af9..11c6dad2f2 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -102,16 +102,20 @@ void FBXReader::consolidateFBXMaterials() { detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity()); } - FBXTexture transparentTexture; QString transparentTextureID = transparentTextures.value(material.materialID); + // If PBS Material, systematically bind the albedo texture as transparency texture and check for the alpha channel + if (material.isPBSMaterial) { + transparentTextureID = diffuseTextureID; + } if (!transparentTextureID.isNull()) { transparentTexture = getTexture(transparentTextureID); - material.opacityTexture = transparentTexture; detectDifferentUVs |= (transparentTexture.texcoordSet != 0) || (!transparentTexture.transform.isIdentity()); } + + FBXTexture normalTexture; QString bumpTextureID = bumpTextures.value(material.materialID); QString normalTextureID = normalTextures.value(material.materialID); diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index f1e6b8c2ef..81bc9b40a6 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -84,8 +84,12 @@ void Material::setMetallic(float metallic) { void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textureMap) { if (textureMap) { _key.setMapChannel(channel, (true)); - + if (channel == MaterialKey::ALBEDO_MAP) { + // clear the previous flags whatever they were: + _key.setOpacityMaskMap(false); + _key.setTranslucentMap(false); + if (textureMap->useAlphaChannel()) { if (textureMap->isDefined()) { if (textureMap->getTextureView().isValid()) {