mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 18:42:12 +02:00
Fix for transparent textures not being rendered with opacity
This commit is contained in:
parent
eb5a950f85
commit
0ffcf437e9
5 changed files with 25 additions and 6 deletions
|
@ -1035,7 +1035,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
|
||||
} else if (type.contains("transparentcolor")) { // it should be TransparentColor...
|
||||
// THis is how Maya assign a texture that affect diffuse color AND transparency ?
|
||||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
opacityTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("bump")) {
|
||||
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("normal")) {
|
||||
|
|
|
@ -402,6 +402,7 @@ public:
|
|||
QHash<QString, QString> specularTextures;
|
||||
QHash<QString, QString> emissiveTextures;
|
||||
QHash<QString, QString> ambientTextures;
|
||||
QHash<QString, QString> opacityTextures;
|
||||
|
||||
QHash<QString, FBXMaterial> _fbxMaterials;
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ void FBXReader::consolidateFBXMaterials() {
|
|||
FBXTexture diffuseTexture;
|
||||
QString diffuseTextureID = diffuseTextures.value(material.materialID);
|
||||
if (!diffuseTextureID.isNull()) {
|
||||
diffuseTexture = getTexture(diffuseTextureID);
|
||||
|
||||
diffuseTexture = getTexture(diffuseTextureID);
|
||||
// FBX files generated by 3DSMax have an intermediate texture parent, apparently
|
||||
foreach (const QString& childTextureID, _connectionChildMap.values(diffuseTextureID)) {
|
||||
if (_textureFilenames.contains(childTextureID)) {
|
||||
|
@ -80,10 +79,16 @@ void FBXReader::consolidateFBXMaterials() {
|
|||
}
|
||||
|
||||
material.diffuseTexture = diffuseTexture;
|
||||
material.opacityTexture = diffuseTexture;
|
||||
|
||||
detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity());
|
||||
}
|
||||
|
||||
FBXTexture opacityTexture;
|
||||
QString opacityTextureID = opacityTextures.value(material.materialID);
|
||||
if (!opacityTextureID.isNull()) {
|
||||
opacityTexture = getTexture(opacityTextureID);
|
||||
material.opacityTexture = opacityTexture;
|
||||
}
|
||||
|
||||
|
||||
FBXTexture normalTexture;
|
||||
QString bumpTextureID = bumpTextures.value(material.materialID);
|
||||
|
|
|
@ -155,6 +155,8 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
|
|||
material->specularTexture = textureCache->getTexture(url);
|
||||
} else if (material->emissiveTextureName == name) {
|
||||
material->emissiveTexture = textureCache->getTexture(url);
|
||||
} else if (material->opacityTextureName == name) {
|
||||
material->opacityTexture = textureCache->getTexture(url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -285,7 +287,16 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
|
|||
diffuseMap->setTextureTransform(material.diffuseTexture.transform);
|
||||
|
||||
material._material->setTextureMap(model::MaterialKey::DIFFUSE_MAP, diffuseMap);
|
||||
material._material->setTextureMap(model::MaterialKey::TRANSPARENT_MAP, diffuseMap);
|
||||
}
|
||||
if (!material.opacityTexture.filename.isEmpty()) {
|
||||
networkMaterial->opacityTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.opacityTexture.filename)), DEFAULT_TEXTURE, material.opacityTexture.content);
|
||||
networkMaterial->opacityTextureName = material.opacityTexture.name;
|
||||
|
||||
auto opacityMap = model::TextureMapPointer(new model::TextureMap());
|
||||
opacityMap->setTextureSource(networkMaterial->opacityTexture->_textureSource);
|
||||
opacityMap->setTextureTransform(material.opacityTexture.transform);
|
||||
|
||||
material._material->setTextureMap(model::MaterialKey::TRANSPARENT_MAP, opacityMap);
|
||||
}
|
||||
if (!material.normalTexture.filename.isEmpty()) {
|
||||
networkMaterial->normalTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.normalTexture.filename)), (material.normalTexture.isBumpmap ? BUMP_TEXTURE : NORMAL_TEXTURE), material.normalTexture.content);
|
||||
|
|
|
@ -182,6 +182,8 @@ public:
|
|||
QSharedPointer<NetworkTexture> specularTexture;
|
||||
QString emissiveTextureName;
|
||||
QSharedPointer<NetworkTexture> emissiveTexture;
|
||||
QString opacityTextureName;
|
||||
QSharedPointer<NetworkTexture> opacityTexture;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue