__ANDROID__ is always set by the toolchain and less likely to cause
conflicts than ANDROID. This change also removes the -DANDROID flag
we set ourselves in our toolchain CMake files since we don't need
it anymore.
Fixes the "triangle count is zero" assertion with the big car model.
We do have nominal support for points and lines, but we should not
attempt to compute tangents for these.
As a reminder, glTF also supports loops, strips, and fans; this is the
only way in which Filament is non-conformant.
Fixes issue seen with Vulkan + the quantized version of Avocado.
We already support the quantized glTF extension, which is when this
comes up. Technically this is only needed for Vulkan but gltfio does
not (and should not) know which backend is being used, so we simply
apply these transformations assuming the worst.
In practice this code usually won't be activated, and if even when it
is, it won't hurt loading time as much as other things like large
textures.
The vertex data for glTF morph targets are deltas rather than final
values, so we were passing incorrect data into the SurfaceOrientation
helper.
This has been a long-standing bug that affected models with morphing,
including Buster Drone. However in practice we have observed visual
issues only with AnimatedMorphCube.
Tested against AnimatedMorphCube, Buster Drone, Cesium Man, Fox, and
Littlest Tokyo.
Fixes#1609
Recall that we now use shared_ptr to simplify lifetime management of
cgltf source data (#3413).
Before this commit, we were only using shared_ptr to retain the source
data during buffer uploads. After this commit, we are using it to retain
source data during texture decoding.
Fixes#3428.
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.
The gltfio API allows users to destroy ResourceLoader or FilamentAsset
even when various asynchronous work (e.g. uploading buffers to the GPU)
has not yet been completed. This was achieved in an error-prone manner
using manual reference counting and an internal management object called
AssetPool.
This PR refactors gltfio by wrapping cgltf_data in shared_ptr, which I
usually try to avoid. However in this case it provides the precisely the
functionality that is needed.
I tested this PR for memory leaks and crashes by hacking gltf_viewer
and monitoring memory usage in Activity Monitor.
This fixes#3383 and makes it easier to implement some missing features,
such as animation support for instanced assets.
Bad texture files would cause the background decoder thread to never
finish and would generate textures with 0x0 dimensions, which eventually
triggers GL_INVALID_VALUE.
To recap, gltfio texture loading has two phases: the first phase is
synchronous and uses stbi_info to gather texture info. The second phase
is asynchronous and uses stbi_load to do the actual decoding.
During the first phase, we now check the return code from stbi_info
rather than assuming that it worked. :)
Fixes#3344
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.
- Allow JavaScript and Java / Kotlin clients to configure this setting.
- Opt in by default (this was disabled in #2621)
- Optimize large assets like Bistro by iterating through prims only when
the asset actually has skins.
Fixes#2714.
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.
This needs a bit more testing before merging, but I wanted to put up the
PR for review. I will look into supporting Android after we land this.
Fixes#1932.
This replaces the "bindings" structures with simple types that re-use
data structures from cgltf.
This also moves some trivial work from ResourceLoader to AssetLoader,
which simplifies the communication between these two classes.
Motivated by #1932.
For Android and wasm we do not use the filesystem and therefore do not
need `utils::Path`.
```
libgltfio-jni.so BEFORE 1.9 MB (693 KB gzipped)
libgltfio-jni.so AFTER 1.4 MB (542 KB gzipped)
```
Note that libgeometry is already included in `filament-android`, this
simply exposes more of its existing functionality.
The Java version of SurfaceOrientation is similar to the JavaScript
version because we are bundling it into the main Filament package, even
though it is a separate library in C++. This is much simpler than
creating a brand new Java package.
New Android sample that tests this is forthcoming.
Fixes#1729.
This "fixes" the new animated Fox model in the glTF conformance suite.
As per the glTF spec, we now generate per-face normals for the case
where normals are not specified in the model.
Note that true flat shading (i.e. flat interpolation) is not a
requirement in the glTF spec, since some Khronos members advocate for
WebGL 1.0 compatibility.
Fixes#2088.
This feature adds one new method to `FilamentAsset` and uses it in our
Kotlin, JavaScript, and C++ helpers:
utils::Entity popRenderable() noexcept;
This pops a ready renderable off an internal queue, or returns 0 if no
renderables have become ready. It provides a simple way for clients to
gradually add renderables to the scene as they become ready. Previously
clients could only get the entire list of entities, regardless of
whether they had Renderable components or complete textures.
To facilitate this feature, this PR adds a new internal-only class to
gltfio called `DependencyGraph`, which is a temporary object used for
bookkeeping during the asynchronous load.
`DependencyGraph` discovers ready-to-render entities by tracking the
textures that each entity depends on. This is a graph because
renderables connect to a set of material instances, which in turn
connect to a set of parameter names, which in turn connect to a set of
texture objects. These relationships are not easily inspectable using
the Filament API or ECS.
We were already using jobs for decoding PNG and JPEG files, but we were
doing a join. This add three methods to ResourceLoader that allow
clients to amortize the decoding process across multiple frames, even on
single-threaded platforms like WebGL.
This PR adds async loading to the following demos:
- samples/gltf_viewer (now shows a progress bar in the UI)
- android/sample-gltf-viewer
- web/samples/helmet.html
Fixes#1876.
Add bindings for releaseSourceAsset() and fix a double-free issue.
According to the Android Studio profiler, this makes Java memory usage
go from 18.6 MB to 6.5 MB.
This was untested because our only glTF Android sample uses glb instead
of JSON. We will soon be adding a new Android demo that uses an actual
gltf file.
This fixes#1841.
For the street light glb from the Khronos suite, this reduces texture
loading time from 290 ms to 110 ms.
Stay tuned for another feature: notification callbacks.
Related to #1876.
Sparse accessors are easy to punt gracefully, we can emit a warning
and instead use the dense "base" data.
Also, after cgltf support for this lands, we will need to apply sparse
data in ResourceLoader, so this adds a bit of plumbing to prep for that.
Relates to #1727.