add support for khr_materials_sheen during export
parent
0fdda99ea1
commit
aa9d6ce7b7
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* glTF Extensions Support:
|
* glTF Extensions Support:
|
||||||
* KHR_materials_pbrSpecularGlossiness: full
|
* KHR_materials_pbrSpecularGlossiness: full
|
||||||
* KHR_materials_unlit: full
|
* KHR_materials_unlit: full
|
||||||
|
* KHR_materials_sheen: full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSETWRITER_H_INC
|
#ifndef GLTF2ASSETWRITER_H_INC
|
||||||
#define GLTF2ASSETWRITER_H_INC
|
#define GLTF2ASSETWRITER_H_INC
|
||||||
|
|
|
@ -417,6 +417,25 @@ namespace glTF2 {
|
||||||
exts.AddMember("KHR_materials_unlit", unlit, w.mAl);
|
exts.AddMember("KHR_materials_unlit", unlit, w.mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.materialSheen.isPresent) {
|
||||||
|
Value materialSheen(rapidjson::Type::kObjectType);
|
||||||
|
|
||||||
|
MaterialSheen &sheen = m.materialSheen.value;
|
||||||
|
|
||||||
|
WriteVec(materialSheen, sheen.sheenColorFactor, "sheenColorFactor", defaultSheenFactor, w.mAl);
|
||||||
|
|
||||||
|
if (sheen.sheenRoughnessFactor != 0.f) {
|
||||||
|
WriteFloat(materialSheen, sheen.sheenRoughnessFactor, "sheenRoughnessFactor", w.mAl);
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteTex(materialSheen, sheen.sheenColorTexture, "sheenColorTexture", w.mAl);
|
||||||
|
WriteTex(materialSheen, sheen.sheenRoughnessTexture, "sheenRoughnessTexture", w.mAl);
|
||||||
|
|
||||||
|
if (!materialSheen.ObjectEmpty()) {
|
||||||
|
exts.AddMember("KHR_materials_sheen", materialSheen, w.mAl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exts.ObjectEmpty()) {
|
if (!exts.ObjectEmpty()) {
|
||||||
obj.AddMember("extensions", exts, w.mAl);
|
obj.AddMember("extensions", exts, w.mAl);
|
||||||
}
|
}
|
||||||
|
@ -808,6 +827,10 @@ namespace glTF2 {
|
||||||
if (this->mAsset.extensionsUsed.KHR_materials_unlit) {
|
if (this->mAsset.extensionsUsed.KHR_materials_unlit) {
|
||||||
exts.PushBack(StringRef("KHR_materials_unlit"), mAl);
|
exts.PushBack(StringRef("KHR_materials_unlit"), mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->mAsset.extensionsUsed.KHR_materials_sheen) {
|
||||||
|
exts.PushBack(StringRef("KHR_materials_sheen"), mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exts.Empty())
|
if (!exts.Empty())
|
||||||
|
|
|
@ -714,6 +714,22 @@ void glTF2Exporter::ExportMaterials()
|
||||||
mAsset->extensionsUsed.KHR_materials_unlit = true;
|
mAsset->extensionsUsed.KHR_materials_unlit = true;
|
||||||
m->unlit = true;
|
m->unlit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasMaterialSheen = false;
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_SHEEN, hasMaterialSheen);
|
||||||
|
|
||||||
|
if (hasMaterialSheen) {
|
||||||
|
mAsset->extensionsUsed.KHR_materials_sheen = true;
|
||||||
|
|
||||||
|
MaterialSheen sheen;
|
||||||
|
|
||||||
|
GetMatColor(mat, sheen.sheenColorFactor, AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_FACTOR);
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_FACTOR, sheen.sheenRoughnessFactor);
|
||||||
|
GetMatTex(mat, sheen.sheenColorTexture, AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_TEXTURE);
|
||||||
|
GetMatTex(mat, sheen.sheenRoughnessTexture, AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_TEXTURE);
|
||||||
|
|
||||||
|
m->materialSheen = Nullable<MaterialSheen>(sheen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue