Commit Graph

23 Commits

Author SHA1 Message Date
Powei Feng
3ce752c47b gltfio: enable passing in variant filters (#8851)
This enables filtering variants when using the JitMaterialProvider.
2025-06-13 21:06:22 +00:00
Juan Caldas
ad8c9ce4e0 Add common CLI Args parser for the samples (#8819) 2025-06-05 18:18:41 +00:00
Philip Rideout
9fa6dc4131 gltfio API change part 1: move all MaterialInstance methods to FilamentInstance 2022-09-29 16:28:50 -07:00
Philip Rideout
c4abe4f46a gltfio: allow zero-instance assets.
This is a feature request from Google. It allows users to "preload" an
asset, ie you can now create all VertexBuffer objects, Texture objects,
etc, without actually creating any entities or renderable components.

In the past we used TransformManager to help out with computing the big
asset-level bounding box, but now we use `gltf_node_transform_world()`
because entities might not yet exist.

One minor side effect is that `FilamentAsset::getBoundingBox()` now
returns the AABB that was determined at load time, and does not account
for instances. As a result, our `gltf_instances` sample app looks
slightly different but this is expected.
2022-09-14 16:40:47 -07:00
Philip Rideout
7337a467b9 gltfio cleanup: NodeMap is now a FixedCapacityVector, etc. 2022-08-30 15:57:30 -07:00
Philip Rideout
54769a2ad3 gltfio: Move the API for recomputeBoundingBoxes.
Prior to this change, `recomputeBoundingBoxes` was an opt-in config
parameter in ResourceLoader. It is now a method on FilamentInstance.

The old API did not work for dynamically created instances. Since this
is a relatively obscure feature, we considered removing it completely,
especially since the computation requires the presence of CPU-side
vertex data combined with the transform hierarchy.

Instead of removing the feature, we decided to move it to a better
place. This paves the way for some upcoming improvements, which include
reducing the memory footprint for assets. It also improves overall code
organization and separation of concerns.
2022-08-26 09:48:04 -07:00
Philip Rideout
8dc6fde588 gltfio API change: assets are now always 'instanced' etc
This change was motivated by some internal work at Google and has the
benefit of simplifying the gltfio API and implementation. There are 2
major API changes:

(1) Consolidate separate loader entry points for GLB and GLTF.

The distinction between GLB and GLTF can be made from the file content
alone, because GLB has a 4-byte magic string in its header. There is no
need for separate entry points.  Clients do not (and should not) need
to check the file name extension.

(2) Remove the distinction between "instanced" and "non-instanced"
glTF assets.

In the new scheme, all assets have at least 1 instance.

Broadly speaking, in gltfio an "asset" is a collection of Filament
objects like textures and vertex buffers, while an "instance" is a
collection of entities and components (e.g. the transform hierarchy).

This API change makes life easier for clients because they no longer
need to decide a priori if they will ever need to add instances.

This change also moves some public-facing methods from FilamentAsset to
FilamentInstance:

    - getSkinCount, getSkinNameAt
    - getJointCountAt, getJointsAt
    - attachSkin, detachSkin
2022-08-18 08:58:24 -07:00
Philip Rideout
5e4025bd4c UbershaderProvider now takes a custom archive in its constructor.
We still use resgen for convience, but the archive is now passed in
from the client application.

This will allow us to shrink the gltfio Android library (stay tuned).
2022-06-09 14:31:24 -07:00
Philip Rideout
30dbd3ac4f Rename gltfio to filament::gltfio. 2022-06-06 16:25:02 -07:00
Philip Rideout
0ae83a6c97 gltfio: Rename all plugin classes to have "provider" suffix.
UbershaderLoader  => UbershaderProvider
    MaterialGenerator => JitShaderProvider
2022-06-06 16:25:02 -07:00
daemyung jang
b7787b9a1a Fix a memory leak (#5539)
Delete the resource loader when the application is terminated.
2022-05-11 09:27:27 -07:00
Philip Rideout
f39815393a Fix crash regression with gltf_viewer and gltf_instances. 2022-05-05 09:42:08 -07:00
Philip Rideout
9031babd92 Various glTF-related cleanup and enhancements.
- For completion, FilamentAsset now has getRenderableEntities(). This is
  similar to sister methods getLightEntities() and getCameraEntities()
  except there is no need to store a separate array.

- The web helmet demo does not need to enable shadows, they are already
  enabled.

- The ViewerGui populateAsset() method was doing two things that are
  now decoupled for clarity: setAsset() and populateAsset().

- The updateRootTransform() method is now called only when the autoscale
  checkbox is toggled, instead of every frame.

- The getFooEntities() methods in Java now skip doing work for empty
  lists. Actually these should not return arrays at all, but let's fix
  that later, since it will break backwards compatibility.
2022-05-04 13:53:28 -07:00
Philip Rideout
fc284af684 Rename SimpleViewer to ViewerGui.
The SimpleViewer C++ class was not viewer component like `ModelViewer`
and `<filament-viewer>`. It was actually just the UI builder used
in the `gltf_viewer` desktop app and the remote Android interface.
2022-05-03 08:10:53 -07:00
Philip Rideout
a82b3bedb2 gltfio: material variants can now be applied to FilamentInstance. 2022-03-25 16:47:59 -07:00
Romain Guy
a5dbddfd12 Fix release distribution (#4713)
Statically link SDL2 to make our samples (glTF Viewer, etc.) completely
standalone, and include missing resources (fonts and default environment
map for the IBL).
2021-10-07 10:11:27 -07:00
Philip Rideout
b841709729 gltf_viewer: make auto-scale into a UI setting. 2021-06-28 15:08:59 -07:00
Philip Rideout
eb0c346969 gltfio: remove hacky RTTI from MaterialProvider.
We want anybody to write their own class that descends from
MaterialProvider, so it doesn't make sense to have an enum of
concrete types.
2021-06-24 15:24:13 -07:00
Philip Rideout
243ba77025 gltfio: support animation in dynamically-added instances.
I tested this by viewing CesiumMan with our `gltf_instances` sample app.

There is now a need for some general refactoring in gltfio. I feel that
the high-level objects have become too tightly coupled to each other.

Fixes #3137.
2021-01-19 16:37:54 -08:00
Philip Rideout
70dba2398e gltfio: add createInstance() to AssetLoader.
Note that this API is on the loader rather than the asset. This is
because the loader knows how to create Filament entities by traversing
a cgltf node hierarchy.

Animation on dynamically added instances is not yet supported.

We did not add destroyInstance() because gltfio favors flat arrays for
long term storage of entity lists and instance lists, which would be
slow to shift. We also wish to discourage create/destroy churn since it
is more efficient to pre-allocate instances and selectively add them
into the scene.

Fixes #3137.
2020-11-02 09:47:14 -08:00
Philip Rideout
7997e4aa21 Introduce libs/viewer and serializable view settings.
This introduces the `viewer::Settings` struct, and a JSON reader /
writer.

This will be used for automated testing and for client / server
communication.

Note that `viewer::Settings` is closely associated with the
`filament::View` API; when updating the latter we will often need to
update the former, as well as some serialization code. This increases
the maintenance burden and I think we should consider using a parser
library like libclang or a macro-based reflection utility.

This PR also migrates SimpleViewer into libs/viewer and un-inlines its
implementation. It does not belong in gltfio because it has an imgui
dependency.
2020-09-29 10:47:35 -07:00
Philip Rideout
b4623c9afc Add lightroom IBL, enable ColorGrading by default in gltf_viewer.
The non-legacy ACES is now default, it looks much better.

I also tested this IBL with WebGL and Android.
2020-07-30 11:39:36 -07:00
Philip Rideout
2d62daf5e8 Add sample for testing glTF instancing.
Fixes #1513.
2020-05-29 07:43:44 -07:00