Add KHR_materials_transmission during export
parent
2b097c1e73
commit
383c97e380
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* KHR_materials_unlit: full
|
* KHR_materials_unlit: full
|
||||||
* KHR_materials_sheen: full
|
* KHR_materials_sheen: full
|
||||||
* KHR_materials_clearcoat: full
|
* KHR_materials_clearcoat: full
|
||||||
|
* KHR_materials_transmission: full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSETWRITER_H_INC
|
#ifndef GLTF2ASSETWRITER_H_INC
|
||||||
#define GLTF2ASSETWRITER_H_INC
|
#define GLTF2ASSETWRITER_H_INC
|
||||||
|
|
|
@ -458,6 +458,22 @@ namespace glTF2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.materialTransmission.isPresent) {
|
||||||
|
Value materialTransmission(rapidjson::Type::kObjectType);
|
||||||
|
|
||||||
|
MaterialTransmission &transmission = m.materialTransmission.value;
|
||||||
|
|
||||||
|
if (transmission.transmissionFactor != 0.f) {
|
||||||
|
WriteFloat(materialTransmission, transmission.transmissionFactor, "transmissionFactor", w.mAl);
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteTex(materialTransmission, transmission.transmissionTexture, "transmissionTexture", w.mAl);
|
||||||
|
|
||||||
|
if (!materialTransmission.ObjectEmpty()) {
|
||||||
|
exts.AddMember("KHR_materials_transmission", materialTransmission, w.mAl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exts.ObjectEmpty()) {
|
if (!exts.ObjectEmpty()) {
|
||||||
obj.AddMember("extensions", exts, w.mAl);
|
obj.AddMember("extensions", exts, w.mAl);
|
||||||
}
|
}
|
||||||
|
@ -857,6 +873,10 @@ namespace glTF2 {
|
||||||
if (this->mAsset.extensionsUsed.KHR_materials_clearcoat) {
|
if (this->mAsset.extensionsUsed.KHR_materials_clearcoat) {
|
||||||
exts.PushBack(StringRef("KHR_materials_clearcoat"), mAl);
|
exts.PushBack(StringRef("KHR_materials_clearcoat"), mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->mAsset.extensionsUsed.KHR_materials_transmission) {
|
||||||
|
exts.PushBack(StringRef("KHR_materials_transmission"), mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exts.Empty())
|
if (!exts.Empty())
|
||||||
|
|
|
@ -747,6 +747,20 @@ void glTF2Exporter::ExportMaterials()
|
||||||
|
|
||||||
m->materialClearcoat = Nullable<MaterialClearcoat>(clearcoat);
|
m->materialClearcoat = Nullable<MaterialClearcoat>(clearcoat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasMaterialTransmission = false;
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_TRANSMISSION, hasMaterialTransmission);
|
||||||
|
|
||||||
|
if (hasMaterialTransmission) {
|
||||||
|
mAsset->extensionsUsed.KHR_materials_transmission = true;
|
||||||
|
|
||||||
|
MaterialTransmission transmission;
|
||||||
|
|
||||||
|
mat->Get(AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR, transmission.transmissionFactor);
|
||||||
|
GetMatTex(mat, transmission.transmissionTexture, AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE);
|
||||||
|
|
||||||
|
m->materialTransmission = Nullable<MaterialTransmission>(transmission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue