KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.18k stars 1.14k forks source link

Disambiguation of attribute semantic names #2111

Open javagl opened 2 years ago

javagl commented 2 years ago

The (Meshes) Overview section of the specification says

Application-specific attribute semantics MUST start with an underscore, e.g., _TEMPERATURE

Some questions are not sufficiently answered by this.


The first question is very vague and hard to answer specifically: What constitutes "application-specific"?


A broader, more specific, and somewhat crucial question is: Is it possible to disambiguate custom attribute names in extensions?

For example, there could be two extensions that both define a generic attribute name like _ID or _VALUE. The name clash would prevent the extensions to be used at the same time. A seemingly simple and straightforward solution would be to require the attribute names to be prefixed with the extension name. Something like "_EXT_foo_bar_ID" looks a bit odd, but is as unambiguous as it gets. In any case: Only requiring the undescore prefix may not be sufficient (also because there is no way to sensibly figure out which extension might already use which attribute names).


A question that is somewhat tangential, but brought up this one (via https://github.com/CesiumGS/3d-tiles/issues/611 ): Can extensions define custom attributes without the _ underscore?

Based on my understanding, the answer to this is no: The validator dedicatedly checks for the semantics that are defined in the core spec, and only skips the ones that start with an undescore, via the checkAttributeSemanticName function, causing a MESH_PRIMITIVE_INVALID_ATTRIBUTE error for all unknown attribute names that do not start with an underscore. But I wanted to ask for a confirmation here: Is it correct that such attribute names would be considered as invalid even when the support for the extension was added to the validator?

lexaknyazev commented 2 years ago

Excellent question. I think it's a case where the spirit and the letter of the spec have slightly diverged. The underscore attributes are akin to extras properties - with no portability or scope protection guarantees. At the same time, we probably cannot allow extensions to add custom unprefixed attributes for the reasons mentioned above.

javagl commented 1 year ago

Disclosure: I'm an 'Independent Contributor' for the Khronos Group, and been involved in the development of glTF extensions as part of my freelancing work, for a company that is also a Khronos member. I do not endorse or promote these extensions in my role as a Khronos contributor. They are only examples of cases where the question about the 'Disambiguation of attribute semantic names' is relevant. But the question refers to the glTF specification in general, and is not specific for these extensions.

Two extensions are currently proposed (as pull requests) that make heavy use of glTF attributes for storing 'binary data':