Added gltf2 KHR_materials_volume write support.

pull/4112/head
diharaw 2021-09-30 08:10:02 +01:00
parent 200bf8df7a
commit d3276de47d
2 changed files with 27 additions and 0 deletions

View File

@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* KHR_materials_sheen: full
* KHR_materials_clearcoat: full
* KHR_materials_transmission: full
* KHR_materials_volume: full
*/
#ifndef GLTF2ASSETWRITER_H_INC
#define GLTF2ASSETWRITER_H_INC

View File

@ -474,6 +474,28 @@ namespace glTF2 {
}
}
if (m.materialVolume.isPresent) {
Value materialVolume(rapidjson::Type::kObjectType);
MaterialVolume &volume = m.materialVolume.value;
if (volume.thicknessFactor != 0.f) {
WriteFloat(materialVolume, volume.thicknessFactor, "thicknessFactor", w.mAl);
}
WriteTex(materialVolume, volume.thicknessTexture, "thicknessTexture", w.mAl);
if (volume.attenuationDistance != INFINITY) {
WriteFloat(materialVolume, volume.attenuationDistance, "attenuationDistance", w.mAl);
}
WriteVec(materialVolume, volume.attenuationColor, "attenuationColor", defaultAttenuationColor, w.mAl);
if (!materialVolume.ObjectEmpty()) {
exts.AddMember("KHR_materials_volume", materialVolume, w.mAl);
}
}
if (!exts.ObjectEmpty()) {
obj.AddMember("extensions", exts, w.mAl);
}
@ -890,6 +912,10 @@ namespace glTF2 {
exts.PushBack(StringRef("KHR_materials_transmission"), mAl);
}
if (this->mAsset.extensionsUsed.KHR_materials_volume) {
exts.PushBack(StringRef("KHR_materials_volume"), mAl);
}
if (this->mAsset.extensionsUsed.FB_ngon_encoding) {
exts.PushBack(StringRef("FB_ngon_encoding"), mAl);
}