Fix alphaMode of glb exporting
Only export alphaMode as BLEND when there are transparent parts.master
parent
9e7f39e0d4
commit
c4639d77ae
|
@ -37,6 +37,7 @@ Document::Document() :
|
|||
textureMetalnessImage(nullptr),
|
||||
textureRoughnessImage(nullptr),
|
||||
textureAmbientOcclusionImage(nullptr),
|
||||
textureHasTransparencySettings(false),
|
||||
rigType(RigType::None),
|
||||
weldEnabled(true),
|
||||
polyCount(PolyCount::Original),
|
||||
|
@ -2087,6 +2088,8 @@ void Document::textureReady()
|
|||
delete m_resultTextureMesh;
|
||||
m_resultTextureMesh = m_textureGenerator->takeResultMesh();
|
||||
|
||||
textureHasTransparencySettings = m_textureGenerator->hasTransparencySettings();
|
||||
|
||||
//addToolToMesh(m_resultTextureMesh);
|
||||
|
||||
m_textureImageUpdateVersion++;
|
||||
|
|
|
@ -534,6 +534,7 @@ public: // need initialize
|
|||
QImage *textureMetalnessImage;
|
||||
QImage *textureRoughnessImage;
|
||||
QImage *textureAmbientOcclusionImage;
|
||||
bool textureHasTransparencySettings;
|
||||
RigType rigType;
|
||||
bool weldEnabled;
|
||||
PolyCount polyCount;
|
||||
|
|
|
@ -1703,6 +1703,7 @@ void DocumentWindow::exportGlbToFilename(const QString &filename)
|
|||
exportMotions.push_back({motion->name, motion->jointNodeTrees});
|
||||
}
|
||||
GlbFileWriter glbFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename,
|
||||
m_document->textureHasTransparencySettings,
|
||||
m_document->textureImage, m_document->textureNormalImage, m_document->textureMetalnessRoughnessAmbientOcclusionImage, exportMotions.empty() ? nullptr : &exportMotions);
|
||||
glbFileWriter.save();
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
|
|
@ -26,6 +26,7 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome,
|
|||
const std::vector<RiggerBone> *resultRigBones,
|
||||
const std::map<int, RiggerVertexWeights> *resultRigWeights,
|
||||
const QString &filename,
|
||||
bool textureHasTransparencySettings,
|
||||
QImage *textureImage,
|
||||
QImage *normalImage,
|
||||
QImage *ormImage,
|
||||
|
@ -169,7 +170,8 @@ GlbFileWriter::GlbFileWriter(Outcome &outcome,
|
|||
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["baseColorTexture"]["index"] = textureIndex++;
|
||||
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["metallicFactor"] = MeshLoader::m_defaultMetalness;
|
||||
m_json["materials"][primitiveIndex]["pbrMetallicRoughness"]["roughnessFactor"] = MeshLoader::m_defaultRoughness;
|
||||
m_json["materials"][primitiveIndex]["alphaMode"] = "BLEND";
|
||||
if (textureHasTransparencySettings)
|
||||
m_json["materials"][primitiveIndex]["alphaMode"] = "BLEND";
|
||||
if (normalImage) {
|
||||
m_json["materials"][primitiveIndex]["normalTexture"]["index"] = textureIndex++;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
const std::vector<RiggerBone> *resultRigBones,
|
||||
const std::map<int, RiggerVertexWeights> *resultRigWeights,
|
||||
const QString &filename,
|
||||
bool textureHasTransparencySettings,
|
||||
QImage *textureImage=nullptr,
|
||||
QImage *normalImage=nullptr,
|
||||
QImage *ormImage=nullptr,
|
||||
|
|
|
@ -24,7 +24,8 @@ TextureGenerator::TextureGenerator(const Outcome &outcome, Snapshot *snapshot) :
|
|||
m_resultTextureMetalnessImage(nullptr),
|
||||
m_resultTextureAmbientOcclusionImage(nullptr),
|
||||
m_resultMesh(nullptr),
|
||||
m_snapshot(snapshot)
|
||||
m_snapshot(snapshot),
|
||||
m_hasTransparencySettings(false)
|
||||
{
|
||||
m_outcome = new Outcome();
|
||||
*m_outcome = outcome;
|
||||
|
@ -210,6 +211,11 @@ void TextureGenerator::prepare()
|
|||
}
|
||||
}
|
||||
|
||||
bool TextureGenerator::hasTransparencySettings()
|
||||
{
|
||||
return m_hasTransparencySettings;
|
||||
}
|
||||
|
||||
void TextureGenerator::generate()
|
||||
{
|
||||
m_resultMesh = new MeshLoader(*m_outcome);
|
||||
|
@ -240,6 +246,10 @@ void TextureGenerator::generate()
|
|||
std::map<std::pair<QUuid, QUuid>, const OutcomeNode *> nodeMap;
|
||||
std::map<QUuid, float> partColorSolubilityMap;
|
||||
for (const auto &item: m_outcome->nodes) {
|
||||
if (!m_hasTransparencySettings) {
|
||||
if (!qFuzzyCompare(1.0, item.color.alphaF()))
|
||||
m_hasTransparencySettings = true;
|
||||
}
|
||||
nodeMap.insert({{item.partId, item.nodeId}, &item});
|
||||
partColorMap.insert({item.partId, item.color});
|
||||
partColorSolubilityMap.insert({item.partId, item.colorSolubility});
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
QImage *takeResultTextureAmbientOcclusionImage();
|
||||
Outcome *takeOutcome();
|
||||
MeshLoader *takeResultMesh();
|
||||
bool hasTransparencySettings();
|
||||
void addPartColorMap(QUuid partId, const QImage *image, float tileScale);
|
||||
void addPartNormalMap(QUuid partId, const QImage *image, float tileScale);
|
||||
void addPartMetalnessMap(QUuid partId, const QImage *image, float tileScale);
|
||||
|
@ -60,6 +61,7 @@ private:
|
|||
std::map<QUuid, std::pair<QImage, float>> m_partAmbientOcclusionTextureMap;
|
||||
std::set<QUuid> m_countershadedPartIds;
|
||||
Snapshot *m_snapshot;
|
||||
bool m_hasTransparencySettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue