Compare commits

..

201 Commits

Author SHA1 Message Date
Romain Guy
2908224c95 Filament 1.4.4 2020-01-09 12:19:05 -08:00
Romain Guy
e011853e7e Update androidx.annotation to 1.1.0 2020-01-09 08:55:43 -08:00
Romain Guy
104105c937 Fix the build 2020-01-08 18:01:18 -08:00
Romain Guy
3fa98419a6 Add more .gitignore 2020-01-08 17:59:49 -08:00
Romain Guy
44d08ce41e Fixup javadocs 2020-01-08 17:55:17 -08:00
Mathias Agopian
0a1c1be00e Refactoring to allow rendering multi-pass rendering
specifically into the same render target.
2020-01-08 16:10:09 -08:00
Mathias Agopian
7efd7abffe Don't combine clearFlags when retrieving a rendertarget
Instead we use the clear flags that the user specified. This is needed
in the case where we're rendering in the target in two passes, the
first pass might want to clear the buffers, while the 2nd one will not.
If we were combining the clear flags, the first pass's flags would be
sticky and the view would always be cleared.

If combining is needed it must be specified by the user.
2020-01-08 16:10:09 -08:00
Mathias Agopian
e27158507e refactor Renderer to make it more flexible
This is in preparation to supporting screen-space effects.
There are two major changes:

- RenderPass is now copiable and intended to be passed by copy to
  the execute stage of frame graph passes

- The color pass is in its own function now


