-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
gltfio: Add support for "software instancing". #2607
Conversation
This adds createInstancedAsset() to AssetLoader, which creates a master asset and a set of slave instances. Vertex buffers, index buffers, textures, and material instances are shared. Entities and components are duplicated. Instances have their own API object that is very simple. Light sources and material instances are not instanced, so are not accessible through the instance API object. The master-slave ownership model lets us avoid complex shared ownership semantics. The existing cache structures in AssetLoader allow the implementation of this feature to be fairly simple. The master asset exposes the union of all entities and allows clients to modify all instances en masse if they wish. This design also works naturally with ResourceLoader, which does not need to know about instancing. For example, asynchronous loading is completely unchanged; the dependency graph simply contains the union of entities across all instances. Support for animation is added in a subsequent commit. Fixes #1513.
When animation is applied to the master asset, all instances are animated. Instances can also be individually animated via the Animator in FilamentInstance. Fixes #1513.
|
||
namespace gltfio { | ||
|
||
namespace details { struct FFilamentAsset; } | ||
namespace details { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in another PR, maybe we should get rid of details:: in gltfio too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I would definitely like to do that.
@prideout Hay just a question about this part of the API. this seems to require you know how many instances you are going to need upfront. What is the intended method to add new instances at run time? I don't want to keep loading the asset every time I need to draw a new copy of my model. |
You can use the new |
This is not exposed in the web api yet, any idea on when it could be? |
It is exposed in the web API although I haven't had a chance to test it on that platform: https://github.com/google/filament/blob/main/web/filament-js/jsbindings.cpp#L1787 |
oh, I'm sorry must have been added after I pulled or something, will have to pull again. Thank you! |
@prideout after pulling and some confusion, I noticed that yes the function is in the definition file and in the jsbindings file it does not exist in the filament.js file. Should this be elevated to an issue? |
However I can easily believe that there is an issue with the web bindings for this entry point since I have not yet tested. Feel free to file an issue if you see an error message in Chrome's developer console when calling this method. |
This adds createInstancedAsset() to AssetLoader, which creates a master asset and a set of slave instances. Vertex buffers, index buffers, textures, and material instances are shared. Entities and components are duplicated.
Instances have their own API object that exposes a subset of the master asset's entity hierarchy and an optional Animator object.
This also adds a new sample app called
gltf_instances
. It is similar togltf_viewer
but with no GUI. It has additional command line arguments for a number of instances and animation.Java and JavaScript bindings will be added in a subsequent PR.
Fixes #1513