Skip to content

KHR_mesh_quantization support #52

@zeux

Description

@zeux

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.

  1. 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.
};
  1. 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)

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions