Now that #51 is merged I'd like to discuss how to add support for KHR_mesh_quantization (https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization) to this SDK.
All of the code that could support reading quantized accessors is here, but we're missing good validation. Specifically:
- When KHR_mesh_quantization is set, certain attribute types are now valid to use for mesh geometry inputs
- When KHR_mesh_quantization is not set, I'd like to improve the current validation code to properly check
normalized attribute.
My suggestion is as follows.
- Change the existing accessor validation to use tables of admissible component types, e.g.
struct GeometryAccessor
{
bool quantized;
ComponentType type;
bool normalized;
};
std::vector<GeometryAccessor> kPositionAccessors =
{
{ false, COMPONENT_FLOAT, false },
{ true, COMPONENT_SHORT, true }, // etc.
};
-
When loading the document, cache the presence of required KHR_mesh_quantization extension in the document field to alleviate concerns around string comparisons (alternatively we could look this up when reading accessor data)
-
Instead of current ad-hoc code, use somewhat more generic code e.g. Validation::ValidateGeometryAccessor(accessor, kPositionAccessors, doc.RequiresMeshQuantization()));
As a result, files that don't require KHR_mesh_quantization will be validated using the existing validation rules (+ a normalized check); files that require KHR_mesh_quantization will be automatically de-quantized on load.
Thoughts/suggestions welcome.
Now that #51 is merged I'd like to discuss how to add support for KHR_mesh_quantization (https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization) to this SDK.
All of the code that could support reading quantized accessors is here, but we're missing good validation. Specifically:
normalizedattribute.My suggestion is as follows.
When loading the document, cache the presence of required KHR_mesh_quantization extension in the document field to alleviate concerns around string comparisons (alternatively we could look this up when reading accessor data)
Instead of current ad-hoc code, use somewhat more generic code e.g.
Validation::ValidateGeometryAccessor(accessor, kPositionAccessors, doc.RequiresMeshQuantization()));As a result, files that don't require KHR_mesh_quantization will be validated using the existing validation rules (+ a
normalizedcheck); files that require KHR_mesh_quantization will be automatically de-quantized on load.Thoughts/suggestions welcome.