mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 04:08:56 +02:00
Trying to support ambient occlusion map from blender
This commit is contained in:
parent
e92b4029b2
commit
f569169662
3 changed files with 24 additions and 1 deletions
|
@ -924,6 +924,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
// material.emissiveColor = getVec3(property.properties, index);
|
||||
// material.emissiveFactor = 1.0;
|
||||
|
||||
} else if (property.properties.at(0) == "AmbientFactor") {
|
||||
material.ambientFactor = property.properties.at(index).value<double>();
|
||||
// Detected just for BLender AO vs lightmap
|
||||
} else if (property.properties.at(0) == "Shininess") {
|
||||
material.shininess = property.properties.at(index).value<double>();
|
||||
|
||||
|
@ -1126,8 +1129,10 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("tex_emissive_map")) {
|
||||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("ambient")) {
|
||||
} else if (type.contains("ambientcolor")) {
|
||||
ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("ambientfactor")) {
|
||||
ambientFactorTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("tex_ao_map")) {
|
||||
occlusionTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
float metallic{ 0.0f };
|
||||
float roughness{ 1.0f };
|
||||
float emissiveIntensity{ 1.0f };
|
||||
float ambientFactor{ 1.0f };
|
||||
|
||||
QString materialID;
|
||||
QString name;
|
||||
|
@ -436,6 +437,7 @@ public:
|
|||
QHash<QString, QString> shininessTextures;
|
||||
QHash<QString, QString> emissiveTextures;
|
||||
QHash<QString, QString> ambientTextures;
|
||||
QHash<QString, QString> ambientFactorTextures;
|
||||
QHash<QString, QString> occlusionTextures;
|
||||
|
||||
QHash<QString, FBXMaterial> _fbxMaterials;
|
||||
|
|
|
@ -175,6 +175,14 @@ void FBXReader::consolidateFBXMaterials() {
|
|||
|
||||
FBXTexture occlusionTexture;
|
||||
QString occlusionTextureID = occlusionTextures.value(material.materialID);
|
||||
if (occlusionTextureID.isNull()) {
|
||||
// 2nd chance
|
||||
// For blender we use the ambient factor texture ONLY if the ambientFactor value is set to 0
|
||||
if (material.ambientFactor == 0.0) {
|
||||
occlusionTextureID = ambientFactorTextures.value(material.materialID);
|
||||
}
|
||||
}
|
||||
|
||||
if (!occlusionTextureID.isNull()) {
|
||||
occlusionTexture = getTexture(occlusionTextureID);
|
||||
detectDifferentUVs |= (occlusionTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
|
||||
|
@ -187,6 +195,14 @@ void FBXReader::consolidateFBXMaterials() {
|
|||
|
||||
FBXTexture ambientTexture;
|
||||
QString ambientTextureID = ambientTextures.value(material.materialID);
|
||||
if (ambientTextureID.isNull()) {
|
||||
// 2nd chance
|
||||
// For blender we use the ambient factor texture ONLY if the ambientFactor value is set to 1
|
||||
if (material.ambientFactor == 1.0) {
|
||||
ambientTextureID = ambientFactorTextures.value(material.materialID);
|
||||
}
|
||||
}
|
||||
|
||||
if (_loadLightmaps && !ambientTextureID.isNull()) {
|
||||
ambientTexture = getTexture(ambientTextureID);
|
||||
detectDifferentUVs |= (ambientTexture.texcoordSet != 0) || (!ambientTexture.transform.isIdentity());
|
||||
|
|
Loading…
Reference in a new issue