-
Notifications
You must be signed in to change notification settings - Fork 478
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
gltfpack: Implement mesh instancing #142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of an optional node pointer we now have an array of nodes. When merging, the rule is that the node arrays must be pairwise compatible with each other wrt transforms. This hopefully will maintain mergeability for common cases without requiring splitting mesh sets. The rest of the code is adjusted in a trivial manner; when writing node attachments, we need to write a new quantization node for each target node because a node can only have one parent.
mm (mesh merge) will be used to restore the behavior where many instances of the same mesh can get merged in world space. mi (mesh instance) will be used to implement instancing extension.
Instead of duplicating meshes during parsing, we now parse all meshes[] elements, fill them with node references and discard empty meshes. This allows us to implement proper instancing export and is much more memory efficient on large inputs.
This allows us to confirm that the scene complexity doesn't change significantly during packing.
When -mm is specified, we merge individual instances of the same mesh together. This can only be done when no instance is attached to an animated node.
This is a copy of mrdoob/three.js#18913, using the inline quaternionFromBufferAttribute since it will need to be changed to support quantized inputs.
This adds all the necessary infrastructure with statistics and data structure changes to implement mesh instancing.
We decompose each node's transform into T/R/S and compress them individually using the same format and settings we use for animation data. Note that we are explicitly disabling cross-mesh merging in presence of instancing - in theory it's possible to use it but it doesn't seem like it's very important to do so...
Quantization offset needs to be applied in the instance local space.
Right now this is inconsequential since we don't allow merging meshes with instances, but this may change in the future. Also clang-format.
Supporting normalized rotations as an input and removed clone to fix quantized inputs.
This was referenced May 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change reworks the gltfpack mesh processing pipeline to be instancing-friendly: instead of duplicating all mesh instances during parsing, we keep the instance data if possible throughout the pipeline.
By default gltfpack no longer merges multiple instances of the same mesh together; this behavior can be changed using
-mm
command-line switch (which usually generates fewer draw calls for scenes with duplicate geometry, at the expense of using more memory).This change also implements experimental support for EXT_mesh_gpu_instancing, which can be activated using
-mi
switch. The instance data is saved in the same format as animation keyframes, which doesn't fully match the current spec draft.