-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 2.0.0-dev.3.0 #124
Conversation
It looks like there's an issue with validating normal/tangent data for quantized normalized accessors. Here's an example: I'm getting the following type mismatch when trying to validate buffer contents here:
|
@zeux |
By the way, what asset did cause the original stack trace (with |
@lexaknyazev This was me copy&pasting the error from a wrong build, sorry about that - I tried to fix the |
I suspect this is just not implemented yet but it looks like this change only adds extra attribute types for base attributes when KHR_quantized_geometry is enabled, but not for morph targets? Here's a morph target example using quantized geometry, this gets a few errors in the morph target accessors:
|
@zeux |
@lexaknyazev Thanks! After this change I've confirmed that running all models from glTF-Sample-Models through gltfpack (which quantizes geometry & animation data) and running the output through gltf-validator with -r doesn't result in any errors on any models. |
@zeux |
Yeah - correct. |
|
Yeah - gltfpack renormalizes the skinning weights after quantization. This is necessary because if the weights don't add up to exactly 1 (which happens trivially when quantizing individual weights), vertices can be deformed very significantly because the weight error will get multiplied by the joint position, so an error of 1/255.f in the weight sum is actually unacceptably large. As a side effect I guess it fixes the validation errors :) Some of these files do generate validation warnings after gltfpack because some skinning weights get rounded to 0, but the joint index is preserved, so I get "Joints accessor element at index 60 (component index 0) is used with zero weight but has non-zero value (1).". I'll look into cleaning this up. |
Does it mean that we should enforce strict |
Yeah - it should be safer to validate the sum against 1.0 with some floating point epsilon that is independent of quantization, and enforce this in the same way regardless of the encoded type. While in principle renderers can normalize the weight in the shader during transformation, neither three.js nor Babylon.JS do this, and the spec does say that weights should sum to 1.0. |
|
@zeux |
While this change also produces no errors, I don't think I understand the logic behind it. If normalization happens on original float data without regards to quantization and individual weights are quantized, then even for two weights the sum isn't guaranteed to be 1.0 - if you start with two equal weights (0.5), the normalizing them retains the weights, and then quantization produces round(0.5 * 255) = 128 for each of them, for a total of 256/255 > 1. As per my comments above, if you introduce an error into the weight sum, then you can have noticeable distortion in the output if skinning is done in world space (as prescribed by glTF) and the joint offsets are large. So if we are assuming a "perfect" output, then I'd expect the threshold to be approximately equal to the floating point error of |
Yeah. Apparently, my inputs never had exact
Would this error depend on the number of non-zero weights? Practically, there could be from 1 to 8 of them per vertex. |
Hmm - maybe. I would expect that, handwaving a bit:
I've tested this with threshold=1e-6 on existing models before quantization but admittedly none of them have 8 weights. We could perhaps be a bit conservative and set the threshold to 1e-5 - or, maybe in line with your suggestion, to 1.5 ulp (= 1.785e-7 ~= 2e-7) per non-zero weight? |
By the way, just for exposition, here's a character where 8-bit weights have not been renormalized post quantization, with screenshots for root joint offset ~=0, root joint offset ~= 3x character size, root joint offset ~= 30x character size - the camera follows the character: This is with weights normalized before quantization and then quantized through rounding. When you normalize after quantization, the last screenshots looks clean: The screenshots are produced with three.js. |
When values are stored as integers and their sum is exactly Since the validator already tracks the number of non-zero weights per each vertex (no matter how many influence sets), we could set the threshold to What do you think? |
Yeah, correct - if you want to separate this case this works (although the 2e-7 threshold should cover it trivially I think). This looks good to me assuming this math actually passes on real models :D |
@bghgary @emackey The other question is how to deal with enums. Consider
This could be expressed as type Storage = "data-uri" | "buffer-view" | "glb" | "external"; When the corresponding resource object (image or buffer) is invalid, what value should this field have:
|
My vote is still |
Since there was no further feedback, I'm going to change the definitions of all optional or unknown fields in the report so that they could be omitted ( @bghgary @donmccurdy Any objections? |
Looks good! |
No objections! |
Done. |
Published to npm. /cc @donmccurdy |
VSCode's glTF Tools 2.2.8 has been updated to this version of the validator. |
I'm trying to use browersify to make the validator work for web like I've done in the past, but I'm getting an error when loading the resulting js:
I'll keep digging, but if anyone happens to know what is causing this, please let me know. |
It looks like this comes from dart2js? What changed such that it's trying to access the url module now? |
The new validator release is working for me on gltf-viewer.donmccurdy.com/, although I switched from Browserify to ParcelJS recently (so it's using ES modules rather than CommonJS). |
Ok, let me try ParcelJS. |
I get a very similar error with ParcelJS though I'm not using ES modules. I doubt that makes a difference though since it looks like the validator is trying to access the "url" module which is a node.js thing. Am I missing something? I'm running this:
Where index.js is: GLTFValidator = require('gltf-validator'); |
@donmccurdy Do you happen to have a polyfill for url module? |
One more thing I should mention is that I'm running this in a web worker. |
@bghgary @donmccurdy |
Thanks @lexaknyazev! I'm curious what is going on once you figure it out. I'll try to polyfill |
Ah, after looking at the code more carefully, I see what you mean by it's related to web worker. I managed to work around the problem by setting an empty |
2.0.0-dev.3.0 (November 2019)
New Features
Added support for
EXT_texture_webp
extension.extensionsUsed
, image objects with WebP data are reported with a newIMAGE_NON_ENABLED_MIME_TYPE
error.Added support for
KHR_mesh_quantization
draft extension.Added
NON_REQUIRED_EXTENSION
error for extensions that cannot be optional (such asKHR_mesh_quantization
).Added vendor prefixes:
MESHOPT
,POLUTROPON
, andAGT
(Add missing vendor extensions prefixesMESHOPT
andPOLUTROPON
#119).Added vendor prefixes:
ALCM
andSKYLINE
.Added vendor prefixes:
FOXIT
,KDAB
, andCAPTURE
.Extension names are now validated to have an upper-case prefix separated from the rest on the name with underscore (new
INVALID_EXTENSION_NAME_FORMAT
warning).Referencing an image of type defined by an extension from the core objects now results in
TEXTURE_INVALID_IMAGE_MIME_TYPE
error.Added
IMAGE_FEATURES_UNSUPPORTED
warning for images that contain features (like animation in WebP) not supported by glTF.Validation report now includes color-space information for provided images.
Validation report
info
object now includes more information about asset's performance characteristics (see Add object counts and sizes to report #120).Vertex colors with values outside of
[0.0 .. 1.0]
range now issueACCESSOR_NON_CLAMPED
error.Skinning validation (fixes Skins data validation #58):
When a node with a skinned mesh is used in a scene, the skeleton's common root must be available in the same scene (
NODE_SKIN_NO_SCENE
error).The skeleton nodes of a skin must have a common root (
SKIN_NO_COMMON_ROOT
error).The
skin.skeleton
property, when present, must point to a common root (SKIN_SKELETON_INVALID
error).Animation channels should not target a node with a skinned mesh (
ANIMATION_CHANNEL_TARGET_NODE_SKIN
warning).A node with a skinned mesh should be a root node (
NODE_SKINNED_MESH_NON_ROOT
warning).A node with a skinned mesh should not have local transforms (
NODE_SKINNED_MESH_LOCAL_TRANSFORMS
warning).Vertex influences validation:
All joints values must be within the range of joints in the skin (
ACCESSOR_JOINTS_INDEX_OOB
error).No joint may have more than one non-zero weight for a given vertex (
ACCESSOR_JOINTS_INDEX_DUPLICATE
error).Weights must be non-negative (
ACCESSOR_WEIGHTS_NEGATIVE
error).Weights for each vertex must be normalized to have a linear sum of
1.0
(ACCESSOR_WEIGHTS_NON_NORMALIZED
error).Unused joint values (i.e. joints with a weight of zero) should be set to zero (
ACCESSOR_JOINTS_USED_ZERO_WEIGHT
warning).Integration updates
Upgraded to the latest stable SDK.
Generated npm package no longer requires polyfills when using webpack with certain configurations (fixes NPM Package not working in Angular7 App #110).
It is now possible to omit timestamps from validation reports.
Validation report now consistently uses lower-case enums.
Native executable binaries can now be compiled. See the README for details (fixes Windows EXE command line validation tool #113).
Generated report filename is now
<asset>.report.json
.Unit tests (300+) are now consistently stored: an asset and its validation report. Combined with provided JSON catalogs, they could be used for testing other glTF implementations.
Changes
Major refactoring of binary data validation. Now, mesh and animation accessor issues are attributed to the corresponding binding points rather than to accessor objects. This change makes validation reports more precise when accessors are reused. Namely:
ACCESSOR_ANIMATION_INPUT_NEGATIVE
andACCESSOR_ANIMATION_INPUT_NON_INCREASING
are attributed toanimation.sampler.input
.ANIMATION_SAMPLER_OUTPUT_ACCESSOR_NON_NORMALIZED_QUATERNION
(new) is attributed toanimation.channel.sampler
.ACCESSOR_INVALID_SIGN
is attributed tomesh.primitive.attributes.TANGENT
; its message is more sound now.ACCESSOR_VECTOR3_NON_UNIT
(renamed fromACCESSOR_NON_UNIT
) is attributed tomesh.primitive.attributes.NORMAL
ormesh.primitive.attributes.TANGENT
.ACCESSOR_NON_CLAMPED
is attributed tomesh.primitive.attributes.COLOR
.ACCESSOR_INVALID_IBM
is attributed toskin.inverseBindMatrices
.ACCESSOR_INDEX_OOB
,ACCESSOR_INDEX_PRIMITIVE_RESTART
, andACCESSOR_INDEX_TRIANGLE_DEGENERATE
are attributed tomesh.primitive.indices
.ACCESSOR_INVALID_FLOAT
message is more specific.Fixed incorrect message in
ACCESSOR_INDEX_OOB
.BUFFER_VIEW_TOO_LONG
is now attributed tobufferView.byteLength
whenbufferView.byteOffset
fits the referenced buffer.FILE_NOT_FOUND
is renamed toIO_ERROR
; its error messages are now more consistent across platforms.Web drag-n-drop validator now issues an error when external resources are not available among dropped files.
ACCESSOR_INDECOMPOSABLE_MATRIX
renamed toACCESSOR_INVALID_IBM
; IBM data is no longer checked for TRS decomposition.Unused texture coordinates are now consistently reported as
UNUSED_OBJECT
with proper pointers regardless of material presence;MESH_PRIMITIVE_UNUSED_TEXCOORD
is removed (fixes No message for unused texcoords if there is no material #117).MESH_PRIMITIVE_JOINTS_WEIGHTS_MISMATCH
now reports mismatching numbers.Removed
BUFFER_NON_FIRST_GLB
warning (fixes Should all buffers with empty uri be treated as GLB buffers? #121).Removed
ANIMATION_SAMPLER_OUTPUT_INTERPOLATION
.Removed
WEB3D_quantized_attributes
andCESIUM_RTC
extensions support.Bugfixes
Fixed possible crash on empty input stream.
Fixed possible crash on unresolved animation sampler inputs.
BUFFER_VIEW_TOO_LONG
is now correctly attributed to the invalid property.When
buffer.byteLength
is undefined for an embedded buffer,BUFFER_EMBEDDED_BYTELENGTH_MISMATCH
is no longer reported.When
asset.version
is undefined or incorrect,ASSET_MIN_VERSION_GREATER_THAN_VERSION
,UNKNOWN_ASSET_MAJOR_VERSION
, andUNKNOWN_ASSET_MINOR_VERSION
are no longer reported.When reported,
UNKNOWN_ASSET_MAJOR_VERSION
andUNKNOWN_ASSET_MINOR_VERSION
errors now point toasset.version
.MESH_PRIMITIVE_TANGENT_WITHOUT_NORMAL
andMESH_PRIMITIVE_TANGENT_POINTS
now point to tangent attribute instead ofprimitive.attributes
object.Numerical thresholds for unit-length vectors are now chosen to accommodate possibly-quantized values.
Fixed missing
UNRESOLVED_REFERENCE
errors forKHR_lights_punctual
extension.When the root
KHR_lights_punctual
(withlights
array) extension object is not present, its node counterpart now issuesUNSATISFIED_DEPENDENCY
error.Reported issues about invalid JSON syntax or invalid root object type no longer have JSON pointers.
Fixed incorrect message in
BUFFER_VIEW_TOO_BIG_BYTE_STRIDE
.Fixed possible crash on invalid buffer or image objects (fixes Validation failed: NoSuchMethodError: method not found: 'a' on null #125).
Please review the slightly updated validation report JSON format. Given that there's an interest in providing TypeScript definitions, we should make them consistent, especially around
null
/undefined
values.