I'm looking at replacing some custom GLTF structs for a model generator with the gltf_json crate from this project. One oddity I ran into involves serializing materials. If a material is created with default values:
gltf_root.push(gltf_json::Material::default());
When it is serialized many of the defaults are included in the JSON:
The GLTF spec at https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material states that emissiveFactor, alphaMode, doubleSided, and the values included under pbrMetallicRoughness are all optional AND have spec-defined default values. For spec-compliant renderers, there's no reason to include those values in the JSON.
Is there a way to tell the gltf crate to skip serializing these values? If not, would you accept a patch that updates gltf_json's materials to skip serializing values if they are equal to their spec-defined defaults?
I'm looking at replacing some custom GLTF structs for a model generator with the gltf_json crate from this project. One oddity I ran into involves serializing materials. If a material is created with default values:
When it is serialized many of the defaults are included in the JSON:
The GLTF spec at https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material states that
emissiveFactor
,alphaMode
,doubleSided
, and the values included underpbrMetallicRoughness
are all optional AND have spec-defined default values. For spec-compliant renderers, there's no reason to include those values in the JSON.Is there a way to tell the gltf crate to skip serializing these values? If not, would you accept a patch that updates gltf_json's materials to skip serializing values if they are equal to their spec-defined defaults?