Commit Graph

127 Commits

Author SHA1 Message Date
Powei Feng
f664601c51 android: add readPixels callback for ModelViewer (#9440) 2025-11-21 19:33:36 +00:00
Powei Feng
aa4f1910b8 android: add static annotation for Utils.init() (#9435)
This allows for static call from java, e.g.:

```
static {
    Utils.init();
}
```
2025-11-13 22:01:49 +00:00
Rafael Marinho de Araújo
d47a69a529 add overload of loadTexture that loads bitmap from ByteArray (#9416)
Co-authored-by: rma6 <rafaelmarinhoa@gmail.com>
2025-11-07 10:11:23 -08:00
Mathias Agopian
76e36cd87b try to cleanup android libraries cmake build
- make as many library deps private as possible
- try to keep the same structure between the CMakeList.txt files
- for gltfio use libgltfio_core.a
2025-09-04 11:28:28 -07:00
Powei Feng
9fad497fa0 Enable c++20 for Android and iOS (#9150)
- Fix Android cmake files
- Change iOS samples to use c++20
2025-09-03 00:28:14 +00:00
Powei Feng
c21f211a13 Update java for Texture::Usage (#9055)
Also update samples and utils to use proper usage when
generating mipmaps.
2025-08-11 19:47:26 +00:00
Powei Feng
1b2ab09719 android: prevent leak of cubemap for IndirectLight/Skybox (#8470)
We break existing  API by returning both the IndirectLight and the
texture. Same thing with Skybox.

Fix one bug where the float array in getSphericalHarmonics wasn't
getting written out.

Fixes #6412
2025-02-27 20:14:22 +00:00
Tibor Hencz
a2fe9f745c Add ability to disable panning in the OrbitManipulator (#7928) 2024-06-27 00:05:14 +00:00
Mathias Agopian
6dd6db89d5 align android libraries to 16 KiB 2024-05-13 23:14:32 -07:00
Mathias Agopian
39d555d115 get rid of filmat-lite, which was poorly maintained 2023-10-02 14:18:25 -07:00
Romain Guy
cb9bfaeb83 Fix build warnings (#7189)
The latest macOS toolchain triggers warnings for duplicate libraries at
link time. This is caused by our dependency chains.

Also remove an inlining warning in Kotlin and unnecessary warnings in
build.sh when doing a clean or generating web docs.
2023-09-20 10:16:55 -07:00
JEONG TAEHUN
50045edb4f [ModelViewer.kt, Remove Lint warning] (#6917)
- Use of getter method instead of property access syntax (for getInstance)
 - 'rangeTo' or the '..' call should be replaced with 'until' (in for)

Co-authored-by: jeongth9446 <taehuniy@gmail.com>
2023-06-26 12:05:43 +08:00
Romain Guy
bd9ba1139e Update Kotlin math APIs (#6761)
Fixes bugs and adds new useful APIs.
2023-04-24 05:17:09 -07:00
Romain Guy
7f51f21512 Fix Android samples 2023-04-21 15:53:59 -07:00
Mathias Agopian
c24cc726e8 Fix Android samples so they handle surface resizes properly 2023-04-21 15:36:02 -07:00
Romain Guy
7b90a8f921 Set the Kotlin JDK version to match AGP's 2023-04-20 23:17:25 -07:00
Romain Guy
9fb96cd200 Upgrade to AGP/Gradle 8.0.0, and other dependency upgrades (#6753)
This upgrade lets us remove several hacks we needed to properly publish
our artifacts on Maven.
2023-04-20 18:02:23 -07:00
Daniel Rahme
e30a99f692 Fix wrong package name 2023-03-13 15:14:46 -07:00
Mathias Agopian
94f121f37d Add a camera near/far setting in gltf_viewer 2023-02-17 11:16:42 -08:00
Philip Rideout
342138aecb gltfio: Update Java API. 2022-09-29 16:28:50 -07:00
Ben Doherty
7f5ad3743b Fixes for 1.27.2 release (#6125) 2022-09-29 13:08:00 -07:00
Romain Guy
8dae181c2f Upgrade AGP and dependencies including plugins (#6078)
This moves to a new, maintained Maven publishing plugin.
2022-09-15 16:05:18 -07:00
Mathias Agopian
ead5a97871 make AutomationEngine feature level aware
this basically just adds an Engine* parameter too all applySettings
methods
2022-09-07 15:32:58 -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
Mathias Agopian
a64b1eccdf add API to enable/disable auto-instancing globally.
auto-instancing can have some overhead, so when it is known that the
scene doesn't have identical primitives, it is better to disable it.
(disabled by default).

Also add some missing bindings for `enableAccurateTranslations`.
2022-07-06 15:51:41 -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
Ben Doherty
62a234a8f9 Add package name back to AndroidManifest.xml to fix G3 (#5569) 2022-05-17 17:53:16 -07:00
Romain Guy
f229aaa7c4 Upgrade Android tools (#5533)
* Upgrade Android tools

NDK 24
AGP/Gradle 7.2
Kotlin 1.6.21
Coroutines 1.6.1

* Force Java 8 to run sdkmanager
2022-05-09 12:12:14 -07:00
Philip Rideout
f847232296 gltfio: introduce TextureProvider API.
This allows clients to provide their own asynchronous texture decoders
for various mime-typed images. This is a plug-in component for gltfio,
in some ways similar to MaterialProvider.

There are two motivations for this: to decouple gltfio from STB and
to make it easier to integrate support for BasisU textures.

This also has the side effect of simplifying ResourceLoader, since the
texture decoding jobs have been moved out.

As part of this work, I made the "stb" CMake target into a traditional
static library. Previously we had several files called `Image.cpp`
whose sole purpose was to enable STB_IMAGE_IMPLEMENTATION.
2022-04-21 13:25:40 -07:00
Philip Rideout
d52a24b6e9 Incorporate feedback from code review. 2022-04-15 10:48:48 -07:00
Philip Rideout
9aeec3a759 Add Ktx2Reader and BasisEncoder and use them in samples.
mipgen can now emit basis-encoded KTX2 files. Both the desktop and
web "suzanne" samples use this as a test for compressed textures.

This PR does not add KTX2 support to glTF, but it's on the way.

`BasisEncoder` has a builder style API that calls the basis encoder to
create KTX2 files. This hides some low-level BasisU features that we are
not using, like file I/O and mipmap generation.

`Ktx2Reader` is an easy-to-use API for creating Filament textures from
KTX2 files. Its API primarily consists of these two methods:

    bool requestFormat(Texture::InternalFormat format);
    Filament::Texture* load(const uint8_t* data, size_t size);

The first method is used to build an ordered list of formats that are
supported by your hardware. The second method consumes the contents of a
basis-encoded KTX2 file and attempts to produce a Filament texture with
a preferred format.

IMPORTANT: Our tools still let you use KTX1 for non-compressed images
because it is useful for HDR, but you can no longer use KTX1 for
block-compressed data.

Partial fix for #4771.
2022-04-15 10:48:48 -07:00
Philip Rideout
b60518caa5 Add libs/ktxreader, rename some things to prep for KTX2.
Changes:

- Remove the strange header-only variant of libs/image
- Rename KtxBundle => Ktx1Bundle
- Move image/KtxUtility => ktxreader/Ktx1Reader
- Add unit test for Ktx1Reader and test stub for KTX2.

Notes:

- Ktx1Bundle does not depend on Filament and is used by cmgen
  and mipgen to generate KTX files.

- Ktx1Reader has a dependency on Filament and should therefore live in
  a separate library, which it now does.
2022-04-06 10:56:37 -07:00
Philip Rideout
043fdf7a51 Remove lite flavor from android-utils.
We noticed that the lite flavor isn't actually smaller, plus we need to
rework our Android library hierarchy anyway, so for now let's remove
this.
2022-03-23 11:18:25 -07:00
Philip Rideout
fb627d8b66 gltfio: decouple MaterialProvider lifetime from AssetLoader.
This is a gltfio API change (!)

Jave clients now need to call destroy on MaterialProvider.

Previously, the Java AssetLoader took over ownership of a native
material provider upon construction, but this was neither documented
nor consistent with the C++ layer. (This is historical; in the past we
did not expose MaterialProvider to Java.)

One motivation for this (aside from API consistency) is that users may
wish to preserve the material cache from one run to another.

Fixes #5132.
2022-03-14 08:56:33 -07:00
chubei-oppen
37353cca55 android-utils: Copy bug fixes from upstream (#5279) 2022-03-01 17:32:40 -10:00
chubei-oppen
c72817fc25 Bugfix: Mat4 from Quaternion was transposed (#5277) 2022-03-01 10:08:27 -08:00
chubei-oppen
23b578ef89 Bugfix: lookAt z axis negated 2022-02-24 09:24:57 -08:00
Romain Guy
9491b36a25 It's ok compiler, it's ok 2022-02-15 08:17:10 -08:00
Romain Guy
04337fdb68 Update Kotlin math API to latest (#5152)
Changes incorporated from github.com/romainguy/kotlin-math
2022-02-03 12:17:21 -08:00
Jared Fowler
b67963176b Moving UiHelper to the constructor which allows for more composable control of the underlying views & surface 2022-01-11 08:56:42 -08:00
Ankbzpx
fb1eb35ba5 Fix aabb misalignment for skinned gltf model (#4973) 2022-01-10 15:06:23 -08:00
Romain Guy
332d5681e6 Update dependencies 2021-12-07 09:34:28 -08:00
Romain Guy
2cbacb532a Cache calls to Enum.values() (#4902)
Each call to .values() allocates a new array. Let's cache them once
and for all to avoid unncessary allocations.
2021-11-29 11:35:58 -08:00
Mathias Agopian
1c1cb11cf5 Use the new CallbackHandler in the java bindings
Java callbacks are now directly dispatched to their handler, instead
of first going through filament's opportunistic dispatch, reducing
callback latency.
2021-10-04 10:56:43 -07:00
Mathias Agopian
82623c8fd4 IBLPrefilter relied on finalizer which could cause crashes
The finalizer can't be used to dispose of filament resource, because
it runs on its own thread.

Added a destroy() method to all IBLPrefilter related classes that must
be called once the object is no longer needed.

note: Resources will be freed eventually anyways when the Engine itself is
destroyed.


fixes #4633
2021-09-17 14:34:31 -07:00
Mathias Agopian
52c376a8a7 Fix filament-utils-android 'lite' flavor
Fixes #4601
2021-09-16 14:16:51 -07:00
Romain Guy
8e7aaaa662 Update dependencies and expose Filament as API in gltfio/utils (#4605) 2021-09-10 12:35:19 -07:00
Romain Guy
67b53d0115 Optimize matrix multiplications to avoid allocations (#4350)
The previous code was a lot cleaner but caused 1+N (where N is
the dimension of the matrix) on each multiply.
2021-07-20 17:51:10 -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