Skip to content
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

consolidate meshes, based on a list of DBIds #9

Closed
wallabyway opened this issue Nov 26, 2019 · 11 comments
Closed

consolidate meshes, based on a list of DBIds #9

wallabyway opened this issue Nov 26, 2019 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@wallabyway
Copy link
Collaborator

wallabyway commented Nov 26, 2019

Can you add a command line option to take in an array of dbID-groups (or via a separate AEC.json file) and mesh-merge the meshes ?

The problem:
When I convert the 'advanced.rvt' model, it produces 1000+ nodes, which crashes Unity/Blender/gltf-pipeline and renders slowly in 3js / Babylon.js etc.

If this utility could do "mesh-merge" (same as mesh-consolidation), it would reduce the nodes, to fix the gltf-tooling crashes, and render the AEC model faster. I also realize that it means I can no longer pick individual AEC entities (at least, not easily).

@petrbroz petrbroz added the enhancement New feature or request label Nov 26, 2019
@petrbroz petrbroz self-assigned this Nov 26, 2019
@petrbroz
Copy link
Owner

petrbroz commented Nov 26, 2019

I guess by saying "merging" instead of "consolidating", the idea is to simply bundle multiple primitives in a single mesh object, is that right? This would help decrease the number of nodes, but the number of meshes and materials would remain the same. Or are you actually asking for consolidation of multiple objects to a single mesh? The tricky part there would be the consolidation of the individual materials.

@wallabyway
Copy link
Collaborator Author

wallabyway commented Dec 4, 2019

@wallabyway
Copy link
Collaborator Author

looks like gltfpack already consolidates by default, based on material shader.

@petrbroz
Copy link
Owner

I believe it does. Also, if I remember correctly, @zeux mentioned that gltfpack could potentially support other, less aggressive rules for consolidation. If one could consolidate meshes based on properties of gltf nodes (in our case, dbIDs encoded in node names), that would solve this request quite nicely.

@zeux
Copy link

zeux commented Dec 19, 2019

Yeah this is perfectly reasonable - I can implement a separate merge mode (right now there are two, "merge everything possible" and "don't touch anything that has a name") that merges meshes between nodes with equivalent names - is that what you mean by "dbIDs encoded in node names"?

@petrbroz
Copy link
Owner

petrbroz commented Dec 20, 2019

In the original file format that we're converting to glTF, "dbIDs" are simply numerical IDs of individual selectable elements that can have certain properties (from an external database) attached to them. We're currently storing the dbIDs in node.name.

The idea here was not necessarily to consolidate nodes with equivalent names, but to consolidate nodes with names belonging to specific "consolidation groups", for example, consolidating nodes "123", "124", "125" into one mesh, and nodes "126", "127", "128" into another mesh. That doesn't sound very flexible/reusable, though... Would it perhaps make more sense to merge based on an "extra" property like node.extras.merge_group?

@zeux
Copy link

zeux commented Dec 20, 2019

Ok - I see. In this case it's definitely worthwhile specifying this explicitly.

I'm not sure what the best route for this is. Might make sense to open an issue in glTF repository soliciting feedback for the schema specification so that longer term this solution can be implemented in other tools - it's probably fine to use extras for this similar to targetNames but I just want to make sure.

@donmccurdy
Copy link

I guess by saying "merging" instead of "consolidating", the idea is to simply bundle multiple primitives in a single mesh object, is that right? This would help decrease the number of nodes, but the number of meshes and materials would remain the same.

Note that while this would reduce JSON size a bit, I'd expect draw calls and runtime performance of N primitives or N meshes to be pretty much the same.

Added a comment about the tagging suggestion in KhronosGroup/glTF#1731.

@wallabyway
Copy link
Collaborator Author

wallabyway commented Jan 21, 2020

Hi @donmccurdy - The N primitives/meshes are reduced by the Zeux pipeline.

So just focusing on render performance comparison (skip the file size stuff, since that involves discussing compression)... when I say 'merging' or 'consolidating', I'm referring to http://learningthreejs.com/blog/2011/10/05/performance-merging-geometry/

I'll take the gltf file we produce from our SVF->glTF pipeline, we get 1000's of nodes, accessors and meshes for an AEC model. This is to maintain selectable primitives. We feed that gltf into the Zeux compressor pipeline to get a new glb file. By default the Zeux pipeline consolidates by material, reducing draw calls to the number of state changes for material shader switching (roughly). In the end, the glb file has much fewer N primitives/meshes and significant render performance improvement (especially on Safari mobile, chrome/android).

I hope I understood your comment. Please excuse me if I got it wrong.

The file size and decode times, are small and fast for our testing...
example: a single office floor gltf = 50MB. vs zeux.glb.gz = 4.8MB
load time (TTLP) < 3seconds, second load (TTLP) 300ms (three.js hosted on githubpages)

@wallabyway
Copy link
Collaborator Author

glTFpack does mesh merge that reduces draw calls to, typically 2 (maybe 3), for most things converted from our SVF assets.

Currently, when mesh-merge happen, the dbids (nodes) are also merged, losing the ability to associate a node with a dbid.

Thankfully the FEATURE_ID extension proposal, can store the DBID in custom vertices attributes.

https://github.com/CesiumGS/glTF/tree/proposal-EXT_mesh_features/extensions/2.0/Vendor/EXT_mesh_features#feature-id-by-vertex

If glTFPack put the dbids into a custom vertices attribute, during mesh-merge, then we could retrieve the DBID later.

So during a hit-test, we detect the triangle face, it vertices / custom attributes. This containing the FEATURE_ID and our DBID.
Thus we can have the benefits of glTFpack's mesh-merge (2 draw calls, low-node count, compression) as well as extracting the DBID, thus solving for this problem: KhronosGroup/glTF#1699

Closing

@wallabyway
Copy link
Collaborator Author

wallabyway commented Jul 30, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants