glTF2: Improved support for AI_MATKEY_OPACITY
- Exporter: Writing opacity to pbrMetallicRoughness.baseColorFactor[3] even when alphaMode is set - Importer: Setting AI_MATKEY_OPACITY from pbrMetallicRoughness.baseColorFactor[3]pull/3967/head
parent
bd9b28bc45
commit
0e41efb050
|
@ -778,12 +778,8 @@ void glTF2Exporter::ExportMaterials()
|
||||||
mat.Get(AI_MATKEY_TWOSIDED, m->doubleSided);
|
mat.Get(AI_MATKEY_TWOSIDED, m->doubleSided);
|
||||||
mat.Get(AI_MATKEY_GLTF_ALPHACUTOFF, m->alphaCutoff);
|
mat.Get(AI_MATKEY_GLTF_ALPHACUTOFF, m->alphaCutoff);
|
||||||
|
|
||||||
aiString alphaMode;
|
|
||||||
|
|
||||||
if (mat.Get(AI_MATKEY_GLTF_ALPHAMODE, alphaMode) == AI_SUCCESS) {
|
|
||||||
m->alphaMode = alphaMode.C_Str();
|
|
||||||
} else {
|
|
||||||
float opacity;
|
float opacity;
|
||||||
|
aiString alphaMode;
|
||||||
|
|
||||||
if (mat.Get(AI_MATKEY_OPACITY, opacity) == AI_SUCCESS) {
|
if (mat.Get(AI_MATKEY_OPACITY, opacity) == AI_SUCCESS) {
|
||||||
if (opacity < 1) {
|
if (opacity < 1) {
|
||||||
|
@ -791,6 +787,8 @@ void glTF2Exporter::ExportMaterials()
|
||||||
m->pbrMetallicRoughness.baseColorFactor[3] *= opacity;
|
m->pbrMetallicRoughness.baseColorFactor[3] *= opacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mat.Get(AI_MATKEY_GLTF_ALPHAMODE, alphaMode) == AI_SUCCESS) {
|
||||||
|
m->alphaMode = alphaMode.C_Str();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -267,6 +267,7 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
|
||||||
SetMaterialColorProperty(r, mat.emissiveFactor, aimat, AI_MATKEY_COLOR_EMISSIVE);
|
SetMaterialColorProperty(r, mat.emissiveFactor, aimat, AI_MATKEY_COLOR_EMISSIVE);
|
||||||
|
|
||||||
aimat->AddProperty(&mat.doubleSided, 1, AI_MATKEY_TWOSIDED);
|
aimat->AddProperty(&mat.doubleSided, 1, AI_MATKEY_TWOSIDED);
|
||||||
|
aimat->AddProperty(&mat.pbrMetallicRoughness.baseColorFactor[3], 1, AI_MATKEY_OPACITY);
|
||||||
|
|
||||||
aiString alphaMode(mat.alphaMode);
|
aiString alphaMode(mat.alphaMode);
|
||||||
aimat->AddProperty(&alphaMode, AI_MATKEY_GLTF_ALPHAMODE);
|
aimat->AddProperty(&alphaMode, AI_MATKEY_GLTF_ALPHAMODE);
|
||||||
|
|
Loading…
Reference in New Issue