This actually simplify RenderPass api.
2020-01-08 16:10:09 -08:00
Romain Guy
d9ee2fa10d Use a proper Gradle plugin to generate Filament assets in samples (#2018) 2020-01-08 15:45:44 -08:00
Mathias Agopian
b30a7aa5a2 Make ResourceAllocator mockable and update test
We have one very important unit test that is supposed to make sure
the framegraph reuses the same rendertarget between 2 passes, this
unit test would always succeed when using the NoopDriver.
Now that we can mock the ResourceAllocator, we can ensure this unit
test is doing its job.
2020-01-08 15:39:40 -08:00
Mathias Agopian
34c1aaac18 improve cmgen prefiltered cubemaps
Rotate the sample pattern at every light direction, which trades
aliasing for noise (which is arguably more pleasant) for IBLs with
very high frequency (i.e. high level of HDR-ness).
2020-01-08 15:39:21 -08:00
Ben Doherty
8dbb4c6b7e Add new heightfield sample (#2004) 2020-01-08 11:55:28 -08:00
Romain Guy
f5d5afba74 Re-organize Android Gradle files (#2013)
* Re-organize Android Gradle files

Clean up our Gradle files, share versioning, etc. and prepare for
publication to sonatype.

* Use androix annotations for desktop

* Add samples as subprojects to root Gradle

* Fix build script

* Don't break when samples aren't compiled

* Better organize the Android Studio project
2020-01-07 18:37:45 -08:00
Philip Rideout
e09f0bb99f Repair gradle IBL path for gltf_bloom.
I broke this when I changed the cmgen KTX behavior.
2020-01-07 14:05:40 -08:00
Mathias Agopian
fddf51dc74 cmgen -d would force importance sampling mips generation 2020-01-06 17:43:11 -08:00
Mathias Agopian
b8d4b981e0 Better roughness remapping and comments
We were conflating two concepts in our comments about the roughness
remapping, which was confusing. Also changed the remapping so it 
matches a log2 mapping in our default configuration.
2020-01-06 17:42:56 -08:00
Daniel Lehmann
892302442f Fix Backend enum in Java to be consistent with C definition (#2006)
The C definition was changed to include METAL, moving NOOP further down.
The Java definition never caught up, making NOOP mean METAL and making the
real NOOP unreachable.

This patch puts them back in sync. Also, updated the Java comments to match
the comments from the C definition.
2020-01-06 16:27:15 -08:00
Philip Rideout
39046ddfe1 camutils: fix MSVC error. 2020-01-06 16:12:05 -08:00
Philip Rideout
ac14074bc4 camutils: flip zoom to match old manipulator. 2020-01-06 16:12:05 -08:00
Philip Rideout
7d548151d7 Introduce camutils library.
This moves the camera manipulator into its own library and adds new
functionality including a new "Google Maps" manipulator and a bookmark
feature to facilitate camera animation.

Java bindings and an Android sample will land later this week.
2020-01-06 16:12:05 -08:00
Philip Rideout
898ed70aa0 Remove <iostream> from math headers.
This speeds up our build time by using <iosfwd> and un-inlining the
vector print functions.
2020-01-06 15:09:06 -08:00
Romain Guy
78842b59c9 Only build FBX and OBJ importers (#2003) 2020-01-06 14:38:32 -08:00
Ben Doherty
f4f4f9ccd5 Implement flush for Metal backend (#1999) 2020-01-06 12:28:11 -08:00
Mathias Agopian
2ef9d72dbd Simply refraction code
This makes it easier to add new shapes and experiment.
Added a "sold box" shape that is not used yet.
2020-01-06 11:33:06 -08:00
Tim Psiaki
b030f67eb7 Make EntityManager and Panic dynamic-linkable. 2020-01-06 10:24:17 -08:00
Romain Guy
8380a87a6e Update HTML docs 2020-01-05 11:44:45 -08:00
Philip Rideout
06b9bb0c34 gltfio: honor node labels if they exist.
In glTF, multiple nodes can refer to the same mesh, and each node can be
assigned a unqiue string label. Previously we used NameComponentManager
to annotate entities with mesh labels rather than node labels. This was
wrong because Filament entities are 1:1 with nodes, not meshes.

We still fall back to mesh labels when node labels are not provided.
2020-01-03 10:13:59 -08:00
Philip Rideout
17893ecefd Repair Android extension pointers.
Fixes #1989 by fetching extension function pointers that were refactored
in #1977. Moved string-splitting utility to a common location so that
the base class and concrete classes can both use it.
2020-01-03 07:16:56 -08:00
Ben Doherty
efc1b01901 Respect colorWrite in Metal backend (#1996) 2020-01-02 13:36:59 -07:00
Ben Doherty
88fa93f1de Add support for ASTC textures on iOS / Metal (#1992) 2020-01-02 11:35:23 -07:00
Ben Doherty
36385a2432 Improve Metal textures (#1991) 2019-12-30 11:15:04 -07:00
brian.wang
1e05327c5d Fix compile error for VS 2019 16.4.2 with Vulkan (#1990) 2019-12-27 10:44:24 -07:00
Philip Rideout
0b7a08a2d8 Repair web samples by fixing typo in previous fix. 2019-12-18 18:06:21 -08:00
Philip Rideout
237e0ee367 Revert "Revert "gltfio: enable specular AO to "fix" #1870""
This reverts commit f9230856af.
2019-12-18 13:56:13 -08:00
Philip Rideout
f9230856af Revert "gltfio: enable specular AO to "fix" #1870"
This reverts commit 9bf9c3a439.
2019-12-18 13:17:52 -08:00
Philip Rideout
9bf9c3a439 gltfio: enable specular AO to "fix" #1870 2019-12-18 13:07:05 -08:00
Philip Rideout
25c4efd2db cmgen: do not create useless folder for KTX files
With KTX, we should simply create the specified output folder and put
the KTX file(s) in there. There is no need to create a subfolder of the
output folder.

This change also allows users to pick a custom name for their KTX file,
because we only use the "deployment" name when generating filenames.
2019-12-18 13:03:02 -08:00
Ben Doherty
8f6f0ef511 Add continuous build artifacts (#1978) 2019-12-16 10:38:57 -08:00
Pixelflinger
a924fbb490 Better roughness remapping for IBLs
This greatly improves the quality of semi-rough
materials.
2019-12-14 16:36:58 -08:00
Philip Rideout
4c01dfc9fd macOS: fix flash of red upon resize.
Previous to this change, we suffered from a flash-of-red followed by a
flash-with-wrong-projection every time we resized an OpenGL window.

SDL throttles the window resize events, so FilamentApp updates the View
only on the final low-level resize event. However we were calling
Cocoa's update method on every low-level resize event. Thus we were
showing uninitialized content during the resize.

FilamentApp recreates the SwapChain after the final resize event; one
reason for this is the fact that Vulkan swap chains must be recreated.

The fix is to defer the Cocoa update until the swap chain gets
recreated. This is the perfect time because FilamentApp has already set
the new Viewport at this point.
2019-12-14 09:29:35 -08:00
Mathias Agopian
5ee15239fd Split Android specific code out of PlatformEGL (#1977)
We now should be able to use PlatformEGL for all generic EGL platforms
(not tested though). Most texture streaming operations are not supported
in that case, since they're platform specific.
2019-12-13 14:23:19 -08:00
Philip Rideout
69d36b0226 WebGL: fix usage of direction estimator. 2019-12-13 12:46:11 -08:00
Philip Rideout
87db1aaa57 WebGL: remove old broken test. 2019-12-13 12:46:11 -08:00
Philip Rideout
5e096de534 Disable rounding FBO sizes on WebGL. 2019-12-13 12:46:11 -08:00
Philip Rideout
97d53bf7e9 Remove warnings about deadlock. 2019-12-13 10:25:38 -08:00
Philip Rideout
6fbc690097 macOS: pump the event queue while waiting. 2019-12-13 10:25:38 -08:00
Jordan Rupprecht
311f6eacd7 Add missing <assert.h> include. (#1969)
An version of clang is smarter about generating warnings for template code. `assert` here is not included, so clang generates: `error: use of undeclared identifier 'assert'`
2019-12-13 09:26:02 -08:00
Ben Doherty
0dee8c5f34 Deprecate Kokoro-specific logic from build scripts (#1973) 2019-12-12 13:23:43 -08:00
Philip Rideout
ddf85bae72 CMake: add a convenient "run" target for quick testing.
This is just a shortcut for building gltf_viewer, then immediately
running it, which is something we do a lot.
2019-12-12 13:12:23 -08:00
Pixelflinger
695d61f87c fix CubemapUtils::processSingleThreaded()
the state wasn't initialized from the user given prototype
2019-12-11 15:26:12 -08:00
Philip Rideout
9584371f89 macOS: add a check for "is this the right view?" 2019-12-11 14:49:23 -08:00
Philip Rideout
509bfb5b5e Add warnings (hopefully temporary) about macOS deadlock. 2019-12-11 14:49:23 -08:00
Philip Rideout
f853b7dc40 macOS: add cleanup for observer. 2019-12-11 14:49:23 -08:00
Philip Rideout
0693a97577 macOS: fix window resizing regression. 2019-12-11 14:49:23 -08:00
Romain Guy
8e00df1de5 Add Color::absorptionAtDistance() to compute absorption for refraction. (#1964)
Specifying the transmittance color at a specific distance is more
user-friendly than specifying absorption coefficients directly.
2019-12-10 18:20:23 -08:00
Philip Rideout
28f0536b31 Repair JavaScript bindings for IndirectLight. 2019-12-10 18:19:38 -08:00
Mathias Agopian
639bfbfc9a Fix SSAO when blending is used
When doing the depth path for ssao, we need to remove the blended
objects, i.e. produce a depth path similar to the regular depth prepass.

We also need to clear the SAO buffer. It's not needed for opaque
objects because they are written in the SAO's depth buffer. This fixes
"ship in a bottle" scenario.
2019-12-10 17:53:02 -08:00
Philip Rideout
0c734d6db0 Simplify PlatformCocoaGL. 2019-12-10 17:19:41 -08:00
Philip Rideout
e0f5b5125c Fix Catalina by moving some calls to the UI thread.
Fixes #1839.
2019-12-10 17:19:41 -08:00
Philip Rideout
28065e36e8 Make builds less verbose.
Fixes #1956.
2019-12-10 17:19:06 -08:00
Mathias Agopian
8088f0cd6f fix android samples
these samples broke with the new 5 lods ibls
2019-12-10 16:56:19 -08:00
Mathias Agopian
36cdadd238 fix gltf_viewer calculated light position/intensity 2019-12-10 14:44:23 -08:00
Ben Doherty
1061d5c5fa Fix MSVC 2019 16.4 build (#1943) 2019-12-10 13:34:48 -08:00
Mathias Agopian
c1bd438d89 temporary workaround for build break 2019-12-10 12:26:52 -08:00
Pixelflinger
dd8c0a759f Improve IBL's diffuse
If spherical harmonics are not specified in IndirectLight (i.e. 
omitted entirely), we instead use the roughness==1 LOD in the shader.
This produce much better results with absolute HDR environment, and 
generally works better more often.

This is now the preferred solution.

For cases where spherical harmonicas are better or preferred, they
can simply be supplied as before.
2019-12-10 12:26:52 -08:00
Mathias Agopian
0f16f3177e some cmgen fixes
- support equirect/octahedron save in more cases
- apply 1/pi when rendering SH so it's easier to compare 
  (this is used only for debugging anyways)
2019-12-10 12:26:52 -08:00
Ben Doherty
acc2fd9c94 Add depth32 fallback for GPUs without packed depth support (#1957) 2019-12-10 12:23:17 -08:00
Romain Guy
8feb842717 Ignore metallicness when refracted objects don't specify reflectance
Metals need a complex IOR but we only accept a scalar IOR.
2019-12-10 11:56:00 -08:00
Romain Guy
f19eaaa557 Fix directoy based cubemap loading 2019-12-10 10:03:56 -08:00
Romain Guy
3fa0c2d18b Add refraction to material_sandbox 2019-12-10 09:51:54 -08:00
Mathias Agopian
9393e1369b don't apply roughness remapping for solid refraction
The thin roughness remapping only makes sense for thin surfaces, it was
a mistake to apply it to solids. It assumes that a ray will go
undisturbed though the thin surface with an ior of 1.
2019-12-10 00:02:17 -08:00
Ben Doherty
8342b0ecec Update Windows READMEs for building with VS2019 (#1952) 2019-12-09 17:09:45 -08:00
Ben Doherty
9a291b6543 Refactor Metal buffers, allow in-frame vertex and index updates (#1950) 2019-12-09 15:54:40 -08:00
Romain Guy
ec403f8940 Fix material_sandbox 2019-12-09 13:37:09 -08:00
Mathias Agopian
047dab769d fix unit tests 2019-12-09 13:24:49 -08:00
Philip Rideout
5d8cd288d3 Fixed formatting in release notes. 2019-12-09 12:42:17 -08:00
Philip Rideout
8a63682382 Remove unused includes. 2019-12-09 12:41:02 -08:00
Philip Rideout
036f151a42 WebGL: enable depth buffer in swap chain.
In PR #1906 we enabled depth for all backends, but we forgot web.

Note that this required 0 new codelines whereas Vulkan required 116
additional codelines. :)
2019-12-09 10:18:23 -08:00
Ben Doherty
5bc1356192 Update RELEASE_NOTES.md 2019-12-09 10:01:25 -08:00
Ben Doherty
c04a111d10 Fix froxel coordinate calculation on Metal and Vulkan (#1934) 2019-12-09 09:57:59 -08:00
Philip Rideout
da5eabc91f Fix bad state after setIndirectLight(null).
This cleans up 3 related issues, but only the first of these caused an
actual user-visible bug:

(1) When the IBL was null, prepareLighting was failing to bind the black
1x1 texture.

(2) If you added and removed an IBL from a Scene, then Scene was not
returned to its initial state.

(3) The default 1x1 IBL used an intensity of 1 rather than 30000, which
is inconsistent with the null IBL.

Fixes #1940.
2019-12-09 09:30:59 -08:00
Mathias Agopian
79f8947bfa Improve thin layer refraction
We now take into account the light bouncing between the two interfaces
of the materials. We can do this because we assume thin surfaces, 
meaning that the light will exit where it entered and with the same
direction that the specular.

This strengthen the specular at grazing angles (and reduces the transmission).
2019-12-08 22:18:18 -08:00
Mathias Agopian
160a22519e Use unclamped roughness for IBls
This allows us to have sharp reflection and refraction -- the later
is very important.
2019-12-08 22:18:18 -08:00
Mathias Agopian
cc9a1d446c added the concept of micro thickness for thin objects
When dealing with thin objects we really have two thicknesses to 
consider, the thickness in the direction of the normal, which 
corresponds to the value used for solid objects, and the thickness of
the object's walls, which generally is a constant.

Reusing thickness in the later case is problematic for assets that have
a thickness map, but are rendered hollow.

In the future we can even imagine handling double-sided hollow objects
by using the thickness information -- e.g. a hollow cube.
2019-12-08 22:18:18 -08:00
Mathias Agopian
b78ea90c27 apply thin roughness remapping to solid as well
this is because for solids we're also handling both interfaces in one
go (as opposed to calculate the actual btdf), and roughness should
depend on the ior.

Also rename some variables for less confusion (we now use 
incident(I)/refracted(R)).
2019-12-08 22:18:18 -08:00
Mathias Agopian
cbb5d2b423 fix typos and rename refraction to refractionMode 2019-12-08 22:18:18 -08:00
Pixelflinger
c759743e40 Don't saturate absorption, unless it's a constant
Update documentation.
2019-12-08 22:18:18 -08:00
Pixelflinger
3b2ecc6003 Fix a material compiling issue when thickness wasn't defined
We also now assume a thickness of 0, if it's not set in the material.
We don't want to assume any particular thickness, because it depends
on the scene's scale.

Also clamp the remapped roughness.
2019-12-08 22:18:18 -08:00
Mathias Agopian
4790cb5009 Allow materials to override the IOR
Normally the IOR is deduced from the reflectance, but now we allow to
specify the IOR instead or in addition to the reflectance.
In the later case, it's possible to create physically impossible
materials, but this can be useful for artistic reasons.
2019-12-08 22:18:18 -08:00
Pixelflinger
ee0080487a finish plumbing for new material parameters 2019-12-08 22:18:18 -08:00
Pixelflinger
f70b820cbe update material documentation 2019-12-08 22:18:18 -08:00
Pixelflinger
1ccae61d40 shader plumbing for screen-space refraction
In this PR, the filament side is missing, so we're outputting back.
But all codepaths in the shader are implemented:
 cubemap/screenspace, solid/thin
2019-12-08 22:18:18 -08:00
Mathias Agopian
f670472e55 implement thin layers 2019-12-08 22:18:18 -08:00
Mathias Agopian
f94aa731ed Add plumbing for refraction type (solid or thin) 2019-12-08 22:18:18 -08:00
Mathias Agopian
5c80bfe430 update documentations with common IOR values 2019-12-08 22:18:18 -08:00
Mathias Agopian
8d7866b58d apply fresnel to refraction
fixes white furnace test.
2019-12-08 22:18:18 -08:00
Mathias Agopian
179bf03caf implement absorption 2019-12-08 22:18:18 -08:00
Pixelflinger
0371a805ed basic refraction 2019-12-08 22:18:18 -08:00
Pixelflinger
57b48e0719 address reviewers comments
- get rid of "thin layer thickness" property
- make absorption a vec3
2019-12-08 22:18:18 -08:00
Mathias Agopian
eb767abc55 Add material properties needed for refraction 2019-12-08 22:18:18 -08:00
Mathias Agopian
dbda77b091 Improve low roughness significantly
Filament will now allow incomplete mipmap chains for the IBL and
map the roughness to the available chain.

This allows to create roughness cubemaps with a minim size for
roughness==1, instead of always mapping it to 1x1.

cmgen will now use 16x16 cubemaps for roughness==1, which
improves the quality of rough objects significantly.

The beauty of this is that there is no asset or API change. Old assets
will continue to work like before.
2019-12-08 22:17:08 -08:00
Philip Rideout
2c1454270e OpenGL: enable cubemap filtering on desktop.
According to the OpenGL spec, proper cubemap filtering is disabled by
default in non-ES OpenGL.
2019-12-08 22:16:52 -08:00
Mathias Agopian
1ec72e606b Round non-texture FBO attachments to 32 pixels
this helps reducing churn in the resourceallocator cache.
2019-12-06 14:03:07 -08:00
Philip Rideout
24bfdd741a Revert "Fix bad state after setIndirectLight(null)."
This reverts commit f0ce4094dd.
2019-12-06 13:56:21 -08:00
Philip Rideout
f0ce4094dd Fix bad state after setIndirectLight(null).
This cleans up 3 related issues, but only the first of these caused an
actual user-visible bug:

(1) When the IBL was null, prepareLighting was failing to bind the black
1x1 texture.

(2) If you added and removed an IBL from a Scene, then Scene was not
returned to its initial state.

(3) The default 1x1 IBL used an intensity of 1 rather than 30000, which
is inconsistent with the null IBL.

Fixes #1940.
2019-12-06 13:54:49 -08:00
Philip Rideout
9cbcd88d4e WebGL: tweak helmet demo for shadows. 2019-12-06 10:27:00 -08:00
Philip Rideout
8ea6e6ce59 Upgrade hello-camera to use AHardwareBuffer. 2019-12-06 08:46:37 -08:00
Philip Rideout
6d0f8c9ead cmgen: add support for non-RLE HDR images.
The new conditional is cribbed from STB, which checks the first three
bytes.

Fixes #1937.
2019-12-06 08:45:12 -08:00
Philip Rideout
43d91a5c40 Repair twoPassesTwoSides transparency.
This regressed when we added support for dynamic backface culling
(#1641). Also note another fix we made: #1877.
2019-12-05 09:00:57 -08:00
Romain Guy
564e527ac7 Fix docs typo 2019-12-05 10:17:00 +01:00
Philip Rideout
6d3b733cb1 Bump package.json version. 2019-12-04 15:59:52 -08:00
Philip Rideout
0e967726de Simplify CameraManipulator.
This removes a lot of code and will make it easier to migrate into a new
library with Java bindings, etc.

- The clipping planes and projection matrix were unused, removed them.

- In split view mode, our demos were using only 2 of the 3 manipulators,
  removed one.

- Instead of callbacks and update methods, users can simply ask for the
  current matrix at every frame.

- The manipulator's job is to consume mouse events and maintain an
  "look at" basis, there is no need to store a reference to a Filament
  Camera.
2019-12-04 08:05:17 -08:00
Mathias Agopian
001a4c46db Added a property chunk to materials
Materials can now reflect which property is in use.
2019-12-03 17:51:44 -08:00
Mathias Agopian
1a9d0926ee Added a torus and simple cube shapes
renamed "cube.obj" to "rounded_cube.obj", which it was (rounded)
2019-12-03 17:49:40 -08:00
Mathias Agopian
05a756beaa ResourceAllocator: minor clean-up and comments 2019-12-03 17:42:43 -08:00
Mathias Agopian
1014847e9d workaround OpenGLES driver bug
some drivers declare supporting anisotropic filtering, but don't
support calling glSamplerParameter() to set the max anisotropy, presumably because they only support glTexParameter().
We simply turn off anisotropic filtering on these drivers.
2019-12-03 17:41:41 -08:00
Ben Doherty
d3309c2e84 Fix Windows build variants (#1926) 2019-12-02 17:16:15 -08:00
Romain Guy
565002a918 Remove obsolete comment 2019-12-02 14:23:12 -08:00
Romain Guy
08b83e7ed1 Make including jawt_md.h more resilient (#1922)
Sometimes CMake decides to use the JNI bits included with XCode instead
of those from the installed JDK. The header files are located in different
directories. This does the proper include.
2019-12-02 08:45:20 -08:00
Ben Doherty
b4c2f523fe Update RELEASE_NOTES.md 2019-11-27 13:14:12 -08:00
Romain Guy
4ba5d6b9a8 Update release notes 2019-11-27 13:05:34 -08:00
Ben Doherty
59ceb05f99 Add support for mapping individual planes of iOS external images (#1917) 2019-11-27 10:38:13 -08:00
Benjamin Doherty
929c8e96c6 Handle surface size changes in Metal 2019-11-27 01:08:40 -08:00
Philip Rideout
1b5a730358 VulkanDriver: add depth buffer to swap chain. 2019-11-27 01:08:40 -08:00
Benjamin Doherty
79255e8e7d Implement default depth buffer for Metal 2019-11-27 01:08:40 -08:00
Mathias Agopian
50845261fe Swap chains are now always created with a depth buffer
This is to allow direct rendering of 3D objects into the swapchain 
under certain circumstances (no msaa or postprocessing).
2019-11-27 01:08:40 -08:00
Philip Rideout
da090f0ff6 Fix missing call to glInvalidateFramebuffer().
We were over-optimizing, not always honoring the flag. This was
incorrect since bindFramebuffer can be called from other places.

Fixes #1914.
2019-11-26 15:25:59 -08:00
Philip Rideout
60ead8c5f3 Add Android sample for testing the Stream API.
This new sample differs from "Hello Camera" in that it exercises all
three ways of using Stream. It also uses Canvas instead of Camera2 to
draw into the external texture. It shows two sets of stripes, one
animated using the shader and the other animated using Canvas. If the
two stripes are aligned, then the stream is perfectly synchronized.
Users can tap the screen to cycle between the three modes.
2019-11-26 07:58:52 -08:00
Ben Doherty
6942569409 Pass shared context on Windows to wglCreateContextAttribs (#1913) 2019-11-25 13:38:07 -08:00
Romain Guy
498a608941 Remove unused lambda capture 2019-11-23 19:55:05 -08:00
Philip Rideout
eee7154c33 wasm: add support for DEBUG builds by disabling RTTI.
Unfortunately we require RTTI to be disabled for web builds
due to the way in which we handle array buffers. This may change
in the future but for now I think it's an acceptable constraint,
especially given the fact that RTTI adds bloat anyway.
2019-11-22 14:33:03 -08:00
Ben Doherty
a735660af8 Separate resource packages for gltf_viewer and lucy demo (#1908) 2019-11-22 11:34:42 -08:00
Ben Doherty
c5ed7172b3 Add release GitHub workflow (#1903) 2019-11-21 11:04:20 -08:00
Mathias Agopian
4b28362920 Better workaround a resource culling issue.
A texture resource can end-up with not usage bit set if it is used as
an attachment of a render target that gets replaced by a moveResource()
call. The framegraph should take care of culling our this resource,
in that case, but currently doesn't.

We worked around this issue by not declaring the resources, but it's
better to do this in the frame graph code, as to not affect the 
user facing API.
2019-11-20 22:26:00 -08:00
Mathias Agopian
dfeaa416c0 Tone mapping always sets alpha channel to 1 in opaque mode
This fixes an issue where the alpha channel could be left to garbage in
opaque mode with FXAA disabled.
2019-11-20 17:34:59 -08:00
Mathias Agopian
3ce4dd94f7 Use a larger blur filter for SSAO
We go from 9 to 15 taps to better match the 16x16 noise pattern.
2019-11-20 16:32:28 -08:00
Ben Doherty
0ee1d406e0 Update README.md to reflect build link removal (#1902) 2019-11-20 13:29:51 -08:00
Mathias Agopian
dad814e046 Fix a long standing bug preventing the use of transparent views (#1893)
Fix #1165

In order to use transparent views, post-processing had to be disabled
because we were not able to blit post-processed buffers with blending.
This is now fixed by simply reverting to a quad.

A side effect of this, is improved performance when a scaling blit is
needed when MSAA is active.


This also introduced new "bugs", or at least weird behaviors: the
system needs to know when blending is needed, and this has to be
based on heuristics (unless we add a new api). Currently the heuristic
is that the COLOR buffer is not discarded and the view is cleared with 
an alpha value (or not cleared).
2019-11-19 14:05:22 -08:00
Pixelflinger
6246f20e63 Always use SH3 for indirect lighting
We used to use SH2 on mobile/webgl, but the quality degradation is too
prominent. This adds ~16 adds though.
2019-11-19 14:00:37 -08:00
Ben Doherty
f4ad55f6d7 Fix Windows CI failures by specifying shell (#1890) 2019-11-19 11:20:59 -08:00
Pixelflinger
027c4b42f7 fix a few issues with MSAA blits
1) When scaling is enabled, we're using a blit at the end of the frame,
   however, if MSAA is also enabled, this blit is not allowed, so we
   need an explicit MSAA resolve.

2) When rendering directly into the default render target with MSAA
   enabled, we need an explicit resolve ONLY IF there is a format
   conversion, because those are also not allowed. 
   Before, we were doing this resolve regardless.

3) The test for "rendering directly into the default target" had
   become wrong because, the Render target can now be a user texture
   (which is assumed to have the proper MSAA-ness and a depth buffer),
   so no intermediate buffer should be needed for those. We now
   check that render target is actually the default render target
2019-11-18 20:25:53 -08:00
Pixelflinger
fb6c9f8b7d Use 16x16 blue noise for SSAO samples
The larger, blue noise texture gives a more pleasant, smoother SSAO
effect.
2019-11-18 20:25:29 -08:00
Pixelflinger
33d2eaee5b remove old 'SSAO' algorithm 2019-11-18 16:16:29 -08:00
Ben Doherty
ae3ccd7fb6 Implement headless swap chains and readPixels for Metal (#1885) 2019-11-18 11:28:20 -08:00
Russell Chou
72dbea256a Fix comment. 2019-11-16 15:10:15 -08:00
Pixelflinger
ea0ff1bc01 Add a way to override the material of a RenderPass
We used to have this functionality, but it we removed it because we
didn't have a use for it and it was costly.

This new implementation is only internal, and would (will?) be useful
if we wanted to generate a special buffer for SSAO for instance (instead
of just depth). This implementation, overrides the material at the time
the commands are executed, which is much cheaper than the previous
implementation.
2019-11-15 17:37:18 -08:00
Philip Rideout
2bca33f535 gltfio: Use JobSystem to decode PNG / JPEG.
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.
2019-11-15 17:30:52 -08:00
Ben Doherty
75c5bb846b Use checkout action for GitHub Actions (#1886) 2019-11-15 16:33:23 -08:00
Pixelflinger
0da551c7fd More improvements to SSAO
- we add an 'intensity' parameter that allows to control the strength
  of the AO effect. This is useful for aesthetic reasons.

- the default intensity is now 2x that of before this change, which
  makes the intensity parameter match AO papers this implementation
  is inspired of.

- bias is now z-dependent, which reduces some self shadowing wrt the
  depth.
2019-11-15 09:42:37 -08:00
Mathias Agopian
5583dc26f9 Added a parameter to control the bilateral filter
This is needed because filament doesn't make strong assumptions about
the units used (e.g. meters), so we can't hardcode a distance in the
shader. But also, this is a cheap change.
2019-11-15 09:42:37 -08:00
Mathias Agopian
339fa3bd60 SAO and ssaogen cleanup
ssaogen now produces better formatted tables, directly usable in
shader code.

SAO shader now squares the sample radius outside of `tapLocation`, also
added some comments.
2019-11-15 09:42:37 -08:00
Mathias Agopian
dbaaa977e7 Fix depth mipmaping program
Due to a typo, we were using a nearest neighbor downsampling, instead
of picking one of the 4 pixels based on position.
2019-11-15 09:42:37 -08:00
Mathias Agopian
b10e99d374 Turn mipmapDepth material to a post-process material 2019-11-15 09:42:37 -08:00
Philip Rideout
a7d572f060 Stream API: improve dlsym usage. 2019-11-15 08:40:41 -08:00
Philip Rideout
127234f655 Stream API: release image sooner. 2019-11-15 08:40:41 -08:00
Philip Rideout
2c13c8fe6e Stream API: rename createAcquiredImage => transformAcquiredImage. 2019-11-15 08:40:41 -08:00
Philip Rideout
c0b9900cdc Stream API: privatize the AcquiredImage struct. 2019-11-15 08:40:41 -08:00
Philip Rideout
44e8d57935 Stream API: cleanup as per code review feedback. 2019-11-15 08:40:41 -08:00
Philip Rideout
d85f8164c0 Stream API: add support for acquire / release semantics.
Previously, Streams had two modes (native and texid), this adds a third
mode called "acquired", which allows for copy-free synchronized external
textures in OpenGL and paves the way for Vulkan.

The native mode is now deprecated but texid mode needs to stay around
until all clients can be upgraded.

In an early prototype, this functionality was added directly into
Texture but required quite a bit of additional state tracking, so the
Stream API seemed like a better fit.

This API is probably not necessary for Metal due to Metal's shared
ownership semantics.

This has been tested with a new Android sample that will be added in a
subsequent PR.
2019-11-15 08:40:41 -08:00
Mathias Agopian
32407c2ba5 RenderPass cleanup/refactoring
RenderPass's API now doesn't need to know about FScene, instead we
pass the geometry info as parameters.

This is one step towards keeping the "scene" concept more away from
rendering.
2019-11-14 15:31:59 -08:00
Philip Rideout
51e82a5561 Fix dynamic backface culling.
This fixes an oversight in #1641 for scenes that have only 1 primitive
when the depth prepass is enabled. In such cases, the same prim is
rendered twice in a row: once for depth and once for color.

We had enhanced the main render loop to override the primitive's
backface culling state when the material instance changed, but that was
not sufficient since the same material instance can be used for depth
and color passes.

Fixes #1872.
2019-11-13 12:15:44 -08:00
Mathias Agopian
3fb75ca904 custom command support in the renderloop
New internal API to add custom commands (lambda) before or after each
pass. These commands can be added at any point and will be sorted
properly.

e.g.:

    appendCustomCommand(Pass::COLOR, CustomCommand::PROLOG, 0, [](){
       // custom code
    });


Also split appendSortedCommands() in two functions to make it easier
to insert custom commands.
2019-11-13 11:34:34 -08:00
Tim Psiaki
64a70c7c18 Flip Tangents and Bitangents on backfaces. 2019-11-13 11:31:57 -08:00
Mathias Agopian
b9a68090b1 fix a data race on Debug builds
On Debug builds, HeapAllocatorArena needs LockingPolicy::Mutex because
it uses a TrackingPolicy, which needs to be synchronized.
On Release builds, HeapAllocatorArena doesn't need a LockingPolicy 
because HeapAllocator is intrinsically synchronized as it relies on
heap allocations (i.e.: malloc/free)
2019-11-13 09:18:57 -08:00
Mathias Agopian
5344854056 tweak how we invoke commandstream's commands
- this is to allow the use of C++17 std::invoke
- don't std::move() each argument of the tuple<> instead
  std::move() the tuple itself and perfectly-forward each argument.
- handle return values
- handle synchronous commands
2019-11-12 11:29:05 -08:00
Ben Doherty
abad894fd5 Fix UB inside FMaterial (#1862) 2019-11-12 10:08:42 -08:00
Philip Rideout
8872227af5 Fix normals with skinning when there is no normal map.
I tested this with the CesiumMan model, the lighting seems improved
around his hands.

Fixes #1848.
2019-11-11 15:03:17 -08:00
Mathias Agopian
30a07a49d0 add a way to import/export an Entity from/to an integer
This is intended to be used for interop with other programing languages.
2019-11-11 14:37:10 -08:00
Mathias Agopian
0a37cce5fe don't use our own sync primitives when TSAN is used
TSAN seems to have problems with homegrown sync primitives, such as
spinlocks, so we just don't use them when TSAN is enabled.
2019-11-11 14:36:49 -08:00
flashk
fc76ed9949 clampNoV function ignores argument
The "clampNoV" shader function is ignoring the passed dot product argument and recomputing the dot product itself. This will result in the wrong NoV value being used for clear coat IBL computations.
2019-11-08 15:34:25 -08:00
Philip Rideout
d55d042a14 Renderer: call updateStreams AFTER makeCurrent.
When using the OpenGL backend, updateStreams makes GL calls such as
glEGLImageTargetTexture2DOES and therefore requires a valid GL context.
2019-11-08 12:21:25 -08:00
Ben Doherty
d7e07f4d51 Transition to GitHub Actions for continuous builds (#1850) 2019-11-07 13:38:37 -08:00
Ben Doherty
22a6ecadbb Disable RenderingTest from CI test suite (#1858) 2019-11-07 11:17:41 -08:00
Mathias Agopian
53ff133b03 fix a possible memory corruption in debug builds
TrackingPolicy::Debug didn't store the base pointer of the Area, and
instead relied on the first allocation to discover it, however, because
of alignment, the first allocation may not match the base pointer.
Because of that there could be an overflow in onRewind(), i.e. we
could rewind to a pointer before the (wrongly computed) base. This
overflow caused the debug memset to go awry and stomped on memory.

This is fixed by passing the base pointer to the constructor of the
TrackingPolicy. This base pointer could be nullptr with certain
allocators, but in that case, onReset/onRewind should never be called;
and this is enforced at compile time.

Also fixed a (luckily) harmless buffer overflow when preparing the
dynamic lights, if the number of lights wasn't a multiple of 4. This
was harmless because we use a linear allocator, so overflows are not 
really overflows.
2019-11-07 10:03:41 -08:00
Benjamin Doherty
d1ab68ebfa Fix KTX image test on Windows 2019-11-07 09:15:07 -08:00
Philip Rideout
655b7dc13c Emit warning for too many morph targets.
Motivated by #1852.
2019-11-06 15:39:38 -08:00
Philip Rideout
48bfe0453b Fix an assert when the last uniform is an array.
Clients who do not yet have this fix can usually work around this issue
by calling the non-array overload of `MaterialInstance::setParameter`
when the array size is 1.
2019-11-06 15:39:17 -08:00
Philip Rideout
87a05f057a Fix out-of-bounds in an [unused] utility.
This was caught by ASAN.

Our algorithm header has many one-liners that compute the "next power of
two length / 2" but they all have the caveat that if the input is
already POT, then the "/ 2" part does not occur.

Usually we deal with this by testing the difference against zero.
However in `partition_point` we were skipping the test, thus causing a
potential out-of-bounds access.

I fixed `partition_point` and added a few more tests for non-POT cases.
2019-11-05 17:14:15 -08:00
Mathias Agopian
4f540fe7fd Better handling of engine shutdown
- we make sure we don't leak user callbacks or fences
- fix typos
2019-11-05 16:17:46 -08:00
Pixelflinger
1fd675fd09 Make filament's readPixels() asynchronous wrt the GPU
This doesn't change the user facing API because it already used a
callback.

With this change we implement readPixels() with a PBO, which won't
stall the GPU. Then we periodically check a fence to see when the
command is completed, at which point we map the PBO and copy the data
to the user buffer.
2019-11-05 16:17:46 -08:00
Mathias Agopian
bf72adbb57 Implement Headless SwapChain mode.
This is useful for unit tests. The content of the swapchain can be
read to main memory with Renderer::readPixels().


This PR doesn't implement this new feature in the following backends and
platforms (TODO):

VulkanDriver.cpp
MetalDriver.mm

PlatformWGL.cpp
PlatformWebGL.cpp
PlatformCocoaTouchGL.mm
2019-11-05 12:19:29 -08:00
Ben Doherty
dd45703d73 Fix Metal backend crash when rendering external image before set (#1847) 2019-11-05 09:23:58 -08:00
Ben Doherty
7c0d3cdb10 Add EAC / ETC2 and DXT compression formats to Metal backend (#1800) 2019-11-05 09:21:41 -08:00
Mathias Agopian
5462cc0fcf Renderer::readPixels() can now read back from a RenderTarget
Before it was limited to reading back from the SwapChain.
2019-11-04 17:18:39 -08:00
Philip Rideout
8fe9f15b3b JavaScript: add documentation for fetch utility. 2019-11-04 14:20:51 -08:00
Philip Rideout
c49c6e5d19 JavaScript: allow pre-population of asset data.
Fixes #1843.
2019-11-04 14:20:51 -08:00
Philip Rideout
636c54ec6f gltfio: support mesh-level morph weights.
We honored node-level defaults but not mesh-level.

Fixes #1840.
2019-11-04 12:32:02 -08:00
Nicklas Ansman Giertz
52ee07f2fd Add a clarifying comment 2019-11-03 15:03:13 -08:00
Nicklas Ansman Giertz
02ef4a99b7 Add some missing nullability annotations to the gltfio android bindings 2019-11-03 15:03:13 -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
86c0a68ccd Work around unaligned stack with clang 11.
Optimized macOS builds can trigger "stack_not_16_byte_aligned_error"
when building with clang 11. We happen to see this with resgen but it
could happen anywhere.

https://forums.developer.apple.com/thread/121887

Fixes #1823
2019-11-01 13:52:47 -07:00
Ben Doherty
9379e7ce45 Use ARC for Metal backend (#1824) 2019-11-01 10:28:28 -07:00
Philip Rideout
04d2234169 Fix WebGL debug build. 2019-11-01 09:14:38 -07:00
Philip Rideout
66f4419518 gltfio: Fix black default material.
Fixes #1828.
2019-10-31 16:45:01 -07:00
Philip Rideout
be4ad2ec07 WebGL: add a light source to the animation demo. 2019-10-31 16:45:01 -07:00
Philip Rideout
853b2205dd Upgrade emsdk for improved wasm generation.
This uses clang's wasm backend rather than fastcomp.
2019-10-31 16:41:29 -07:00
Philip Rideout
80f104c522 OpenGL: Fix up my previous fix for uvec4 attribs.
The previous fix for #1726 was not quite right because it did not
set the INTEGER flag unless the attribute was declared.

Fixes #1726.
2019-10-31 11:57:43 -07:00
Philip Rideout
1fa2fd9b7f WebGL: add morphing demo. 2019-10-31 11:57:43 -07:00
Philip Rideout
fa108d6a65 Use the Jim Arvo method for transforming AABB's.
This is from the 1990 Graphics Gems article.
2019-10-30 16:15:55 -07:00
719 changed files with 16588 additions and 11468 deletions

View File

@@ -0,0 +1,33 @@
name: Android
on:
push:
branches:
- master
jobs:
build-android:
name: build-android
runs-on: macos-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/android && ./build.sh continuous
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-android
path: out/filament-android-release.aar
- uses: actions/upload-artifact@v1.0.0
with:
name: filamat-android-full
path: out/filamat-android-full-release.aar
- uses: actions/upload-artifact@v1.0.0
with:
name: filamat-android-lite
path: out/filamat-android-lite-release.aar
- uses: actions/upload-artifact@v1.0.0
with:
name: gltfio-android-release
path: out/gltfio-android-release.aar

21
.github/workflows/ios-continuous.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: iOS
on:
push:
branches:
- master
jobs:
build-ios:
name: build-ios
runs-on: macos-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/ios && ./build.sh continuous
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-ios
path: out/filament-release-ios.tgz

21
.github/workflows/linux-continuous.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Linux
on:
push:
branches:
- master
jobs:
build-linux:
name: build-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/linux && ./build.sh continuous
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-linux
path: out/filament-release-linux.tgz

21
.github/workflows/mac-continuous.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: macOS
on:
push:
branches:
- master
jobs:
build-mac:
name: build-mac
runs-on: macos-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/mac && ./build.sh continuous
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-mac
path: out/filament-release-darwin.tgz

View File

@@ -12,15 +12,7 @@ jobs:
os: [macos-latest, ubuntu-latest]
steps:
- name: Checkout Filament
run: |
git version
git init $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
git remote add origin https://github.com/google/filament
git config gc.auto 0
git fetch --tags --prune --progress --no-recurse-submodules origin +${GITHUB_REF}:${GITHUB_REF/refs\//refs\/remote\/}
git checkout --progress --force ${GITHUB_REF/refs\//refs\/remote\/}
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
@@ -33,34 +25,18 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout Filament
run: |
git version
git init %GITHUB_WORKSPACE%
cd %GITHUB_WORKSPACE%
git remote add origin https://github.com/google/filament
git config gc.auto 0
git fetch --tags --prune --progress --no-recurse-submodules origin +%GITHUB_REF%:%GITHUB_REF:refs/=refs/remote/%
git checkout --progress --force %GITHUB_REF:refs/=refs/remote/%
shell: cmd
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
build\windows\build-github.bat
build\windows\build-github.bat presubmit
shell: cmd
build-android:
name: build-android
runs-on: macos-latest
steps:
- name: Checkout Filament
run: |
git version
git init $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
git remote add origin https://github.com/google/filament
git config gc.auto 0
git fetch --tags --prune --progress --no-recurse-submodules origin +${GITHUB_REF}:${GITHUB_REF/refs\//refs\/remote\/}
git checkout --progress --force ${GITHUB_REF/refs\//refs\/remote\/}
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/android && ./build.sh ${TARGET}
@@ -72,15 +48,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout Filament
run: |
git version
git init $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
git remote add origin https://github.com/google/filament
git config gc.auto 0
git fetch --tags --prune --progress --no-recurse-submodules origin +${GITHUB_REF}:${GITHUB_REF/refs\//refs\/remote\/}
git checkout --progress --force ${GITHUB_REF/refs\//refs\/remote\/}
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/ios && ./build.sh ${TARGET}
@@ -92,15 +60,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout Filament
run: |
git version
git init $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
git remote add origin https://github.com/google/filament
git config gc.auto 0
git fetch --tags --prune --progress --no-recurse-submodules origin +${GITHUB_REF}:${GITHUB_REF/refs\//refs\/remote\/}
git checkout --progress --force ${GITHUB_REF/refs\//refs\/remote\/}
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/web && ./build.sh ${TARGET}

175
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,175 @@
name: Release
# This Workflow can be triggered two ways:
# 1. A GitHub release is created (using the GitHub web UI). This triggers all of the platforms to build and upload assets.
# 2. A repository_dispatch API event is sent. This triggers a build for only the platform specified in the dispatch event.
env:
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
on:
repository_dispatch:
release:
types: [created]
jobs:
build-desktop:
name: build-desktop
runs-on: ${{ matrix.os }}
if: github.event_name == 'release' || github.event.client_payload.platform == 'desktop'
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
steps:
- name: Decide Git ref
id: git_ref
run: |
REF=${RELEASE_TAG:-${GITHUB_REF}}
TAG=${REF##*/}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag::${TAG}
- uses: actions/checkout@v1.0.0
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
run: |
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
cd build/$WORKFLOW_OS && ./build.sh release
- name: Upload release assets
run: |
pip3 install setuptools
pip3 install PyGithub
DATE=`date +%Y%m%d`
if [ -f out/filament-release-darwin.tgz ]; then mv out/filament-release-darwin.tgz out/filament-${DATE}-mac.tgz; fi;
if [ -f out/filament-release-linux.tgz ]; then mv out/filament-release-linux.tgz out/filament-${DATE}-linux.tgz; fi;
python3 build/common/upload-assets.py ${TAG} out/*.tgz
env:
TAG: ${{ steps.git_ref.outputs.tag }}
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
build-web:
name: build-web
runs-on: macos-latest
if: github.event_name == 'release' || github.event.client_payload.platform == 'web'
steps:
- name: Decide Git ref
id: git_ref
run: |
REF=${RELEASE_TAG:-${GITHUB_REF}}
TAG=${REF##*/}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag::${TAG}
- uses: actions/checkout@v1.0.0
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
run: |
cd build/web && ./build.sh release
- name: Upload release assets
run: |
pip3 install setuptools
pip3 install PyGithub
DATE=`date +%Y%m%d`
mv out/filament-release-web.tgz out/filament-${DATE}-web.tgz
python3 build/common/upload-assets.py ${TAG} out/*.tgz
env:
TAG: ${{ steps.git_ref.outputs.tag }}
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
build-android:
name: build-android
runs-on: macos-latest
if: github.event_name == 'release' || github.event.client_payload.platform == 'android'
steps:
- name: Decide Git ref
id: git_ref
run: |
REF=${RELEASE_TAG:-${GITHUB_REF}}
TAG=${REF##*/}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag::${TAG}
- uses: actions/checkout@v1.0.0
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
run: |
cd build/android && ./build.sh release
- name: Upload release assets
run: |
pip3 install setuptools
pip3 install PyGithub
DATE=`date +%Y%m%d`
mv out/filament-android-release.aar out/filament-${DATE}-android.aar
mv out/filamat-android-full-release.aar out/filamat-${DATE}-full-android.aar
mv out/filamat-android-lite-release.aar out/filamat-${DATE}-lite-android.aar
mv out/gltfio-android-release.aar out/gltfio-${DATE}-android.aar
python3 build/common/upload-assets.py ${TAG} out/*.aar
env:
TAG: ${{ steps.git_ref.outputs.tag }}
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
build-ios:
name: build-ios
runs-on: macos-latest
if: github.event_name == 'release' || github.event.client_payload.platform == 'ios'
steps:
- name: Decide Git ref
id: git_ref
run: |
REF=${RELEASE_TAG:-${GITHUB_REF}}
TAG=${REF##*/}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag::${TAG}
- uses: actions/checkout@v1.0.0
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
run: |
cd build/ios && ./build.sh release
- name: Upload release assets
run: |
pip3 install setuptools
pip3 install PyGithub
DATE=`date +%Y%m%d`
mv out/filament-release-ios.tgz out/filament-${DATE}-ios.tgz
python3 build/common/upload-assets.py ${TAG} out/*.tgz
env:
TAG: ${{ steps.git_ref.outputs.tag }}
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
build-windows:
name: build-windows
runs-on: windows-latest
if: github.event_name == 'release' || github.event.client_payload.platform == 'windows'
steps:
- name: Decide Git ref
id: git_ref
run: |
REF=${RELEASE_TAG:-${GITHUB_REF}}
TAG=${REF##*/}
echo ::set-output name=ref::${REF}
echo ::set-output name=tag::${TAG}
shell: bash
- uses: actions/checkout@v1.0.0
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
run: |
build\windows\build-github.bat release
shell: cmd
- name: Upload release assets
run: |
pip3 install PyGithub
DATE=`date +%Y%m%d`
mv out/filament-windows.tgz out/filament-${DATE}-windows.tgz
python build/common/upload-assets.py ${TAG} out/*.tgz
shell: bash
env:
TAG: ${{ steps.git_ref.outputs.tag }}
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}

21
.github/workflows/web-continuous.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Web
on:
push:
branches:
- master
jobs:
build-web:
name: build-web
runs-on: macos-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
cd build/web && ./build.sh continuous
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-web
path: out/filament-release-web.tgz

View File

@@ -0,0 +1,22 @@
name: Windows
on:
push:
branches:
- master
jobs:
build-windows:
name: build-windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Run build script
run: |
build\windows\build-github.bat continuous
shell: cmd
- uses: actions/upload-artifact@v1.0.0
with:
name: filament-windows
path: out/filament-windows.tgz

View File

@@ -50,22 +50,19 @@ if (WIN32)
set(CRT_FLAGS_DEBUG "/MDd")
endif()
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
# TODO: Figure out why pdb generation messes with incremental compilaton.
# IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
# In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation.
# Instead generate debug info directly inside obj files.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
endif()
# TODO: Figure out why pdb generation messes with incremental compilaton.
# IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
# In RELEASE, also generate PDBs.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi")
# In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation.
# Instead generate debug info directly inside obj files.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
endif()
# ==================================================================================================
@@ -211,6 +208,13 @@ if (ANDROID OR WEBGL)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
endif()
# With WebGL, we disable RTTI even for debug builds because we pass emscripten::val back and forth
# between C++ and JavaScript in order to efficiently access typed arrays, which are unbound.
# NOTE: This is not documented in emscripten so we should consider a different approach.
if (WEBGL)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-rtti")
endif()
# ==================================================================================================
# Debug compiler flags
# ==================================================================================================
@@ -219,16 +223,24 @@ endif()
# -fsanitize=address causes a crash with assimp, which we can't explain for now
#set(EXTRA_SANITIZE_OPTIONS "-fsanitize=undefined -fsanitize=address")
# clang-cl.exe on Windows does not support -fstack-protector.
if (NOT CLANG_CL AND NOT MSVC)
if (NOT CLANG_CL AND NOT MSVC AND NOT WEBGL)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}")
# Disable the stack check for macOS to workaround a known issue in clang 11.0.0.
# See: https://forums.developer.apple.com/thread/121887
if (APPLE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-check")
endif()
# ==================================================================================================
# Linker flags
# ==================================================================================================
# Strip unused sections
set(GC_SECTIONS "-Wl,--gc-sections")
if (NOT WEBGL)
set(GC_SECTIONS "-Wl,--gc-sections")
endif()
set(B_SYMBOLIC_FUNCTIONS "-Wl,-Bsymbolic-functions")
if (APPLE)
@@ -443,6 +455,7 @@ endfunction()
# Common to all platforms
add_subdirectory(${EXTERNAL}/libgtest/tnt)
add_subdirectory(${LIBRARIES}/camutils)
add_subdirectory(${LIBRARIES}/filabridge)
add_subdirectory(${LIBRARIES}/filaflat)
add_subdirectory(${LIBRARIES}/filameshio)

164
README.md
View File

@@ -1,11 +1,11 @@
# Filament
<img alt="Android" src="build/img/android.png" width="20px" height="20px" hspace="2px"/>[![Android Build Status](https://filament-build.storage.googleapis.com/badges/build_status_android.svg)](https://filament-build.storage.googleapis.com/badges/build_link_android.html)
<img alt="iOS" src="build/img/macos.png" width="20px" height="20px" hspace="2px"/>[![iOS Build Status](https://filament-build.storage.googleapis.com/badges/build_status_ios.svg)](https://filament-build.storage.googleapis.com/badges/build_link_ios.html)
<img alt="Linux" src="build/img/linux.png" width="20px" height="20px" hspace="2px"/>[![Linux Build Status](https://filament-build.storage.googleapis.com/badges/build_status_linux.svg)](https://filament-build.storage.googleapis.com/badges/build_link_linux.html)
<img alt="macOS" src="build/img/macos.png" width="20px" height="20px" hspace="2px"/>[![MacOS Build Status](https://filament-build.storage.googleapis.com/badges/build_status_mac.svg)](https://filament-build.storage.googleapis.com/badges/build_link_mac.html)
<img alt="Windows" src="build/img/windows.png" width="20px" height="20px" hspace="2px"/>[![Windows Build Status](https://filament-build.storage.googleapis.com/badges/build_status_windows.svg)](https://filament-build.storage.googleapis.com/badges/build_link_windows.html)
<img alt="Web" src="build/img/web.png" width="20px" height="20px" hspace="2px"/>[![Web Build Status](https://filament-build.storage.googleapis.com/badges/build_status_web.svg)](https://filament-build.storage.googleapis.com/badges/build_link_web.html)
![Android Build Status](https://github.com/google/filament/workflows/Android/badge.svg)
![iOS Build Status](https://github.com/google/filament/workflows/iOS/badge.svg)
![Linux Build Status](https://github.com/google/filament/workflows/Linux/badge.svg)
![macOS Build Status](https://github.com/google/filament/workflows/macOS/badge.svg)
![Windows Build Status](https://github.com/google/filament/workflows/Windows/badge.svg)
![Web Build Status](https://github.com/google/filament/workflows/Web/badge.svg)
Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows,
and WebGL. It is designed to be as small as possible and as efficient as possible on Android.
@@ -21,8 +21,13 @@ Android devices and as the renderer inside the Android Studio plugin.
Make sure you always use tools from the same release as the runtime library. This is particularly
important for `matc` (material compiler).
If you prefer to live on the edge, you can download a continuous build by clicking one of the build
badges above.
If you prefer to live on the edge, you can download a continuous build by following the following
steps:
1. Find the [commit](https://github.com/bejado/filament/commits/master) you're interested in.
2. Click the green check mark under the commit message.
3. Click on the _Details_ link for the platform you're interested in.
4. On the top right, click on the _Artifacts_ dropdown and choose an artifact.
## Documentation
@@ -116,9 +121,9 @@ This repository not only contains the core Filament engine, but also its support
and tools.
- `android`: Android libraries and projects
- `build`: Custom Gradle tasks for Android builds
- `filamat-android`: Filament material generation library (AAR) for Android
- `filament-android`: Filament library (AAR) for Android
- `gltfio-android`: Filament glTF loading library (AAR) for Android
- `samples`: Android-specific Filament samples
- `art`: Source for various artworks (logos, PDF manuals, etc.)
- `assets`: 3D assets to use with sample applications
@@ -363,14 +368,18 @@ See [ios/samples/README.md](./ios/samples/README.md) for more information.
### Windows
#### Building on Windows with the Visual Studio 2019 compiler
#### Building on Windows with Visual Studio 2019
Install the following components:
- [Visual Studio 2019](https://www.visualstudio.com/downloads)
- [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
- [Python 3.7](https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe)
- [CMake 3.14 or later](https://github.com/Kitware/CMake/releases/download/v3.14.7/cmake-3.14.7-win64-x64.msi)
The latest Windows SDK can also by installed by opening Visual Studio and selecting _Get Tools and
Features..._ under the _Tools_ menu.
Open the `x64 Native Tools Command Prompt for VS 2019`.
Create a working directory, and run cmake in it:
@@ -381,122 +390,17 @@ Create a working directory, and run cmake in it:
> cmake ..
```
Then, you should be able to load the generated solution file `TNT.sln` in Visual Studio and build the `material_sandbox` project.
Open the generated solution file `TNT.sln` in Visual Studio.
To build all targets, run _Build Solution_ from the _Build_ menu. Alternatively, right click on a
target in the _Solution Explorer_ and choose _Build_ to build a specific target.
For example, build the `material_sandbox` sample and run it from the `out` directory with:
Run it from the `out` directory with:
```
> samples\Debug\material_sandbox.exe ..\assets\models\monkey\monkey.obj
```
#### Building on Windows with the Clang compiler
The following instructions have been tested on a machine running Windows 10. They should take you
from a machine with only the operating system to a machine able to build and run Filament.
Google employees require additional steps which can be found here [go/filawin](http://go/filawin).
Install the following components:
- [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
- [Visual Studio 2015 or 2017](https://www.visualstudio.com/downloads)
- [Clang 7](http://releases.llvm.org/download.html)
- [Python 3.7](https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe)
- [Cmake 3.13 or later](https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-win64-x64.msi)
If you're using Visual Studio 2017, you'll also need to install the [LLVM Compiler
Toolchain](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain)
extension.
Open an appropriate Native Tools terminal for the version of Visual Studio you are using:
- VS 2015: VS2015 x64 Native Tools Command Prompt
- VS 2017: x64 Native Tools Command Prompt for VS 2017
You can find these by clicking the start button and typing "x64 native tools".
Create a working directory:
```
> mkdir out/cmake-release
> cd out/cmake-release
```
Create the msBuild project:
```
# Visual Studio 2015:
> cmake -T"LLVM-vs2014" -G "Visual Studio 14 2015 Win64" ../..
# Visual Studio 2017
> cmake ..\.. -T"LLVM" -G "Visual Studio 15 2017 Win64" ^
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe"
```
Check out the output and make sure Clang for Windows frontend was found. You should see a line
showing the following output. Note that for Visual Studio 2017 this line may list Microsoft's
compiler, but the build will still in fact use Clang and you can proceed.
```
Clang:C:/Program Files/LLVM/msbuild-bin/cl.exe
```
You are now ready to build:
```
> msbuild TNT.sln /t:material_sandbox /m /p:configuration=Release
```
Run it:
```
> samples\Release\material_sandbox.exe ..\..\assets\models\monkey\monkey.obj
```
#### Tips
- To troubleshoot an issue, use verbose mode via `/v:d` flag.
- To build a specific project, use `/t:NAME` flag (e.g: `/t:material_sandbox`).
- To build using more than one core, use parallel build flag: `/m`.
- To build a specific profile, use `/p:configuration=` (e.g: `/p:configuration=Debug`,
`/p:configuration=Release`, and `/p:configuration=RelWithDebInfo`).
- The msBuild project is what is used by Visual Studio behind the scene to build. Building from VS
or from the command-line is the same thing.
#### Building with Ninja on Windows
Alternatively, you can use [Ninja](https://ninja-build.org/) to build for Windows. An MSVC
installation is still necessary.
First, install the dependencies listed under [Windows](#Windows) as well as Ninja. Then open up a
Native Tools terminal as before. Create a build directory inside Filament and run the
following CMake command:
```
> cmake .. -G Ninja ^
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe" ^
-DCMAKE_BUILD_TYPE=Release
```
You should then be able to build by invoking Ninja:
```
> ninja
```
#### Development tips
- Before shipping a binary, make sure you used Release profile and make sure you have no libc/libc++
dependencies with [Dependency Walker](http://www.dependencywalker.com).
- Application Verifier and gflags.exe can be of great help to trackdown heap corruption. Application
Verifier is easy to setup with a GUI. For gflags, use: `gflags /p /enable pheap-buggy.exe`.
#### Running a simple test
To confirm Filament was properly built, run the following command from the build directory:
```
> samples\material_sandbox.exe --ibl=..\..\samples\envs\pillars ..\..\assets\models\sphere\sphere.obj
```
### Android
Before building Filament for Android, make sure to build Filament for your host. Some of the
@@ -644,7 +548,7 @@ as explained in the sections above. You must have the following ABIs built in
- `x86_64`
- `x86`
To build Filament's AAR simply open the Android Studio project in `android/filament-android`. The
To build Filament's AAR simply open the Android Studio project in `android/`. The
AAR is a universal AAR that contains all supported build targets:
- `arm64-v8a`
@@ -655,8 +559,8 @@ AAR is a universal AAR that contains all supported build targets:
To filter out unneeded ABIs, rely on the `abiFilters` of the project that links against Filament's
AAR.
Alternatively you can build the AAR from the command line by executing the following the
`android/filament-android` directory:
Alternatively you can build the AAR from the command line by executing the following in the
`android/` directory:
```
$ ./gradlew -Pfilament_dist_dir=../../out/android-release/filament assembleRelease
@@ -717,13 +621,11 @@ same version that our continuous builds use.
```
cd <your chosen parent folder for the emscripten SDK>
curl -L https://github.com/emscripten-core/emsdk/archive/a77638d.zip > emsdk.zip
unzip emsdk.zip
mv emsdk-* emsdk
cd emsdk
./emsdk update
./emsdk install sdk-1.38.28-64bit
./emsdk activate sdk-1.38.28-64bit
curl -L https://github.com/emscripten-core/emsdk/archive/1b1f08f.zip > emsdk.zip
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
./emsdk install lastest
./emsdk activate lastest
source ./emsdk_env.sh
```
After this you can invoke the [easy build](#easy-build) script as follows:

View File

@@ -3,6 +3,36 @@
This file contains one line summaries of commits that are worthy of mentioning in release notes.
A new header is inserted each time a *tag* is created.
## Next release
## v1.4.4
- Added support for solid and thin layer cubemap and screen-space refraction.
- Improved high roughness material rendering by default when regenerating environments maps.
- Fix bad instruction exception with macOS Catalina.
- Fixed bad state after removing an IBL from the Scene.
- Fixed incorrect punctual light binning (affected Metal and Vulkan backends).
- Fixed crash when using a Metal headless SwapChain with an Intel integrated GPU.
- Added support for ASTC textures on iOS with Metal backend.
- Added new heightfield sample.
- Removed `<iostream>` from math headers.
- cmgen now places KTX files directly in the specified deployment folder.
## v1.4.3
- Fixed an assertion when a parameter array occurs last in a material definition.
- Fixed morph shapes not rendering in WebGL.
- Added support for the latest version of emscripten.
- gltfio: fixed blackness seen with default material.
- Added ETC2 and BC compressed texture support to Metal backend.
- Rendering a `SAMPLER_EXTERNAL` texture before setting an external image no longer results in GPU errors.
- Fixed a normals issue when skinning without a normal map or anisotropy.
- Fixed an issue where transparent views couldn't be used with post-processing.
- Always use higher quality 3-bands SH for indirect lighting, even on mobile.
- The Metal backend can now handle binding individual planes of YUV external images.
- Added support for depth buffer when post-processing is turned off
- Improved performance on GPUs that use tile-based rendering
## v1.4.2
- Cleaned up the validation strategy in Engine (checks for use-after-destroy etc).
@@ -11,6 +41,7 @@ A new header is inserted each time a *tag* is created.
- gltfio: Added Java / Kotlin bindings for Animator.
- gltfio: Fixed panic with the Android gltf-bloom demo.
- gltfio: Java clients should no longer call Filament#init.
- Improved IBL diffuse by allowing to use the specular cubemap at `roughness` = 1 instead of Spherical Harmonics
## v1.4.1

9
android/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
/.idea/gradle.xml
.DS_Store
/build/

57
android/build.gradle Normal file
View File

@@ -0,0 +1,57 @@
// This script accepts the following parameters:
//
// filament_dist_dir
// Path to the Filament distribution/install directory for Android
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
//
// Example:
// ./gradlew -Pfilament_dist_dir=../dist-android-release assembleRelease
buildscript {
def filamentPath = file("../out/android-release/filament").absolutePath
if (project.hasProperty("filament_dist_dir")) {
filamentPath = file("$filament_dist_dir").absolutePath
}
ext.filamentPath = filamentPath
// Our minSdkVersion is actually 19, we lie and say 14 here so apps don't have
// to increase their minSdkVersion unnecessarily. It is however up to them to
// ensure they do not initialize Filament on API levels < 19.
ext.versions = [
'minSdk': 14,
'targetSdk': 29,
'compileSdk': 29,
'kotlin': '1.3.61',
]
ext.deps = [
'androidx': [
'annotations': "androidx.annotation:annotation:1.1.0",
'core': "androidx.core:core:1.1.0",
],
'kotlin': "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
]
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}
}
subprojects { project ->
group = GROUP
version = VERSION_NAME
repositories {
mavenCentral()
google()
jcenter()
}
}

9
android/buildSrc/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
/.idea/gradle.xml
.DS_Store
/build/

View File

@@ -9,61 +9,63 @@
import java.nio.file.Paths
import org.gradle.internal.os.OperatingSystem
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.*
import org.gradle.api.logging.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.incremental.*
def filamentToolsPath = file("../../../../out/release/filament")
if (project.hasProperty("filament_tools_dir")) {
filamentToolsPath = file("$filament_tools_dir")
}
class TaskWithBinary extends DefaultTask {
private final String binaryName
private File binaryPath = null
List<File> getBinaries(String name, File toolsPath) {
def tool = ["/bin/${name}.exe", "/bin/${name}"]
def toolFullPath = tool.collect { path -> Paths.get(toolsPath.absolutePath, path).toFile() }
// Ensure that at least one matc binary and Filament library is present
if (!toolFullPath.any { path -> file(path).exists() }) {
throw new StopActionException("No ${name} binary could be found in " + toolsPath +
"/bin. Ensure Filament has been built/installed before building this app.")
TaskWithBinary(String name) {
binaryName = name
}
return toolFullPath
}
String getBinaryName() {
return binaryName
}
ext.matcFullPath = getBinaries('matc', filamentToolsPath)
ext.cmgenFullPath = getBinaries('cmgen', filamentToolsPath)
ext.filameshFullPath = getBinaries('filamesh', filamentToolsPath)
ext.resgenFullPath = getBinaries('resgen', filamentToolsPath)
File getBinary() {
if (binaryPath == null) {
def tool = ["/bin/${binaryName}.exe", "/bin/${binaryName}"]
def fullPath = tool.collect { path ->
Paths.get(project.ext.filamentToolsPath.absolutePath, path).toFile()
}
binaryPath = OperatingSystem.current().isWindows() ? fullPath[0] : fullPath[1]
}
return binaryPath
}
}
class LogOutputStream extends ByteArrayOutputStream {
private final Logger logger;
private final LogLevel level;
private final Logger logger
private final LogLevel level
public LogOutputStream(Logger logger, LogLevel level) {
this.logger = logger;
this.level = level;
LogOutputStream(Logger logger, LogLevel level) {
this.logger = logger
this.level = level
}
public Logger getLogger() {
return logger;
Logger getLogger() {
return logger
}
public LogLevel getLevel() {
return level;
LogLevel getLevel() {
return level
}
@Override
public void flush() {
logger.log(level, toString());
reset();
void flush() {
logger.log(level, toString())
reset()
}
}
// Custom task to compile material files using matc
// This task handles incremental builds
class MaterialCompiler extends DefaultTask {
File matcPath
class MaterialCompiler extends TaskWithBinary {
@SuppressWarnings("GroovyUnusedDeclaration")
@InputDirectory
File inputDir
@@ -72,8 +74,7 @@ class MaterialCompiler extends DefaultTask {
File outputDir
MaterialCompiler() {
matcPath = OperatingSystem.current().isWindows() ?
project.ext.matcFullPath[0] : project.ext.matcFullPath[1]
super("matc")
}
@SuppressWarnings("GroovyUnusedDeclaration")
@@ -94,10 +95,15 @@ class MaterialCompiler extends DefaultTask {
out.write(header)
out.flush()
if (!getBinary().exists()) {
throw new GradleException("Could not find ${getBinary()}." +
" Ensure Filament has been built/installed before building this app.")
}
project.exec {
standardOutput out
errorOutput err
executable "${matcPath}"
executable "${getBinary()}"
args('-a', 'all', '-p', 'mobile', '-o', getOutputFile(file), file)
}
}
@@ -114,9 +120,8 @@ class MaterialCompiler extends DefaultTask {
// Custom task to process IBLs using cmgen
// This task handles incremental builds
class IblGenerator extends DefaultTask {
File cmgenPath
String cmgenArgs = null;
class IblGenerator extends TaskWithBinary {
String cmgenArgs = null
@SuppressWarnings("GroovyUnusedDeclaration")
@InputFile
@@ -126,8 +131,7 @@ class IblGenerator extends DefaultTask {
File outputDir
IblGenerator() {
cmgenPath = OperatingSystem.current().isWindows() ?
project.ext.cmgenFullPath[0] : project.ext.cmgenFullPath[1]
super("cmgen")
}
@SuppressWarnings("GroovyUnusedDeclaration")
@@ -147,21 +151,20 @@ class IblGenerator extends DefaultTask {
out.write(header)
out.flush()
project.exec {
standardOutput out
errorOutput err
executable "${cmgenPath}"
args('-x', outputDir, file)
if (!getBinary().exists()) {
throw new GradleException("Could not find ${getBinary()}." +
" Ensure Filament has been built/installed before building this app.")
}
project.exec {
standardOutput out
if (!cmgenArgs) {
cmgenArgs = '--format=rgb32f --extract-blur=0.08 --extract=' + outputDir.absolutePath
cmgenArgs = '-q -x ' + outputDir +
' --format=rgb32f --extract-blur=0.08 --extract=' + outputDir.absolutePath
}
cmgenArgs = cmgenArgs + " " + file
errorOutput err
executable "${cmgenPath}"
executable "${getBinary()}"
args(cmgenArgs.split())
}
}
@@ -178,9 +181,7 @@ class IblGenerator extends DefaultTask {
// Custom task to compile mesh files using filamesh
// This task handles incremental builds
class MeshCompiler extends DefaultTask {
File filameshPath
class MeshCompiler extends TaskWithBinary {
@SuppressWarnings("GroovyUnusedDeclaration")
@InputFile
File inputFile
@@ -189,8 +190,7 @@ class MeshCompiler extends DefaultTask {
File outputDir
MeshCompiler() {
filameshPath = OperatingSystem.current().isWindows() ?
project.ext.filameshFullPath[0] : project.ext.filameshFullPath[1]
super("filamesh")
}
@SuppressWarnings("GroovyUnusedDeclaration")
@@ -210,10 +210,15 @@ class MeshCompiler extends DefaultTask {
out.write(header)
out.flush()
if (!getBinary().exists()) {
throw new GradleException("Could not find ${getBinary()}." +
" Ensure Filament has been built/installed before building this app.")
}
project.exec {
standardOutput out
errorOutput err
executable "${filameshPath}"
executable "${getBinary()}"
args(file, getOutputFile(file))
}
}
@@ -228,8 +233,50 @@ class MeshCompiler extends DefaultTask {
}
}
task compileMaterials(type: MaterialCompiler)
class FilamentToolsPluginExtension {
File materialInputDir
File materialOutputDir
task generateIbl(type: IblGenerator)
String cmgenArgs
File iblInputFile
File iblOutputDir
task compileMesh(type: MeshCompiler)
File meshInputFile
File meshOutputDir
}
class FilamentToolsPlugin implements Plugin<Project> {
void apply(Project project) {
def extension = project.extensions.create('filamentTools', FilamentToolsPluginExtension)
project.ext.filamentToolsPath = project.file("../../../out/release/filament")
if (project.hasProperty("filament_tools_dir")) {
project.ext.filamentToolsPath = project.file("$filament_tools_dir")
}
project.tasks.register("filamentCompileMaterials", MaterialCompiler) {
enabled = extension.materialInputDir != null && extension.materialOutputDir != null
inputDir = extension.materialInputDir
outputDir = extension.materialOutputDir
}
project.preBuild.dependsOn "filamentCompileMaterials"
project.tasks.register("filamentGenerateIbl", IblGenerator) {
enabled = extension.iblInputFile != null && extension.iblOutputDir != null
cmgenArgs = extension.cmgenArgs
inputFile = extension.iblInputFile
outputDir = extension.iblOutputDir
}
project.preBuild.dependsOn "filamentGenerateIbl"
project.tasks.register("filamentCompileMesh", MeshCompiler) {
enabled = extension.meshInputFile != null && extension.meshOutputDir != null
inputFile = extension.meshInputFile
outputDir = extension.meshOutputDir
}
project.preBuild.dependsOn "filamentCompileMesh"
}
}

View File

@@ -27,39 +27,6 @@ struct {
jmethodID execute;
} gCallbackUtils;
JniCallback* JniCallback::make(filament::Engine* engine,
JNIEnv* env, jobject handler, jobject callback) {
void* that = engine->streamAlloc(sizeof(JniCallback), alignof(JniCallback));
return new (that) JniCallback(env, handler, callback);
}
JniCallback::JniCallback(JNIEnv* env, jobject handler, jobject callback)
: mEnv(env)
, mHandler(env->NewGlobalRef(handler))
, mCallback(env->NewGlobalRef(callback)) {
}
JniCallback::~JniCallback() {
if (mHandler && mCallback) {
#ifdef ANDROID
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.handlerClass)) {
mEnv->CallBooleanMethod(mHandler, gCallbackUtils.post, mCallback);
}
#endif
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.executorClass)) {
mEnv->CallVoidMethod(mHandler, gCallbackUtils.execute, mCallback);
}
}
mEnv->DeleteGlobalRef(mHandler);
mEnv->DeleteGlobalRef(mCallback);
}
void JniCallback::invoke(void*, size_t, void* user) {
JniCallback* data = reinterpret_cast<JniCallback*>(user);
// don't call delete here, because we don't own the storage
data->~JniCallback();
}
JniBufferCallback* JniBufferCallback::make(filament::Engine* engine,
JNIEnv* env, jobject handler, jobject callback, AutoBuffer&& buffer) {
void* that = engine->streamAlloc(sizeof(JniBufferCallback), alignof(JniBufferCallback));
@@ -95,6 +62,37 @@ void JniBufferCallback::invoke(void*, size_t, void* user) {
data->~JniBufferCallback();
}
JniImageCallback* JniImageCallback::make(filament::Engine* engine,
JNIEnv* env, jobject handler, jobject callback, long image) {
void* that = engine->streamAlloc(sizeof(JniImageCallback), alignof(JniImageCallback));
return new (that) JniImageCallback(env, handler, callback, image);
}
JniImageCallback::JniImageCallback(JNIEnv* env, jobject handler, jobject callback, long image)
: mEnv(env)
, mHandler(env->NewGlobalRef(handler))
, mCallback(env->NewGlobalRef(callback))
, mImage(image) { }
JniImageCallback::~JniImageCallback() {
if (mHandler && mCallback) {
#ifdef ANDROID
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.handlerClass)) {
mEnv->CallBooleanMethod(mHandler, gCallbackUtils.post, mCallback);
}
#endif
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.executorClass)) {
mEnv->CallVoidMethod(mHandler, gCallbackUtils.execute, mCallback);
}
}
mEnv->DeleteGlobalRef(mHandler);
mEnv->DeleteGlobalRef(mCallback);
}
void JniImageCallback::invoke(void* image, void* user) {
reinterpret_cast<JniImageCallback*>(user)->~JniImageCallback();
}
void registerCallbackUtils(JNIEnv *env) {
#ifdef ANDROID
gCallbackUtils.handlerClass = env->FindClass("android/os/Handler");

View File

@@ -23,21 +23,6 @@
#include <filament/Engine.h>
struct JniCallback {
static JniCallback* make(filament::Engine* engine,
JNIEnv* env, jobject handler, jobject callback);
static void invoke(void* buffer, size_t n, void* user);
private:
JniCallback(JNIEnv* env, jobject handler, jobject callback);
~JniCallback();
JNIEnv* mEnv;
jobject mHandler;
jobject mCallback;
};
struct JniBufferCallback {
static JniBufferCallback* make(filament::Engine* engine,
JNIEnv* env, jobject handler, jobject callback, AutoBuffer&& buffer);
@@ -53,3 +38,19 @@ private:
jobject mCallback;
AutoBuffer mBuffer;
};
struct JniImageCallback {
static JniImageCallback* make(filament::Engine* engine, JNIEnv* env, jobject handler,
jobject runnable, long image);
static void invoke(void* image, void* user);
private:
JniImageCallback(JNIEnv* env, jobject handler, jobject runnable, long image);
~JniImageCallback();
JNIEnv* mEnv;
jobject mHandler;
jobject mCallback;
long mImage;
};

View File

@@ -1,55 +1,17 @@
// This script accepts the following parameters:
//
// filament_dist_dir
// Path to the Filament distribution/install directory for Android
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
//
// Example:
// ./gradlew -Pfilament_dist_dir=../../dist-android-release assembleRelease
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
group = "com.google.android.filament"
version = "1.3"
apply plugin: 'com.android.library'
def filament_path = file("../../out/android-release/filament").absolutePath
if (project.hasProperty("filament_dist_dir")) {
filament_path = file("$filament_dist_dir").absolutePath
}
android {
compileSdkVersion 29
compileSdkVersion versions.compileSdk
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
externalNativeBuild {
cmake {
arguments.add("-DANDROID_PIE=ON")
arguments.add("-DANDROID_PLATFORM=android-19")
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
arguments.add("-DANDROID_STL=c++_static")
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
cppFlags.add("-std=c++14")
if (project.hasProperty('extra_cmake_args')) {
arguments.add(extra_cmake_args)
@@ -58,13 +20,6 @@ android {
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "functionality"
productFlavors {
full {
@@ -101,6 +56,7 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation deps.androidx.annotations
}
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

View File

@@ -0,0 +1,3 @@
POM_NAME=Filament Material Builder
POM_ARTIFACT_ID=filamat-android-full
POM_PACKAGING=aar

View File

@@ -1,10 +0,0 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.6/userguide/multi_project_builds.html
*/
rootProject.name = 'filamat-android'

View File

@@ -16,7 +16,7 @@
package com.google.android.filament.filamat;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import java.nio.ByteBuffer;
public class MaterialBuilder {

View File

@@ -16,7 +16,7 @@
package com.google.android.filament.filamat;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import java.nio.ByteBuffer;
public class MaterialPackage {

View File

@@ -1,113 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

View File

@@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/filament-android.iml" filepath="$PROJECT_DIR$/filament-android.iml" />
</modules>
</component>
</project>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

View File

@@ -1,58 +1,17 @@
// This script accepts the following parameters:
//
// filament_dist_dir
// Path to the Filament distribution/install directory for Android
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
//
// Example:
// ./gradlew -Pfilament_dist_dir=../../dist-android-release assembleRelease
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
group = "com.google.android.filament"
version = "1.3"
apply plugin: 'com.android.library'
def filament_path = file("../../out/android-release/filament").absolutePath
if (project.hasProperty("filament_dist_dir")) {
filament_path = file("$filament_dist_dir").absolutePath
}
android {
compileSdkVersion 29
compileSdkVersion versions.compileSdk
defaultConfig {
// Our minSdkVersion is actually 19, we lie and say 14 here so apps don't have
// to increase their minSdkVersion unnecessarily. It is however up to them to
// ensure they do not initialize Filament on API levels < 19.
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
externalNativeBuild {
cmake {
arguments.add("-DANDROID_PIE=ON")
arguments.add("-DANDROID_PLATFORM=android-19")
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
arguments.add("-DANDROID_STL=c++_static")
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
cppFlags.add("-std=c++14")
if (project.hasProperty('extra_cmake_args')) {
arguments.add(extra_cmake_args)
@@ -61,13 +20,6 @@ android {
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
@@ -93,6 +45,7 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation deps.androidx.annotations
}
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

View File

@@ -0,0 +1,3 @@
POM_NAME=Filament
POM_ARTIFACT_ID=filament-android
POM_PACKAGING=aar

View File

@@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,22 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# JNI is an entry point that's hard to keep track of, so there's
# an annotation to mark fields and methods used by native code.
# Keep the annotations that proguard needs to process.
-keep class com.google.android.filament.proguard.UsedBy*
# Just because native code accesses members of a class, does not mean that the
# class itself needs to be annotated - only annotate classes that are
# referenced themselves in native code.
-keep @com.google.android.filament.proguard.UsedBy* class * {
<init>();
}
-keepclassmembers class * {
@com.google.android.filament.proguard.UsedBy* *;
}

View File

@@ -1 +0,0 @@
rootProject.name = 'filament-android'

View File

@@ -59,6 +59,13 @@ Java_com_google_android_filament_Engine_nCreateSwapChain(JNIEnv* env,
return (jlong) engine->createSwapChain(win, (uint64_t) flags);
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Engine_nCreateSwapChainHeadless(JNIEnv* env,
jclass klass, jlong nativeEngine, jint width, jint height, jlong flags) {
Engine* engine = (Engine*) nativeEngine;
return (jlong) engine->createSwapChain(width, height, (uint64_t) flags);
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Engine_nCreateSwapChainFromRawPointer(JNIEnv*,
jclass, jlong nativeEngine, jlong pointer, jlong flags) {

View File

@@ -135,10 +135,31 @@ Java_com_google_android_filament_IndirectLight_nGetDirectionEstimate(JNIEnv* env
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_IndirectLight_nGetColorEstimate(JNIEnv* env, jclass,
jlong nativeIndirectLight, jfloatArray outColor_, float x, float y, float z) {
jlong nativeIndirectLight, jfloatArray outColor_, jfloat x, jfloat y, jfloat z) {
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
jfloat *outColor = env->GetFloatArrayElements(outColor_, NULL);
*reinterpret_cast<filament::math::float4*>(outColor) =
indirectLight->getColorEstimate(math::float3{x, y, z});
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_IndirectLight_nGetDirectionEstimateStatic(JNIEnv *env, jclass,
jfloatArray sh_, jfloatArray outDirection_) {
jfloat* sh = env->GetFloatArrayElements(sh_, NULL);
jfloat *outDirection = env->GetFloatArrayElements(outDirection_, NULL);
*reinterpret_cast<filament::math::float3*>(outDirection) = IndirectLight::getDirectionEstimate((filament::math::float3*)sh);
env->ReleaseFloatArrayElements(outDirection_, outDirection, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_IndirectLight_nGetColorEstimateStatic(JNIEnv *env, jclass,
jfloatArray outColor_, jfloatArray sh_, jfloat x, jfloat y, jfloat z) {
jfloat* sh = env->GetFloatArrayElements(sh_, NULL);
jfloat *outColor = env->GetFloatArrayElements(outColor_, NULL);
*reinterpret_cast<filament::math::float4*>(outColor) =
IndirectLight::getColorEstimate((filament::math::float3*)sh, math::float3{x, y, z});
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
}

View File

@@ -84,6 +84,23 @@ Java_com_google_android_filament_Material_nGetBlendingMode(JNIEnv*, jclass,
return (jint) material->getBlendingMode();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetRefraction(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint)material->getRefractionMode();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetRefractionType(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint) material->getRefractionType();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetVertexDomain(JNIEnv*, jclass,

View File

@@ -97,6 +97,42 @@ Java_com_google_android_filament_Renderer_nReadPixels(JNIEnv *env, jclass,
return 0;
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_Renderer_nReadPixelsEx(JNIEnv *env, jclass,
jlong nativeRenderer, jlong nativeEngine, jlong nativeRenderTarget,
jint xoffset, jint yoffset, jint width, jint height,
jobject storage, jint remaining,
jint left, jint top, jint type, jint alignment, jint stride, jint format,
jobject handler, jobject runnable) {
Renderer *renderer = (Renderer *) nativeRenderer;
Engine *engine = (Engine *) nativeEngine;
RenderTarget *renderTarget = (RenderTarget *) nativeRenderTarget;
stride = stride ? stride : width;
size_t sizeInBytes = PixelBufferDescriptor::computeDataSize(
(PixelDataFormat) format, (PixelDataType) type,
(size_t) stride, (size_t) (height + top), (size_t) alignment);
AutoBuffer nioBuffer(env, storage, 0);
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
// BufferOverflowException
return -1;
}
void *buffer = nioBuffer.getData();
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
(uint32_t) stride, &JniBufferCallback::invoke, callback);
renderer->readPixels(renderTarget,
uint32_t(xoffset), uint32_t(yoffset), uint32_t(width), uint32_t(height),
std::move(desc));
return 0;
}
extern "C" JNIEXPORT jdouble JNICALL
Java_com_google_android_filament_Renderer_nGetUserTime(JNIEnv*, jclass, jlong nativeRenderer) {
Renderer *renderer = (Renderer *) nativeRenderer;

View File

@@ -24,6 +24,25 @@
#include "common/NioUtils.h"
#include "common/CallbackUtils.h"
#ifdef ANDROID
#if __has_include(<android/hardware_buffer_jni.h>)
#include <android/hardware_buffer_jni.h>
#else
struct AHardwareBuffer;
typedef struct AHardwareBuffer AHardwareBuffer;
#endif
#include <android/log.h>
#include <dlfcn.h>
using PFN_FROMHARDWAREBUFFER = AHardwareBuffer* (*)(JNIEnv*, jobject);
static PFN_FROMHARDWAREBUFFER AHardwareBuffer_fromHardwareBuffer_fn = nullptr;
static bool sHardwareBufferSupported = true;
#endif
using namespace filament;
using namespace backend;
@@ -108,10 +127,10 @@ Java_com_google_android_filament_Stream_nBuilderBuild(JNIEnv*, jclass,
return (jlong) builder->builder()->build(*engine);
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_Stream_nIsNative(JNIEnv*, jclass, jlong nativeStream) {
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_Stream_nGetStreamType(JNIEnv*, jclass, jlong nativeStream) {
Stream* stream = (Stream*) nativeStream;
return (jboolean) stream->isNativeStream();
return (jint) stream->getStreamType();
}
extern "C" JNIEXPORT void JNICALL
@@ -160,3 +179,44 @@ Java_com_google_android_filament_Stream_nGetTimestamp(JNIEnv*, jclass, jlong nat
Stream *stream = (Stream *) nativeStream;
return stream->getTimestamp();
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Stream_nSetAcquiredImage(JNIEnv* env, jclass, jlong nativeStream,
jlong nativeEngine, jobject hwbuffer, jobject handler, jobject runnable) {
Engine* engine = (Engine*) nativeEngine;
Stream* stream = (Stream*) nativeStream;
#ifdef ANDROID
// This function is not available before NDK 15 or before Android 8.
if (UTILS_UNLIKELY(!AHardwareBuffer_fromHardwareBuffer_fn)) {
if (!sHardwareBufferSupported) {
return;
}
AHardwareBuffer_fromHardwareBuffer_fn = (PFN_FROMHARDWAREBUFFER) dlsym(RTLD_DEFAULT, "AHardwareBuffer_fromHardwareBuffer");
if (!AHardwareBuffer_fromHardwareBuffer_fn) {
__android_log_print(ANDROID_LOG_WARN, "Filament", "AHardwareBuffer_fromHardwareBuffer is not available.");
sHardwareBufferSupported = false;
}
return;
}
AHardwareBuffer* nativeBuffer = AHardwareBuffer_fromHardwareBuffer_fn(env, hwbuffer);
if (!nativeBuffer) {
__android_log_print(ANDROID_LOG_INFO, "Filament", "Unable to obtain native HardwareBuffer.");
return;
}
auto* callback = JniImageCallback::make(engine, env, handler, runnable, (long) nativeBuffer);
#else
// TODO: for non-Android platforms, it is unclear how to go from "jobject" to "void*"
// For now this code is reserved for future use.
auto* callback = JniImageCallback::make(engine, env, handler, runnable, 0);
void* nativeBuffer = nullptr;
#endif
stream->setAcquiredImage((void*) nativeBuffer, &JniImageCallback::invoke, callback);
}

View File

@@ -241,8 +241,14 @@ Java_com_google_android_filament_View_nGetAmbientOcclusion(JNIEnv*, jclass, jlon
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetAmbientOcclusionOptions(JNIEnv*, jclass,
jlong nativeView, jfloat radius, jfloat bias, jfloat power, jfloat resolution) {
jlong nativeView, jfloat radius, jfloat bias, jfloat power, jfloat resolution, jfloat intensity) {
View* view = (View*) nativeView;
View::AmbientOcclusionOptions options = { .radius = radius, .bias = bias, .power = power, .resolution = resolution};
View::AmbientOcclusionOptions options = {
.radius = radius,
.bias = bias,
.power = power,
.resolution = resolution,
.intensity = intensity
};
view->setAmbientOcclusionOptions(options);
}

View File

@@ -17,7 +17,16 @@
#include <stdio.h>
#include <jawt.h>
#if defined(__has_include)
#if __has_include(<darwin/jawt_md.h>)
#include <darwin/jawt_md.h>
#else
#include <jawt_md.h>
#endif
#else
#include <darwin/jawt_md.h>
#endif
#include <filament/Engine.h>
#include "JAWTUtils.h"

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
final class Asserts {
private Asserts() {

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Size;
/**
* An axis-aligned 3D box represented by its center and half-extent.

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
/**
* Camera represents the eye through which the scene is viewed.

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Size;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import com.google.android.filament.proguard.UsedByReflection;
@@ -119,13 +119,17 @@ public class Engine {
*/
DEFAULT,
/**
* Selects the OpenGL ES driver.
* Selects the OpenGL driver (which supports OpenGL ES as well).
*/
OPENGL,
/**
* Selects the experimental Vulkan driver.
* Selects the Vulkan driver if the platform supports it.
*/
VULKAN,
/**
* Selects the Metal driver if the platform supports it.
*/
METAL,
/**
* Selects the no-op driver for testing purposes.
*/
@@ -290,6 +294,32 @@ public class Engine {
throw new IllegalArgumentException("Invalid surface " + surface);
}
/**
* Creates a headless {@link SwapChain}
*
* @param width width of the rendering buffer
* @param height height of the rendering buffer
* @param flags configuration flags, see {@link SwapChain}
*
* @return a newly created {@link SwapChain} object
*
* @exception IllegalStateException can be thrown if the SwapChain couldn't be created
*
* @see SwapChain#CONFIG_DEFAULT
* @see SwapChain#CONFIG_TRANSPARENT
* @see SwapChain#CONFIG_READABLE
*
*/
@NonNull
public SwapChain createSwapChain(int width, int height, long flags) {
if (width >= 0 && height >= 0) {
long nativeSwapChain = nCreateSwapChainHeadless(getNativeObject(), width, height, flags);
if (nativeSwapChain == 0) throw new IllegalStateException("Couldn't create SwapChain");
return new SwapChain(nativeSwapChain, null);
}
throw new IllegalArgumentException("Invalid parameters");
}
/**
* Creates a {@link SwapChain} from a {@link NativeSurface}.
*
@@ -608,6 +638,7 @@ public class Engine {
private static native void nDestroyEngine(long nativeEngine);
private static native long nGetBackend(long nativeEngine);
private static native long nCreateSwapChain(long nativeEngine, Object nativeWindow, long flags);
private static native long nCreateSwapChainHeadless(long nativeEngine, int width, int height, long flags);
private static native long nCreateSwapChainFromRawPointer(long nativeEngine, long pointer, long flags);
private static native void nDestroySwapChain(long nativeEngine, long nativeSwapChain);
private static native long nCreateView(long nativeEngine);

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import com.google.android.filament.proguard.UsedByReflection;

View File

@@ -15,7 +15,7 @@ package com.google.android.filament;
* limitations under the License.
*/
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
public class Fence {
private long mNativeObject;
@@ -37,6 +37,9 @@ public class Fence {
TIMEOUT_EXPIRED
}
/**
* Blocks the current thread until the Fence signals.
*/
public FenceStatus wait(@NonNull Mode mode, long timeoutNanoSeconds) {
int nativeResult = nWait(getNativeObject(), mode.ordinal(), timeoutNanoSeconds);
switch (nativeResult) {

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.nio.Buffer;
import java.nio.BufferOverflowException;

View File

@@ -16,10 +16,10 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
import com.google.android.filament.proguard.UsedByReflection;
@@ -63,7 +63,10 @@ import com.google.android.filament.proguard.UsedByReflection;
* <h1>Irradiance</h1>
*
* <p>The irradiance represents the light that comes from the environment and shines an
* object's surface. It is represented as
* object's surface.
* The irradiance is calculated automatically from the Reflections (see below), and generally
* doesn't need to be provided explicitly. However, it can be provided separately from the
* Reflections as
* <a href="https://en.wikipedia.org/wiki/Spherical_harmonics">Spherical Harmonics</a> (SH) of 1, 2 or
* 3 bands, respectively 1, 4 or 9 coefficients.</p>
*
@@ -402,6 +405,7 @@ public class IndirectLight {
* <p>The dominant light direction can be used to set a directional light's direction,
* for instance to produce shadows that match the environment.</p>
*
* @param sh pre-scaled 3-bands spherical harmonics
* @param direction an array of 3 floats to receive a unit vector representing the direction of
* the dominant light or <code>null</code>
* @return the <code>direction</code> paramter if it was provided, or a newly allocated float
@@ -410,6 +414,19 @@ public class IndirectLight {
* @see LightManager.Builder#direction
* @see #getColorEstimate
*/
@NonNull @Size(min = 3)
public static float[] getDirectionEstimate(@NonNull float[] sh, @Nullable @Size(min = 3) float[] direction) {
if (sh.length < 9 * 3) {
throw new ArrayIndexOutOfBoundsException(
"3 bands SH required, array must be at least 9 x float3");
}
direction = Asserts.assertFloat3(direction);
nGetDirectionEstimateStatic(sh, direction);
return direction;
}
/** @deprecated */
@NonNull @Size(min = 3)
public float[] getDirectionEstimate(@Nullable @Size(min = 3) float[] direction) {
direction = Asserts.assertFloat3(direction);
@@ -417,6 +434,7 @@ public class IndirectLight {
return direction;
}
/**
* Helper to estimate the color and relative intensity of the environment in a given direction.
*
@@ -424,6 +442,7 @@ public class IndirectLight {
* make sure to multiply this relative intensity by the the intensity of this indirect light.</p>
*
* @param colorIntensity an array of 4 floats to receive the result or <code>null</code>
* @param sh pre-scaled 3-bands spherical harmonics
* @param x the x coordinate of a unit vector representing the direction of the light
* @param y the x coordinate of a unit vector representing the direction of the light
* @param z the x coordinate of a unit vector representing the direction of the light
@@ -438,6 +457,19 @@ public class IndirectLight {
* @see #setIntensity
*/
@NonNull @Size(min = 4)
public static float[] getColorEstimate(@Nullable @Size(min = 4) float[] colorIntensity, @NonNull float[] sh, float x, float y, float z) {
if (sh.length < 9 * 3) {
throw new ArrayIndexOutOfBoundsException(
"3 bands SH required, array must be at least 9 x float3");
}
colorIntensity = Asserts.assertFloat4(colorIntensity);
nGetColorEstimateStatic(colorIntensity, sh, x, y, z);
return colorIntensity;
}
/** @deprecated */
@NonNull @Size(min = 4)
public float[] getColorEstimate(@Nullable @Size(min = 4) float[] colorIntensity, float x, float y, float z) {
colorIntensity = Asserts.assertFloat4(colorIntensity);
nGetColorEstimate(getNativeObject(), colorIntensity, x, y, z);
@@ -472,4 +504,7 @@ public class IndirectLight {
private static native void nGetRotation(long nativeIndirectLight, float[] outRotation);
private static native void nGetDirectionEstimate(long nativeIndirectLight, float[] outDirection);
private static native void nGetColorEstimate(long nativeIndirectLight, float[] outColor, float x, float y, float z);
private static native void nGetDirectionEstimateStatic(float[] sh, float[] direction);
private static native void nGetColorEstimateStatic(float[] colorIntensity, float[] sh, float x, float y, float z);
}

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
public class LightManager {
private long mNativeObject;

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Size;
import com.google.android.filament.proguard.UsedByNative;
@@ -141,6 +141,31 @@ public class Material {
SCREEN,
}
/**
* Supported refraction modes
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refraction">
* Blending and transparency: refractionMode</a>
*/
public enum RefractionMode {
NONE,
CUBEMAP,
SCREEN_SPACE
}
/**
* Supported refraction types
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refractiontype">
* Blending and transparency: refractionType</a>
*/
public enum RefractionType {
SOLID,
THIN
}
/**
* Supported types of vertex domains
*
@@ -351,13 +376,35 @@ public class Material {
return BlendingMode.values()[nGetBlendingMode(getNativeObject())];
}
/**
* Returns the refraction mode of this material.
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refraction">
* Blending and transparency: refraction</a>
*/
public RefractionMode getRefractionMode() {
return RefractionMode.values()[nGetRefractionMode(getNativeObject())];
}
/**
* Returns the refraction type of this material.
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refractiontype">
* Blending and transparency: refractionType</a>
*/
public RefractionType getRefractionType() {
return RefractionType.values()[nGetRefractionType(getNativeObject())];
}
/**
* Returns the vertex domain of this material.
*
* @se
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/vertexandattributes:vertexdomain">
* Vertex and attributes: vertexDomain</a>
* @return
*/
public VertexDomain getVertexDomain() {
return VertexDomain.values()[nGetVertexDomain(getNativeObject())];
@@ -847,6 +894,9 @@ public class Material {
private static native float nGetMaskThreshold(long nativeMaterial);
private static native float nGetSpecularAntiAliasingVariance(long nativeMaterial);
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterial);
private static native int nGetRefractionMode(long nativeMaterial);
private static native int nGetRefractionType(long nativeMaterial);
private static native int nGetParameterCount(long nativeMaterial);
private static native void nGetParameters(long nativeMaterial,

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Size;
public class MaterialInstance {
private Material mMaterial;
@@ -356,7 +356,7 @@ public class MaterialInstance {
* to produce a resolvable offset for a given implementation. This offset is added before the
* depth test.
*
* @warning using a polygon offset other than zero has a significant negative performance
* Warning: using a polygon offset other than zero has a significant negative performance
* impact, as most implementations have to disable early depth culling. DO NOT USE unless
* absolutely necessary.
*

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Size;
public final class MathUtils {
private MathUtils() { }

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import com.google.android.filament.proguard.UsedByNative;

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
abstract class Platform {
private static Platform mCurrentPlatform = null;

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* An offscreen render target that can be associated with a {@link View} and contains

View File

@@ -16,10 +16,10 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
import java.nio.Buffer;
import java.nio.BufferOverflowException;

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import java.nio.Buffer;
import java.nio.BufferOverflowException;
@@ -299,6 +299,94 @@ public class Renderer {
}
}
/**
* Reads back the content of a specified {@link RenderTarget}.
*
*<pre>
*
* Framebuffer as seen on User buffer (PixelBufferDescriptor)
* screen
* +--------------------+
* | | .stride .alignment
* | | ----------------------->-->
* | | O----------------------+--+ low addresses
* | | | | | |
* | w | | | .top | |
* | <---------> | | V | |
* | +---------+ | | +---------+ | |
* | | ^ | | ======> | | | | |
* | x | h| | | |.left| | | |
* +------>| v | | +---->| | | |
* | +.........+ | | +.........+ | |
* | ^ | | | |
* | y | | +----------------------+--+ high addresses
* O------------+-------+
*
*</pre>
*
*
* <p>Typically <code>readPixels</code> will be called after {@link #render} and before
* {@link #endFrame}.</p>
* <br>
* <p>After calling this method, the callback associated with <code>buffer</code>
* will be invoked on the main thread, indicating that the read-back has completed.
* Typically, this will happen after multiple calls to {@link #beginFrame},
* {@link #render}, {@link #endFrame}.</p>
* <br>
* <p><code>readPixels</code> is intended for debugging and testing.
* It will impact performance significantly.</p>
*
* @param renderTarget {@link RenderTarget} to read back from
* @param xoffset left offset of the sub-region to read back
* @param yoffset bottom offset of the sub-region to read back
* @param width width of the sub-region to read back
* @param height height of the sub-region to read back
* @param buffer client-side buffer where the read-back will be written
*
* <p>
* The following format are always supported:
* <li>{@link Texture.Format#RGBA}</li>
* <li>{@link Texture.Format#RGBA_INTEGER}</li>
* </p>
*
* <p>
* The following types are always supported:
* <li>{@link Texture.Type#UBYTE}</li>
* <li>{@link Texture.Type#UINT}</li>
* <li>{@link Texture.Type#INT}</li>
* <li>{@link Texture.Type#FLOAT}</li>
* </p>
*
* <p>Other combination of format/type may be supported. If a combination is
* not supported, this operation may fail silently. Use a DEBUG build
* to get some logs about the failure.</p>
*
* @exception BufferOverflowException if the specified parameters would result in reading
* outside of <code>buffer</code>.
*/
public void readPixels(
@NonNull RenderTarget renderTarget,
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
@IntRange(from = 0) int width, @IntRange(from = 0) int height,
@NonNull Texture.PixelBufferDescriptor buffer) {
if (buffer.storage.isReadOnly()) {
throw new ReadOnlyBufferException();
}
int result = nReadPixelsEx(getNativeObject(), mEngine.getNativeObject(),
renderTarget.getNativeObject(),
xoffset, yoffset, width, height,
buffer.storage, buffer.storage.remaining(),
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
buffer.stride, buffer.format.ordinal(),
buffer.handler, buffer.callback);
if (result < 0) {
throw new BufferOverflowException();
}
}
/**
* Returns a timestamp (in seconds) for the last call to {@link #beginFrame}. This value is
* constant for all {@link View views} rendered during a frame. The epoch is set with
@@ -355,7 +443,7 @@ public class Renderer {
* <br>
* <p>Use this method used to keep the precision of time high in materials, in practice it should
* be called at least when the application is paused, e.g.
* {@link android.app.Activity#onPause() Activity.onPause} in Android.</p>
* <code>Activity.onPause</code> in Android.</p>
*
* @see #getUserTime
*/
@@ -386,6 +474,12 @@ public class Renderer {
Buffer storage, int remaining,
int left, int top, int type, int alignment, int stride, int format,
Object handler, Runnable callback);
private static native int nReadPixelsEx(long nativeRenderer, long nativeEngine,
long nativeRenderTarget,
int xoffset, int yoffset, int width, int height,
Buffer storage, int remaining,
int left, int top, int type, int alignment, int stride, int format,
Object handler, Runnable callback);
private static native double nGetUserTime(long nativeRenderer);
private static native void nResetUserTime(long nativeRenderer);
}

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
/**
* A <code>Scene</code> is a flat container of {@link RenderableManager} and {@link LightManager}

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import com.google.android.filament.proguard.UsedByReflection;

View File

@@ -16,8 +16,8 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import java.nio.Buffer;
import java.nio.BufferOverflowException;
@@ -33,6 +33,20 @@ public class Stream {
private long mNativeObject;
private long mNativeEngine;
/**
* Represents the immutable stream type.
*/
public enum StreamType {
/** Not synchronized but copy-free. Good for video. */
NATIVE,
/** Synchronized, but GL-only and incurs copies. Good for AR on devices before API 26. */
TEXTURE_ID,
/** Synchronized, copy-free, and take a release callback. Good for AR but requires API 26+. */
ACQUIRED,
};
Stream(long nativeStream, Engine engine) {
mNativeObject = nativeStream;
mNativeEngine = engine.getNativeObject();
@@ -40,6 +54,12 @@ public class Stream {
/**
* Use <code>Builder</code> to construct an Stream object instance.
*
* By default, Stream objects are {@link StreamType#ACQUIRED ACQUIRED} and must have external images pushed to them via
* {@link #setAcquiredImage}.
*
* To create a {@link StreamType#NATIVE NATIVE} or {@link StreamType#TEXTURE_ID TEXTURE_ID} stream, call one of the <pre>stream</pre> methods
* on the builder.
*/
public static class Builder {
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
@@ -55,8 +75,8 @@ public class Stream {
}
/**
* Creates a native stream. Native streams can sample data directly from an
* opaque platform object such as a {@link android.graphics.SurfaceTexture SurfaceTexture}
* Creates a {@link StreamType#NATIVE NATIVE} stream. Native streams can sample data
* directly from an opaque platform object such as a {@link android.graphics.SurfaceTexture SurfaceTexture}
* on Android.
*
* @param streamSource an opaque native stream handle, e.g.: on Android this must be a
@@ -74,7 +94,7 @@ public class Stream {
}
/**
* Creates a copy stream. A copy stream will sample data from the supplied
* Creates a {@link StreamType#TEXTURE_ID TEXTURE_ID} stream. A copy stream will sample data from the supplied
* external texture and copy it into an internal private texture.
*
* <p>Currently only OpenGL external texture ids are supported.</p>
@@ -150,12 +170,24 @@ public class Stream {
}
/**
* Indicates whether this <code>Stream</code> is a native stream or a copy stream.
*
* @return true if this is a native <code>Stream</code>, false otherwise.
* Indicates whether this <code>Stream</code> is NATIVE, TEXTURE_ID, or ACQUIRED.
*/
public boolean isNative() {
return nIsNative(getNativeObject());
public StreamType getStreamType() {
return StreamType.values()[nGetStreamType(getNativeObject())];
}
/**
* Updates an <pre>ACQUIRED</pre> stream with an image that is guaranteed to be used in the next frame.
*
* This method should be called on the same thread that calls {#link Renderer#beginFrame}, which is
* also where the callback is invoked.
*
* @param hwbuffer {@link android.hardware.HardwareBuffer HardwareBuffer} (requires API level 26)
* @param handler {@link java.util.concurrent.Executor Executor} or {@link android.os.Handler Handler}.
* @param callback a callback invoked by <code>handler</code> when the <code>hwbuffer</code> can be released.
*/
public void setAcquiredImage(Object hwbuffer, Object handler, Runnable callback) {
nSetAcquiredImage(getNativeObject(), mNativeEngine, hwbuffer, handler, callback);
}
/**
@@ -174,7 +206,7 @@ public class Stream {
* Reads back the content of the last frame of a <code>Stream</code> since the last call to
* {@link Renderer#beginFrame}.
*
* <p>The Stream must be a copy stream, which can be checked with {@link #isNative()}.
* <p>The Stream must be a copy stream, which can be checked with {@link #getStreamType()}.
* This function is a no-op otherwise.</p>
*
* <pre>
@@ -286,6 +318,7 @@ public class Stream {
private static native void nBuilderHeight(long nativeStreamBuilder, int height);
private static native long nBuilderBuild(long nativeStreamBuilder, long nativeEngine);
private static native int nGetStreamType(long nativeStream);
private static native void nSetDimensions(long nativeStream, int width, int height);
private static native int nReadPixels(long nativeStream, long nativeEngine,
int xoffset, int yoffset, int width, int height,
@@ -293,6 +326,6 @@ public class Stream {
int left, int top, int type, int alignment, int stride, int format,
Object handler, Runnable callback);
private static native long nGetTimestamp(long nativeStream);
private static native boolean nIsNative(long nativeStream);
private static native void nSetAcquiredImage(long nativeStream, long nativeEngine,
Object hwbuffer, Object handler, Runnable callback);
}

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
/**
* A <code>SwapChain</code> represents an Operating System's <b>native</b> renderable surface.
@@ -85,15 +85,15 @@ public class SwapChain {
*/
public static final long CONFIG_READABLE = 0x2;
SwapChain(long nativeSwapChain, @NonNull Object surface) {
SwapChain(long nativeSwapChain, Object surface) {
mNativeObject = nativeSwapChain;
mSurface = surface;
}
/**
* @return the native <code>Object</code> this <code>SwapChain</code> was created from.
* @return the native <code>Object</code> this <code>SwapChain</code> was created from or null
* for a headless SwapChain.
*/
@NonNull
public Object getNativeWindow() {
return mSurface;
}

View File

@@ -16,10 +16,10 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
import com.google.android.filament.proguard.UsedByReflection;
@@ -322,13 +322,26 @@ public class Texture {
public CompressedFormat compressedFormat;
@Nullable public Object handler;
@Nullable public Runnable callback;
/**
* Valid handler types:
* - Android: Handler, Executor
* - Other: Executor
* Callback used to destroy the buffer data.
* <p>
* Guarantees:
* <ul>
* <li>Called on the main filament thread.</li>
* </ul>
* </p>
*
* <p>
* Limitations:
* <ul>
* <li>Must be lightweight.</li>
* <li>Must not call filament APIs.</li>
* </ul>
* </p>
*/
@Nullable public Runnable callback;
/**
* Creates a <code>PixelBufferDescriptor</code>

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
/**
* <code>TextureSampler</code> defines how a texture is accessed.

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
/**
* <code>TransformManager</code> is used to add transform components to entities.

View File

@@ -16,9 +16,9 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.nio.Buffer;
import java.nio.BufferOverflowException;

View File

@@ -16,10 +16,10 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;
import static com.google.android.filament.Colors.LinearColor;
@@ -149,6 +149,11 @@ public class View {
* How each dimension of the AO buffer is scaled. Must be positive and <= 1.
*/
public float resolution = 0.5f;
/**
* Strength of the Ambient Occlusion effect. Must be positive.
*/
public float intensity = 1.0f;
}
/**
@@ -761,7 +766,8 @@ public class View {
*/
public void setAmbientOcclusionOptions(@NonNull AmbientOcclusionOptions options) {
mAmbientOcclusionOptions = options;
nSetAmbientOcclusionOptions(getNativeObject(), options.radius, options.bias, options.power, options.resolution);
nSetAmbientOcclusionOptions(getNativeObject(), options.radius, options.bias, options.power,
options.resolution, options.intensity);
}
/**
@@ -819,5 +825,5 @@ public class View {
private static native boolean nIsFrontFaceWindingInverted(long nativeView);
private static native void nSetAmbientOcclusion(long nativeView, int ordinal);
private static native int nGetAmbientOcclusion(long nativeView);
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution);
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution, float intensity);
}

View File

@@ -16,7 +16,7 @@
package com.google.android.filament;
import android.support.annotation.IntRange;
import androidx.annotation.IntRange;
/**
* Specifies a rectangular region within a render target in terms of pixel coordinates.

View File

@@ -17,8 +17,8 @@
package com.google.android.filament.android;
import android.graphics.Bitmap;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import com.google.android.filament.Engine;
import com.google.android.filament.Texture;

View File

@@ -19,8 +19,8 @@ package com.google.android.filament.android;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;

View File

@@ -1,55 +1,17 @@
// This script accepts the following parameters:
//
// filament_dist_dir
// Path to the Filament distribution/install directory for Android
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
//
// Example:
// ./gradlew -Pfilament_dist_dir=../../dist-android-release assembleRelease
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
group = "com.google.android.filament"
version = "1.3"
apply plugin: 'com.android.library'
def filament_path = file("../../out/android-release/filament").absolutePath
if (project.hasProperty("filament_dist_dir")) {
filament_path = file("$filament_dist_dir").absolutePath
}
android {
compileSdkVersion 29
compileSdkVersion versions.compileSdk
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
externalNativeBuild {
cmake {
arguments.add("-DANDROID_PIE=ON")
arguments.add("-DANDROID_PLATFORM=android-19")
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
arguments.add("-DANDROID_STL=c++_static")
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
cppFlags.add("-std=c++14")
if (project.hasProperty('extra_cmake_args')) {
arguments.add(extra_cmake_args)
@@ -58,13 +20,6 @@ android {
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
@@ -84,7 +39,8 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.android.filament:filament-android'
implementation deps.androidx.annotations
implementation project(':filament-android')
}
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

View File

@@ -0,0 +1,3 @@
POM_NAME=Filament glTF Loader
POM_ARTIFACT_ID=gltfio-android
POM_PACKAGING=aar

View File

@@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,12 +0,0 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.6/userguide/multi_project_builds.html
*/
includeBuild '../filament-android'
rootProject.name = 'gltfio-android'

View File

@@ -27,7 +27,7 @@ extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_gltfio_Animator_nApplyAnimation(JNIEnv*, jclass, jlong nativeAnimator,
jint index, jfloat time) {
Animator* animator = (Animator*) nativeAnimator;
animator->applyAnimation(index, time);
animator->applyAnimation(static_cast<size_t>(index), time);
}
extern "C" JNIEXPORT void JNICALL
@@ -46,14 +46,14 @@ extern "C" JNIEXPORT float JNICALL
Java_com_google_android_filament_gltfio_Animator_nGetAnimationDuration(JNIEnv*, jclass,
jlong nativeAnimator, jint index) {
Animator* animator = (Animator*) nativeAnimator;
return animator->getAnimationDuration(index);
return animator->getAnimationDuration(static_cast<size_t>(index));
}
extern "C" JNIEXPORT jstring JNICALL
Java_com_google_android_filament_gltfio_Animator_nGetAnimationName(JNIEnv* env, jclass,
jlong nativeAnimator, jint index) {
Animator* animator = (Animator*) nativeAnimator;
const char* val = animator->getAnimationName(index);
const char* val = animator->getAnimationName(static_cast<size_t>(index));
return val ? env->NewStringUTF(val) : nullptr;
}

View File

@@ -32,7 +32,7 @@ using namespace utils;
extern void registerCallbackUtils(JNIEnv*);
extern void registerNioUtils(JNIEnv*);
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
jint JNI_OnLoad(JavaVM* vm, void*) {
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
return -1;
@@ -69,6 +69,15 @@ Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromBinary(JNIEn
buffer.getSize());
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromJson(JNIEnv* env, jclass,
jlong nativeLoader, jobject javaBuffer, jint remaining) {
AssetLoader* loader = (AssetLoader*) nativeLoader;
AutoBuffer buffer(env, javaBuffer, remaining);
return (jlong) loader->createAssetFromJson((const uint8_t *) buffer.getData(),
buffer.getSize());
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_gltfio_AssetLoader_nEnableDiagnostics(JNIEnv*, jclass,
jlong nativeLoader, jboolean enable) {

View File

@@ -49,7 +49,7 @@ extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_gltfio_FilamentAsset_nGetBoundingBox(JNIEnv* env, jclass,
jlong nativeAsset, jfloatArray result) {
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
float* values = (float*) env->GetFloatArrayElements(result, nullptr);
float* values = env->GetFloatArrayElements(result, nullptr);
const filament::Aabb box = asset->getBoundingBox();
const float3 center = box.center();
const float3 extent = box.extent();
@@ -59,13 +59,13 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetBoundingBox(JNIEnv* en
values[3] = extent.x;
values[4] = extent.y;
values[5] = extent.z;
env->ReleaseFloatArrayElements(result, (jfloat*) values, 0);
env->ReleaseFloatArrayElements(result, values, 0);
}
extern "C" JNIEXPORT jstring JNICALL
Java_com_google_android_filament_gltfio_FilamentAsset_nGetName(JNIEnv* env, jclass,
jlong nativeAsset, jint entityId) {
uint32_t id = entityId;
uint32_t id = static_cast<uint32_t>(entityId);
Entity* entity = (Entity*) &id;
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
const char* val = asset->getName(*entity);
@@ -73,8 +73,26 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetName(JNIEnv* env, jcla
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_gltfio_FilamentAsset_nGetAnimator(JNIEnv* env, jclass,
Java_com_google_android_filament_gltfio_FilamentAsset_nGetAnimator(JNIEnv* , jclass,
jlong nativeAsset) {
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
return (jlong) asset->getAnimator();
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_gltfio_FilamentAsset_nGetResourceUriCount(JNIEnv*, jclass,
jlong nativeAsset) {
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
return (jint) asset->getResourceUriCount();
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_gltfio_FilamentAsset_nGetResourceUris(JNIEnv* env, jclass,
jlong nativeAsset,
jobjectArray result) {
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
auto resourceUris = asset->getResourceUris();
for (int i = 0; i < asset->getResourceUriCount(); ++i) {
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(resourceUris[i]));
}
}

View File

@@ -28,7 +28,7 @@ using namespace filament;
using namespace gltfio;
using namespace utils;
static void destroy(void* data, size_t size, void *userData) {
static void destroy(void*, size_t, void *userData) {
AutoBuffer* buffer = (AutoBuffer*) userData;
delete buffer;
}

View File

@@ -16,9 +16,10 @@
package com.google.android.filament.gltfio;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.nio.Buffer;
/**
* Updates matrices according to glTF <code>animation</code> and <code>skin</code> definitions.
@@ -55,8 +56,8 @@ public class Animator {
}
/**
* Computes root-to-node transforms for all bone nodes, then passes
* the results into {@see RenderableManager#setBones}.
* Computes root-to-node transforms for all bone nodes, then passes the results into
* {@link com.google.android.filament.RenderableManager#setBonesAsMatrices(int, Buffer, int, int)}.
* Uses <code>TransformManager</code> and <code>RenderableManager</code>.
*
* <p>NOTE: this operation is independent of <code>animation</code>.</p>

View File

@@ -16,8 +16,8 @@
package com.google.android.filament.gltfio;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.filament.Engine;
import com.google.android.filament.EntityManager;
@@ -37,7 +37,6 @@ import java.nio.Buffer;
*
* companion object {
* init {
* Filament.init()
* AssetLoader.init()
* }
* }
@@ -54,11 +53,21 @@ import java.nio.Buffer;
* assetLoader.createAssetFromBinary(ByteBuffer.wrap(bytes))!!
* }
*
* ResourceLoader(engine).loadResources(filamentAsset).destroy()
* val resourceLoader = ResourceLoader(engine)
* resourceLoader.loadResources(filamentAsset)
* for (uri in filamentAsset.resourceUris) {
* val buffer = loadResource(uri)
* resourceLoader.addResourceData(uri, buffer)
* }
* resourceLoader.destroy()
* animator = asset.getAnimator()
*
* scene.addEntities(filamentAsset.entities)
* }
*
* private fun loadResource(uri: String): Buffer {
* TODO("Load your asset here (e.g. using Android's AssetManager API)")
* }
* </pre>
*
* @see Animator
@@ -113,6 +122,15 @@ public class AssetLoader {
return new FilamentAsset(nativeAsset);
}
/**
* Creates a {@link FilamentAsset} from the contents of a GLTF file.
*/
@Nullable
public FilamentAsset createAssetFromJson(@NonNull Buffer buffer) {
long nativeAsset = nCreateAssetFromJson(mNativeObject, buffer, buffer.remaining());
return new FilamentAsset(nativeAsset);
}
/**
* Allows clients to enable diagnostic shading on newly-loaded assets.
*/
@@ -123,7 +141,7 @@ public class AssetLoader {
/**
* Frees all memory associated with the given {@link FilamentAsset}.
*/
public void destroyAsset(@Nullable FilamentAsset asset) {
public void destroyAsset(@NonNull FilamentAsset asset) {
nDestroyAsset(mNativeObject, asset.getNativeObject());
asset.clearNativeObject();
}
@@ -132,6 +150,7 @@ public class AssetLoader {
long nativeEntities);
private static native void nDestroyAssetLoader(long nativeLoader);
private static native long nCreateAssetFromBinary(long nativeLoader, Buffer buffer, int remaining);
private static native long nCreateAssetFromJson(long nativeLoader, Buffer buffer, int remaining);
private static native void nEnableDiagnostics(long nativeLoader, boolean enable);
private static native void nDestroyAsset(long nativeLoader, long nativeAsset);
}

View File

@@ -16,7 +16,7 @@
package com.google.android.filament.gltfio;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import com.google.android.filament.Box;
import com.google.android.filament.Entity;
@@ -67,7 +67,7 @@ public class FilamentAsset {
* <p>All of these have a transform component. Some of the returned entities may also have a
* renderable component.</p>
*/
public @Entity int[] getEntities() {
public @NonNull @Entity int[] getEntities() {
int[] result = new int[nGetEntityCount(mNativeObject)];
nGetEntities(mNativeObject, result);
return result;
@@ -93,9 +93,9 @@ public class FilamentAsset {
* Creates or retrieves the <code>Animator</code> for this asset.
*
* <p>When calling this for the first time, this must be called after
* {@see ResourceLoader#loadResources}.</p>
* {@link ResourceLoader#loadResources}.</p>
*/
public Animator getAnimator() {
public @NonNull Animator getAnimator() {
if (mAnimator != null) {
return mAnimator;
}
@@ -103,6 +103,15 @@ public class FilamentAsset {
return mAnimator;
}
/**
* Gets resource URIs for all externally-referenced buffers.
*/
public @NonNull String[] getResourceUris() {
String[] uris = new String[nGetResourceUriCount(mNativeObject)];
nGetResourceUris(mNativeObject, uris);
return uris;
}
void clearNativeObject() {
mNativeObject = 0;
}
@@ -113,4 +122,6 @@ public class FilamentAsset {
private static native void nGetBoundingBox(long nativeAsset, float[] box);
private static native String nGetName(long nativeAsset, int entity);
private static native long nGetAnimator(long nativeAsset);
private static native int nGetResourceUriCount(long nativeAsset);
private static native void nGetResourceUris(long nativeAsset, String[] result);
}

View File

@@ -16,8 +16,8 @@
package com.google.android.filament.gltfio;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.filament.Engine;
import com.google.android.filament.IndirectLight;

View File

@@ -16,7 +16,7 @@
package com.google.android.filament.gltfio;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.util.Log;
import com.google.android.filament.Engine;

18
android/gradle.properties Normal file
View File

@@ -0,0 +1,18 @@
GROUP=com.google.android.filament
VERSION_NAME=1.4.4
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
POM_URL=https://github.com/google/filament
POM_SCM_URL=https://github.com/google/filament
POM_SCM_CONNECTION=scm:git:git://github.com/google/filament.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/google/filament.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=filament-team
POM_DEVELOPER_NAME=Filament Team
org.gradle.jvmargs=-Xmx1536m

View File

@@ -0,0 +1,182 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'maven'
apply plugin: 'signing'
version = VERSION_NAME
group = GROUP
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
}
def getRepositoryPassword() {
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
}
def configurePom(pom) {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
configurePom(pom)
}
}
}
tasks.create("installLocally", Upload) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: "file://${rootProject.buildDir}/localMaven")
configurePom(pom)
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
task install(type: Upload, dependsOn: assemble) {
repositories.mavenInstaller {
configuration = configurations.archives
configurePom(pom)
}
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}
} else {
install {
repositories.mavenInstaller {
configurePom(pom)
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
artifacts {
if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
archives androidSourcesJar
archives androidJavadocsJar
} else {
archives sourcesJar
archives javadocJar
}
}
}
afterEvaluate { project ->
android.libraryVariants.all { variant ->
tasks.androidJavadocs.doFirst {
classpath += files(variant.javaCompileProvider.get().classpath.files.join(File.pathSeparator))
}
}
}

View File

@@ -58,6 +58,14 @@ Demonstrates how to use `Stream` with Android's Camera2 API:
![Hello Camera](../../docs/images/samples/sample_hello_camera.jpg)
### `stream-test`
Tests the various ways to interact with `Stream` by drawing into an external texture using Canvas.
See the following screenshot; if the two sets of stripes are perfectly aligned, then the Filament
frame and the external texture are perfectly synchronized.
![Stream Test](../../docs/images/samples/sample_stream_test.jpg)
## Prerequisites
Before you start, make sure to read [Filament's README](../../README.md). You need to be able to
@@ -85,13 +93,13 @@ $ ./gradlew -Pfilament_tools_dir=../../dist-release assembleDebug
## Important: SDK location
Either ensure your `ANDROID_HOME` environment variable is set or make sure each project contains a
`local.properties` file with the `sdk.dir` property pointing to your installation of the Android
SDK. This includes the project `filament-android` in the parent directory.
Either ensure your `ANDROID_HOME` environment variable is set or make sure the root project
contains a `local.properties` file with the `sdk.dir` property pointing to your installation of
the Android SDK.
## Android Studio
You must use Android Studio 3.3 or higher to open these projects.
You must use Android Studio 3.5 or higher to open these projects.
## Compiling

View File

@@ -1 +0,0 @@
/build

View File

@@ -1,68 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: '../../../build/filament-tasks.gradle'
compileMaterials {
group 'Filament'
description 'Compile materials'
inputDir = file("src/main/materials")
outputDir = file("src/main/assets/materials")
}
task copyMesh(type: Copy) {
from file("../../../../third_party/models/lucy/lucy.glb")
into file("src/main/assets/models")
}
generateIbl {
group 'Filament'
description 'Generate IBL'
cmgenArgs = "--format=ktx --size=256 --extract-blur=0.1 --deploy=src/main/assets/envs"
inputFile = file("../../../../third_party/environments/venetian_crossroads_2k.hdr")
outputDir = file("src/main/assets/envs")
}
preBuild.dependsOn compileMaterials
preBuild.dependsOn copyMesh
preBuild.dependsOn generateIbl
clean.doFirst {
delete "src/main/assets"
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.google.android.filament.gltf"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// We use the .filamat extension for materials compiled with matc
// Telling aapt to not compress them allows to load them efficiently
aaptOptions {
noCompress 'filamat', 'ktx'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Depend on Filament
implementation 'com.google.android.filament:filament-android'
implementation 'com.google.android.filament:gltfio-android'
}

Some files were not shown because too many files have changed in this diff Show More