Commit Graph

55 Commits

Author SHA1 Message Date
Romain Guy
0a5c068cb6 Switch specular AA to Tokuyoshi and Kaplanyan (#1218)
This replaces the previous "curvature to roughness" method. Both are related
and rely on the screen space variance of geometric normals but this new
solution offers more control (the screen space variance and the clamping
threshold can be controlled).
2019-05-23 12:56:26 -07:00
Jeff McGlynn
9fe60a6368 Add proguard annotations for code used by native/reflection (#1207)
Filament references a few classes from native code and by reflections,
so when proguarding binaries we typically had to add an exception for
filament to make it run:

-keep class com.google.android.filament.** {*;}

In a compiled .dex file, the filament namespace takes about 120kb
(before compression), even if the classes aren't used.

To enable proguarding and stripping out unused filament classes,
introduce a UsedByNative and UsedByReflection annotation to explicitly
mark classes that need to be kept in the dex, so that the rest can be
potentially stripped out.

In my testing, this reduces the filament namespace in the .dex from
120kb->40kb, which translates to about 30kb apk size savings after
compression.
2019-05-20 21:02:54 -07:00
Mathias Agopian
cbae6120e1 Ambient Occlusion APIs are more descriptive
Use “AmbientOcclusion” instead of SSAO in all APIs.
2019-05-09 16:36:18 -07:00
Mathias Agopian
011daa952e Add API for controlling SSAO 2019-05-09 16:36:18 -07:00
Philip Rideout
ad79bb8532 Upgrade Gradle and gradle wrappers. (#1123)
This includes a small change to our custom material task because old
gradle passed only the contents of out-of-date directories, newer gradle
passes both the contents and the directory itself.
2019-04-23 12:19:06 -07:00
Philip Rideout
37cb9247fd Add new shading model to Filament for specularGlossiness. (#1083)
* Add new shading model to Filament for specularGlossiness.

This adds a shading model based on KHR_materials_pbrSpecularGlossiness.
The corollary gltfio change will be in an upcoming PR.

* Improve documentation for specular-glossiness
2019-04-09 13:22:16 -07:00
Philip Rideout
dcc17b9b7e Allow dynamic doubleSided and materialThreshold. (#1072)
* MaterialInstance now has setMaskThreshold for convenience.

* Materials now support dynamic doubleSided property.

This does not change the format of material packages because they
already have both getDoubleSided() and getDoubleSidedSet().

The only way in which this change could impact existing applications is
that materials that explicity set doubleSided to "false" will now
respect the material's culling mode, rather than forcing it to NONE.

Fixes gltf_viewer with littlest_tokyo in ubershader mode.

Fixes #963.

* JNI for dynamic material properties.

* Add underscore prefix to internal material params.

* Remove un-needed mat info field.
2019-04-08 11:43:01 -07:00
Mathias Agopian
bc381ac1b7 Add a "stable" shadow-map option
- "stable" mode disables all resolution optimizations that can affect
stability of the shadow map (e.g. lispsm, focusing)

- expose near/far hint + stable option to java
2019-04-05 11:29:56 -07:00
Mathias Agopian
b26684deed rename namespace filament::driver -> filament::backend 2019-03-26 11:47:47 -07:00
Ben Doherty
8b7c2159d3 Fix issue with Windows JAWT swapchains (#1021) 2019-03-25 14:41:46 -07:00
Mathias Agopian
2b5f6cafa6 Separate src/driver into its own library
In this first step, we just "blindly" move everything under src/driver
to a new library libbackend.a. And all headers are moved under
private/backend.

Note that "driver" is renamed "backend", but namespaces are unchanged for now.

Later we'll have to untangle the actual private headers from public
ones and ideally not have any private headers.
2019-03-22 09:45:51 -07:00
Mathias Agopian
9daf7aab64 Decouple tone-mapping, fxaa, msaa and dynamic resolution
It's now possible to enable/disable tone-mapping, fxaa, msaa and
dynamic resolution independently.

A new set/getToneMapping() method is added to View.

It's still possible to disable *all* these post-processing effects
together using setPostProcessing(). This is currently needed when
rendering a transparent view (such as UI) on top of another view.
This limitation might be addressed in the future.

This fixes #621
2019-03-19 11:38:47 -07:00
Philip Rideout
06850cf934 Add Engine::getBackend, fix gltf_viewer + Vulkan. 2019-03-14 10:55:08 -07:00
Mathias Agopian
6e4491c852 Make dithering an enum. 2019-03-12 13:32:28 -07:00
Mathias Agopian
07bb62490b Add an option to turn dithering on/off 2019-03-12 13:32:28 -07:00
Mathias Agopian
8ffba072b2 remove the "byteSize" parameter from update[Vertex|Index]Buffer
It was redundant with BufferDescriptor::size.
2019-03-11 18:27:06 -07:00
Philip Rideout
6d1e0ed6f4 Introduce SurfaceOrientation helper class.
This moves our existing VertexBuffer utility into a new "geometry"
library and adds new functionality for computing tangents based on UV's.
The UV-based method comes from Eric Lengyel.

We considered mikktspace (which thankfully has a zlib-style license) but
it would require re-indexing via meshoptimizer and is therefore a bit
heavyweight.

The new library has no dependencies and will add only 7 KB to Filament's
Android aar file.

Fixes #858 and preps for #528.
2019-02-27 08:47:24 -08:00
Romain Guy
fdee8e2e5c Add missing call to surfaceChanged()
Fixes #842
2019-02-23 22:34:43 -08:00
Mathias Agopian
26468d9532 Split RenderPassParams into multiple structs
We split out Viewport and RenderPassFlags.
2019-02-14 18:08:40 -08:00
Philip Rideout
691daeb45d JNI enhancement: allow mutation of non-direct buffers.
The bug was reproduced and the fix was verified by copying the following
code snippet into one of our Android samples:

    val norm = floatArrayOf(1.0f, 0.0f, 0.0f)
    val tang = floatArrayOf(0.0f, 1.0f, 0.0f, 1.0f)
    val expected = floatArrayOf(0.5f, 0.5f, 0.5f, 0.5f)
    val resultBuffer = FloatBuffer.allocate(4)
    val qtc = VertexBuffer.QuatTangentContext()
    qtc.quatCount = 1
    qtc.quatType = VertexBuffer.QuatType.FLOAT4
    qtc.outBuffer = resultBuffer
    qtc.normals = FloatBuffer.wrap(norm)
    qtc.tangents = FloatBuffer.wrap(tang)
    VertexBuffer.populateTangentQuaternions(qtc)
    Log.e("Filament", "${expected[0]} == ${resultBuffer[0]}")

Fixes #695.
2019-02-11 14:50:14 -08:00
Philip Rideout
40fe6628d0 Expose tangent utility to Java / Kotlin.
This also improves the comments and allows 0 for output stride.
2019-02-11 12:50:19 -08:00
prideout
5ee359cf40 Move math namespace to fix #746. 2019-02-07 09:23:07 -08:00
Philip Rideout
2800f58aa1 Add jniLibs search path to filament-android for Vulkan.
This allows Filament to find validation layers in debug builds.
2019-01-30 16:33:54 -08:00
Philip Rideout
6110809d23 JNI fix for badly-sized PixelBufferDescriptors. (!)
Amazingly, the size field in PixelBufferDescriptor was often totally
incorrect for Java-based clients. The reason we did not notice: OpenGL
often consumes a pointer to image data without consuming a byte count
(e.g. glTexImage2D).

OpenGL infers size from dimensions + format, but Vulkan does not. This
caused texture corruption with Vulkan on Android.

This fix follows a pattern used in other places such as
FRenderer::readPixels.
2019-01-26 09:59:06 -08:00
Philip Rideout
2f35f26148 VertexBuffer builder normalized now accepts "false". 2019-01-17 06:09:17 -08:00
Philip Rideout
125f79e5e0 Allow Java / Kotlin to enable the experimental Vulkan backend.
We still do not compile the Vulkan backend for Android by default, this
simply makes it possible to use the samples on Vulkan with a one-line
change, which is useful for testing purposes.

This change also makes it so that the materials used for the samples
include SPIR-V. This makes them fatter but they are merely samples.

I still consider Vulkan on Android to be experimental, there are some
features that need to be implemented.
2019-01-15 23:00:18 +05:30
Romain Guy
c4989da047 Upgrade sample projects to Android Studio 3.3 (#700) 2019-01-14 11:50:44 -08:00
Romain Guy
eaf790aaa7 Improve rendering to TextureView (#635)
* Improve rendering to TextureView

UiHelper wasn't calling the resize callback at init time when attaching
to a TextureView, but it was for a SurfaceView. This makes both code
paths consistent and fixes the standard samples if they are modified to
render to a TextureView.

This change also adds a new sample app that shows how to render into
a TextureView.

* Suppress warning

* Suppress another warning
2018-12-13 15:57:15 -08:00
Romain Guy
380e3fa690 Simplify UiHelper API, add transparent rendering sample (#629)
* Simplify UiHelper API, add transparent rendering sample

* Rename the app

* Address review comments

Also use the proper package name
2018-12-13 09:09:09 -08:00
Mathias Agopian
42fd0f5dad reduce AAR's content by about 150K
We simply don't emit unwind tables, which are not needed anyways since
we're compiling without exceptions. the combined saving for all four 
targets we support is about 120K.

This seems to improve .aar's compression, for a total gain of 152 KiB. 

We also disable stack-protector in the jni code, since it wasn't
enabled in libfilament.a anyways. However, we now compile all debug 
builds with -fstack-protector
2018-12-11 18:24:16 -08:00
Mathias Agopian
76b15e895a [MATERIALS BREAK] higher period clock
THIS CHANGE BREAKS MATERIALS.

This adds getUserTime() in shaders/materials, which returns the time
in second since Renderer::resetUserTime() was called.
Two values are provided, the time in second encoded as a float and
the difference between that and the double value, which together allows
to perform high precision time computation when needed.

This change allows longer running animations in materials. Using only
the float value, give millisecond resolution for more than 4h.
2018-12-10 16:28:07 -08:00
Romain Guy
6ae21d3825 Add View::setFrontFaceWindingInverted() API (#602)
* Add View::setFrontFaceWindingInverted() API

This API can be used to flip all meshes in a render pass
inside out. This is useful for mirrored rendering.

This change also disables face culling on the default skybox
renderable. Since it is unlit, there is no downside to this
and the mesh being in the device vertex domain it can never
be backfacing unless front face winding is inverted.

* Track face winding state in Vulkan
2018-12-07 16:36:03 -08:00
Romain Guy
4789e81ebc Require API level 21, not 24 (#599)
* Require API level 21, not 24

Fixes #594

* Update README.md
2018-12-07 16:17:57 -08:00
Romain Guy
bd0b752337 Add RenderQuality API (#555)
View::setRenderQuality gives the ability to control the rendering quality
of a given view. In particular this allows the app to lower the quality
of the HDR color buffer by using R11G11B10F instead of RGB(A)16F.
2018-11-29 16:55:36 -08:00
Philip Rideout
b2a2da532a Fix Android-with-Vulkan build. 2018-11-16 12:07:23 -08:00
Mathias Agopian
870d15b9ab Add MaterialInstance::setPolygonOffset()
The polygon offset can now be set through MaterialInstance. 
USE WITH CAUTION, this impacts performance negatively.
2018-11-13 19:27:52 -08:00
Romain Guy
4e3a88bbab Cleanup and documentation (#445) 2018-11-01 16:36:52 -07:00
Mathias Agopian
3b504f2941 add Stream::getTimestamp() to java api 2018-10-16 16:52:26 -07:00
Romain Guy
c581b755fd Add helper to upload Android bitmaps to textures (#382)
* WIP Add helper to upload Android bitmaps to textures

* Add missing file

* Pass custom constants for bitmap formats

* Add sample app for texturing

* Update the README for samples

* Rename variable from callback to autoBitmap
2018-10-16 14:24:18 -07:00
Romain Guy
7cb01929a3 Clean up Kotlin samples (#380)
* Clean up Kotlin samples

* Further code cleanup
2018-10-15 15:28:39 -07:00
Romain Guy
89982e6e97 Improve APIs for Kotlin usage (#361) 2018-10-10 10:13:07 -07:00
Philip Rideout
fc672aa8a4 API CHANGE: remove deprecated RGBM enum. 2018-10-09 12:41:39 -07:00
tpsiaki
faddb10a00 Add CLEAR flag to mirrorFrame (#351)
* Add CLEAR flag to cause mirrorFrame to clear before blit.

* Set viewport size for clear.

* set discardStart
2018-10-09 02:14:05 +02:00
Philip Rideout
c6cef9ff9c NEW API: add RGBM flag to Texture.
This change will allow the skybox use a compressed texture format.

For now, the old internal format "RGBM" is still honored, but in a
forthcoming change we will replace the enum with UNUSED.
2018-10-08 11:33:06 -07:00
tpsiaki
9516080d21 Add support for mirroring the current view to a different swap chain. (#339)
* Add support for save/replay of the current view.

* Add support for having distinct draw/read surfaces.

Adds support to egl & glx drivers for distring draw/read surfaces and
uses this support to implement mirrorFrame using a single blit.

* Use src/dst, Viewport, clean up apis.

* Add SwapChain READABLE Config.

* Commit & setPresentationTime optional on mirror.

* Fix flag check.

* Add documentation for READABLE swap chain config.

* Fix missed s/ExternalContext/Platform/ cases.

* Build break fix.
2018-10-06 00:04:07 +02:00
Romain Guy
57d4a5d47b Update projects for Android Studio 3.2 (#298) 2018-09-24 11:25:44 -07:00
Romain Guy
f8a935e028 Cleanup Android sample code
- Free IBL textures
- Refactor loading code to be easier to read/follow
- Simplify some code originally ported from Java
2018-08-31 21:52:31 -07:00
Romain Guy
c20b452a74 Add new Android sample: IBL and meshes (#192) 2018-08-31 18:13:22 -07:00
Romain Guy
a6722c1f12 Add new Android sample app (#190)
This sample app shows a lit, rotating cube
2018-08-31 14:20:57 -07:00
Romain Guy
f14ff58a89 Add Engine.destroyEntity (#189)
To match the C++ APIs
2018-08-31 10:37:51 -07:00