Commit Graph

36 Commits

Author SHA1 Message Date
Alexey Pelykh
8c36e6d95f MaterialKey: expose constrainMaterial to Android (#4398) 2021-07-28 09:58:41 -07:00
Alexey Pelykh
2b6d99f5e7 Fix nCreateMaterialInstance in UbershaderLoader: JNI_ABORT does not propagate changes (#4396) 2021-07-28 08:35:34 -07:00
Romain Guy
5e51ff78d9 Add KHR_material_volume support to MaterialProvider (#4391)
* Add KHR_material_volume support to MaterialProvider

* Fix typo
2021-07-27 14:56:50 -07:00
Alexey Pelykh
6bf27c7356 Fix NoSuchMethod exception (#4390) 2021-07-27 12:20:41 -07:00
Philip Rideout
ca3b841974 gltfio: Add fast path for native material providers. 2021-07-01 16:11:55 -07:00
Philip Rideout
e9ff2157bc gltfio: Cache the JNI field ids for MaterialKey. 2021-07-01 16:11:55 -07:00
Philip Rideout
d270c42109 gltfio: Allow Java / Kotlin clients to customize MaterialProvider.
This adds some significant JNI glue in order to make the Java API for
gltfio materials much more consistent with C++, and create feature
parity between the two languages.

The motivation is to allow Java clients to provide their own
ubershader-based solution or filamat-based solution.

- The `MaterialProvider` Java class is now an interface.
- The `UbershaderLoader` Java class is now a concrete implementation.
- Users can now write their own provider class using Java / Kotlin.

To streamline the amount of JNI work that occurs at run time, the
MaterialProvider Java interface uses ints in a couple spots instead
of enums. This sacrafices some readability for Java clients who wish
to write their own provider, but makes the JNI much simpler.

This replaces #3975.
2021-07-01 16:11:55 -07:00
Philip Rideout
c7e4116154 gltfio: introduce support for extras strings.
This allows clients to obtain the extras strings for the asset and
for individual nodes.  Note that extras for buffer views, accessors, etc
are not supported, although C++ clients can access the raw cgltf data
directly if they need to.
2021-06-24 10:41:40 -07:00
Philip Rideout
c3c2a732cd gltfio: Add ResourceLoader evict API. 2021-03-03 14:41:22 -08:00
Philip Rideout
893ed861e9 gltfio on Java: free material cache in AssetLoader#destroy
Fixes #3469
2021-01-29 14:42:54 -08:00
Philip Rideout
1ebdb18eae gltfio: add async cancellation API 2020-09-23 10:53:55 -07:00
Ben Doherty
94776a01b3 Add JNI bindings for gltfio camera (#2693) 2020-06-16 15:24:24 -07:00
Philip Rideout
7418fc0222 gltfio: JNI bindings for get-by-name.
Tested in Android Studio by starting sample-gltf-viewer and typing the
following into the debugger:

    modelViewer.asset!!.getFirstEntityByName("Drone_Body")
    modelViewer.asset!!.getEntitiesByName("Drone_Body")
    modelViewer.asset!!.getEntitiesByPrefix("Drone")
2020-06-02 18:38:36 -07:00
Philip Rideout
a3e336921e gltfio: improve performance by assuming assets are well-formed.
glTF assets are required to provide min/max attributes for POSITION,
so in theory we never need to compute the AABB. However the option is
still there.

This PR also makes it so that Java clients can choose this option,
previously it was hardcoded for all non-native clients.
2020-06-01 10:30:09 -07:00
Philip Rideout
81ea280ea9 gltfio: add Java bindings for instancing. 2020-05-29 09:22:17 -07:00
Philip Rideout
c087eb6825 gltfio: Add Java / JavaScript bindings for lights. 2020-05-28 11:51:35 -07:00
Philip Rideout
9a47178b3d gltfio: expose getMaterialInstances to Java.
Tested locally by hacking gltf-viewer on Android, added the following
lines to MainActivity:

```kotlin
for (mat in modelViewer.asset!!.materialInstances) {
    Log.d("gltf-viewer", mat.name)
}
```
2020-05-11 10:39:13 -07:00
Romain Guy
9b1a0e2f58 Remove of static JNI fields (#2400)
Static JNI lookups were causing issues with multiple libraries.
We now do the lookups when we need them as they are effectively
just hashmap lookups and we do them only in places where the
work we need to perform will be much larger than a simple hash
map lookup anyway.

This chane also manually registers filament-utils JNI bindings
to get rid of unnecessary symboles. We should do the same for
other Filament libraries (the symbols are pretty long and
we now have many of them).
2020-04-16 09:00:54 -07:00
Philip Rideout
65129d1b52 filament-utils-android: fix recent crash regression. 2020-02-14 14:56:38 -08:00
Philip Rideout
02b377c244 gltfio: remove locale.cpp dependency
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)
```
2020-02-12 10:03:06 -08:00
Philip Rideout
415aeef95b gltfio JNI: fix broken getName() method. 2020-02-07 17:15:28 -08:00
Philip Rideout
8020f7eb78 gltfio: add plural version of popRenderable 2020-02-04 12:47:32 -08:00
Philip Rideout
d2c883877d gltfio: hide entities with not-yet-ready textures.
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.
2020-02-04 12:47:32 -08:00
Philip Rideout
c681cd243a gltfio: Introduce the asynchronous API and use it.
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.
2020-01-31 09:20:48 -08:00
Philip Rideout
ff66e980eb Add ResourceLoader::hasResourceData. 2020-01-28 14:51:02 -08:00
Philip Rideout
518ae9658f gltfio + Android: improve memory management.
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.
2020-01-21 13:01:55 -08:00
Philip Rideout
961860adee Introduce filament-utils and Java bindings for camutils.
This library houses the KTX loader, camutils bindings, and a Kotlin math
library. More will come later. Sample app is forthcoming.
2020-01-16 16:00:23 -08:00
Philip Rideout
274cd3a1f3 Refactor some Android build things for gltfio.
We currently use static linking and will continue to do so. This means
that libfilament-jni is a subset of of libgltfio-jni, and libgltfio-jni
will become a subset of the upcoming libutils-jni.

This is a simple layer cake, but requires adding some CMake logic to the
gltfio-android CMakeLists, similar to what we already did for the
filament-android CMakeLists. This prevents an obscure CMake error about
duplicated build artifacts.

Also, previously we required clients to call AssetLoader#init(), this
is now renamed to Gltfio#init(), which is more consistent with
Filament#init().
2020-01-16 10:11:36 -08:00
Nicklas Ansman Giertz
73a4431a34 Fix some warnings in the gltfio android jni code 2019-11-03 15:03:13 -08:00
Nicklas Ansman Giertz
e252558ef6 Expose FilamentAsset.getResourceUris in the Android bindings 2019-11-03 15:03:13 -08:00
Nicklas Ansman Giertz
5680b5d9a6 Add support for GLTF files in the android gltfio bindings 2019-11-03 15:03:13 -08:00
Philip Rideout
618b59932c gltfio: Add Java / Kotlin bindings for Animator.
Fixes #1529.
2019-10-28 09:32:39 -07:00
Philip Rideout
1bda37776b Rename KtxUtility namespace to image::ktx. 2019-09-23 12:08:57 -04:00
Philip Rideout
0fe8035309 gltfio: allow names to be queried.
Fixes #1425.
2019-08-06 12:54:29 -07:00
Philip Rideout
927662ea4d Add JNI for KTX, simplify the bloom Android demo. 2019-07-02 11:02:45 -07:00
Philip Rideout
b17d606ed2 Introduce JNI bindings for gltfio.
For now this uses gltfio in the ubershader configuration in order
to avoid the filamat dependency. Note that we have not yet done a size
analysis of the `gltfio_core` library.

New Kotlin-based sample app is forthcoming.
2019-06-18 13:53:45 -07:00