Add KHR_materials_clearcoat during export
parent
f8c63d874b
commit
197bf1e617
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* KHR_materials_pbrSpecularGlossiness: full
|
* KHR_materials_pbrSpecularGlossiness: full
|
||||||
* KHR_materials_unlit: full
|
* KHR_materials_unlit: full
|
||||||
* KHR_materials_sheen: full
|
* KHR_materials_sheen: full
|
||||||
|
* KHR_materials_clearcoat: full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSETWRITER_H_INC
|
#ifndef GLTF2ASSETWRITER_H_INC
|
||||||
#define GLTF2ASSETWRITER_H_INC
|
#define GLTF2ASSETWRITER_H_INC
|
||||||
|
|
|
@ -436,6 +436,28 @@ namespace glTF2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.materialClearcoat.isPresent) {
|
||||||
|
Value materialClearcoat(rapidjson::Type::kObjectType);
|
||||||
|
|
||||||
|
MaterialClearcoat &clearcoat = m.materialClearcoat.value;
|
||||||
|
|
||||||
|
if (clearcoat.clearcoatFactor != 0.f) {
|
||||||
|
WriteFloat(materialClearcoat, clearcoat.clearcoatFactor, "clearcoatFactor", w.mAl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clearcoat.clearcoatRoughnessFactor != 0.f) {
|
||||||
|
WriteFloat(materialClearcoat, clearcoat.clearcoatRoughnessFactor, "clearcoatRoughnessFactor", w.mAl);
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteTex(materialClearcoat, clearcoat.clearcoatTexture, "clearcoatTexture", w.mAl);
|
||||||
|
WriteTex(materialClearcoat, clearcoat.clearcoatRoughnessTexture, "clearcoatRoughnessTexture", w.mAl);
|
||||||
|
WriteTex(materialClearcoat, clearcoat.clearcoatNormalTexture, "clearcoatNormalTexture", w.mAl);
|
||||||
|
|
||||||
|
if (!materialClearcoat.ObjectEmpty()) {
|
||||||
|
exts.AddMember("KHR_materials_clearcoat", materialClearcoat, w.mAl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exts.ObjectEmpty()) {
|
if (!exts.ObjectEmpty()) {
|
||||||
obj.AddMember("extensions", exts, w.mAl);
|
obj.AddMember("extensions", exts, w.mAl);
|
||||||
}
|
}
|
||||||
|
@ -831,6 +853,10 @@ namespace glTF2 {
|
||||||
if (this->mAsset.extensionsUsed.KHR_materials_sheen) {
|
if (this->mAsset.extensionsUsed.KHR_materials_sheen) {
|
||||||
exts.PushBack(StringRef("KHR_materials_sheen"), mAl);
|
exts.PushBack(StringRef("KHR_materials_sheen"), mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->mAsset.extensionsUsed.KHR_materials_clearcoat) {
|
||||||
|
exts.PushBack(StringRef("KHR_materials_clearcoat"), mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exts.Empty())
|
if (!exts.Empty())
|
||||||
|
|
|
@ -730,6 +730,23 @@ void glTF2Exporter::ExportMaterials()
|
||||||
|
|
||||||
m->materialSheen = Nullable<MaterialSheen>(sheen);
|
m->materialSheen = Nullable<MaterialSheen>(sheen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasMaterialClearcoat = false;
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_CLEARCOAT, hasMaterialClearcoat);
|
||||||
|
|
||||||
|
if (hasMaterialClearcoat) {
|
||||||
|
mAsset->extensionsUsed.KHR_materials_clearcoat= true;
|
||||||
|
|
||||||
|
MaterialClearcoat clearcoat;
|
||||||
|
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_FACTOR, clearcoat.clearcoatFactor);
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_FACTOR, clearcoat.clearcoatRoughnessFactor);
|
||||||
|
GetMatTex(mat, clearcoat.clearcoatTexture, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE);
|
||||||
|
GetMatTex(mat, clearcoat.clearcoatRoughnessTexture, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE);
|
||||||
|
GetMatTex(mat, clearcoat.clearcoatNormalTexture, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE);
|
||||||
|
|
||||||
|
m->materialClearcoat = Nullable<MaterialClearcoat>(clearcoat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue