Commit Graph

2335 Commits

Author SHA1 Message Date
Mathias Agopian
8bbf0ce9ef Bloom can now have a dirt texture applied 2020-02-13 20:51:43 -08:00
Romain Guy
a4e4021950 Update README.md 2020-02-13 20:03:51 -08:00
Mathias Agopian
87fe48225f On mobile, use a more efficient up-sampler
This doesn't affect quality significantly, but saves 30% of gpu time
on the upsampling, overall it's about 0.1 ms. This brings The bloom
effect below 2ms on Pixel4.
2020-02-13 17:40:55 -08:00
Ben Doherty
af47fa9b6d Fix incorrect twoPassesOneSide rendering with Metal (#2133) 2020-02-13 17:32:26 -08:00
Mathias Agopian
3de1e197aa improve SSrefr highlights at low roughness
We untonemap/tonemap the first level of blur to reduce the very high
frequencies due to HDR highlights in the image, this produce a softer
image at higher roughness. This can programmatically be turned off,
but that setting is not exposed.
2020-02-13 12:26:25 -08:00
Mathias Agopian
2a1cbe67c6 Improve bloom performance on mobile
The very first downsample stage costs us a lot because it reads from
a full-res texture. We mitigate this by always doing a blit to
1/4 res. Blits are quite a bit faster, this saves about 1ms on
Pixel4.
2020-02-12 17:19:26 -08:00
Mathias Agopian
f57404a3f0 split downsample and upsample passes 2020-02-12 17:19:26 -08:00
Mathias Agopian
87d815c659 Minor cleanup. Add FTexture::maxLevelCount()
We were computing this is many places. Validate better SSAO depth
buffer size.
2020-02-12 17:19:26 -08:00
Mathias Agopian
651ccb183e New mathfwd.h header
math/mathwfd.h forward declares all {mat|vec}{2|3|4}<> classes,
which allows us to remove their respective #include in a lot of
our public headers.
Our math headers are full of templates, so this should help build times
a bit.

Also we want to keep the public headers as minimalist as possible.
2020-02-12 15:30:13 -08:00
Philip Rideout
67406c42ec Clamp viewport width to prevent floating point exception.
To trigger an exception users could either shrink the window or enlarge
the sidebar. Constraining both of these is somewhat tricky so let's
just clamp the viewport width at a low level.
2020-02-12 12:07:51 -08:00
Philip Rideout
cb953b4203 Remove usage of <regex> from Path.
There was actually no need to give special treatment to leading drive
designators since they effectively form the first path segment anyway.
To help prevent regressions, I added a few unit tests in a previous CL.

The motivation for the CL is to remove a dependency on `locale.cpp`,
which can result in shorter build times and reduced binary sizes.
2020-02-12 10:03:06 -08:00
Philip Rideout
c0e2cfb684 Minor enhancements to test_Path. 2020-02-12 10:03:06 -08:00
Philip Rideout
9358c7313e Remove STL from ResourceLoader API. 2020-02-12 10:03:06 -08:00
Philip Rideout
02b377c244 gltfio: remove locale.cpp dependency
For Android and wasm we do not use the filesystem and therefore do not
need `utils::Path`.

```
libgltfio-jni.so BEFORE 1.9 MB (693 KB gzipped)
libgltfio-jni.so AFTER  1.4 MB (542 KB gzipped)
```
2020-02-12 10:03:06 -08:00
Romain Guy
d2287f584a Fix comment 2020-02-11 17:33:56 -08:00
Mathias Agopian
cc94820cb3 clean-up of dynamic scaling code 2020-02-11 16:31:21 -08:00
Mathias Agopian
b17c51e340 Add a threshold option (enabled by default) for bloom.
Threshold can be either on or off, and only thresholds at 1.0 when 
activated (in pre-exposed mode).

This allows to use very high strengths values for the bloom without
softening the rest of the image, and is useful for artistic considerations.
2020-02-11 16:15:04 -08:00
Romain Guy
34dcc90ac7 Save a couple of mul 2020-02-11 16:12:23 -08:00
Mathias Agopian
8a1dc0ac65 Make sure sun in the skybox blooms enough
This is a temporary (hopefully) hack to make the skybox sun look 
better when bloom is enabled (this doesn't affect how the "sun" lights
objects, only how it looks in the skybox).
This scale factor was adjusted empirically.
2020-02-11 16:12:23 -08:00
Philip Rideout
a61bc51271 Add Java bindings for SurfaceOrientation.
Note that libgeometry is already included in `filament-android`, this
simply exposes more of its existing functionality.

The Java version of SurfaceOrientation is similar to the JavaScript
version because we are bundling it into the main Filament package, even
though it is a separate library in C++. This is much simpler than
creating a brand new Java package.

New Android sample that tests this is forthcoming.

Fixes #1729.
2020-02-11 12:38:06 -08:00
Mathias Agopian
bccb8260e2 Implement a Bloom post-process effect 2020-02-11 12:15:57 -08:00
Philip Rideout
bedc609051 RenderPass: remove overrideMaterial. 2020-02-10 17:05:02 -08:00
Mathias Agopian
f1cab9296a Fix a SSRefr when dynamic-scaling is enabled
because the intermediate buffer could have non-square pixels, blurring
the buffer would result in an anamorphic blur.

We fix this by properly scaling the buffer before blurring.
2020-02-10 16:07:40 -08:00
Philip Rideout
4665f6027f Add dynamic raster states to MaterialInstance.
Fulfills a request from tirichards@.

This is similar in some ways to dynamic backface culling but simpler
because there is no interaction with double-sided lighting.

For reference, dynamic backface culling was implemented with #1936, #1877, #1641.
2020-02-10 14:33:14 -08:00
Philip Rideout
891e85ba2b gltfio: add nominal support for flat shading.
This "fixes" the new animated Fox model in the glTF conformance suite.
As per the glTF spec, we now generate per-face normals for the case
where normals are not specified in the model.

Note that true flat shading (i.e. flat interpolation) is not a
requirement in the glTF spec, since some Khronos members advocate for
WebGL 1.0 compatibility.

Fixes #2088.
2020-02-10 14:29:04 -08:00
Mathias Agopian
6957f54547 improve SSRefr roughness with very strong highlight
Chose a filter width that preserve the "gaussianness" of the 
blur filter.
2020-02-10 11:22:15 -08:00
Ben Doherty
48ba111ccc Fix crash in Metal backend with screen-space refractions (#2104) 2020-02-10 10:34:44 -08:00
Philip Rideout
8f2df79a96 gltfio: clean up finalize(). 2020-02-07 18:54:46 -08:00
Philip Rideout
415aeef95b gltfio JNI: fix broken getName() method. 2020-02-07 17:15:28 -08:00
Philip Rideout
cabd9be5f0 ModelViewer now implements OnTouchListener for convenience. 2020-02-07 15:20:41 -08:00
Philip Rideout
45e6e6eb18 sample-gltf-viewer now supports landscape orientation. 2020-02-07 15:20:41 -08:00
Philip Rideout
b89cac48c5 gltfio: fix regression with un-textured renderables. 2020-02-07 09:44:42 -08:00
Mathias Agopian
00d55cddb5 fix screen-space refraction roughness calculation (#2108)
It turns out that textureLod() only reads the base layer if the sampler
is not set to xxx_MIPMAP_xxx. This prevented the gaussian-blur code
to work properly.
Specifically, the horizontal pass would always use the base layer. Not
only this made the blur unstable, but also hurt performance significantly.

With this change, the untonamap/tonemap is no longer needed and the 
results are much more convincing with objects with highlights.
2020-02-07 08:55:23 -08:00
Romain Guy
88dd32b1a7 Add emissive to material_sandbox 2020-02-06 16:20:22 -08:00
Mathias Agopian
20e7acd24d fix a typo in blit post-process material 2020-02-06 15:32:25 -08:00
Romain Guy
9be871f14b Don't use a LOD bias but a specific LOD in SSAO code 2020-02-06 15:31:33 -08:00
Pixelflinger
0b358081c3 make the gaussian blur pass more generic
the input and output are now separate (don't need to be the same
texture)
2020-02-06 14:37:04 -08:00
Mathias Agopian
d172ae78fd minor improvements to SSRef code 2020-02-06 13:05:25 -08:00
Pixelflinger
5f1c9bc41b More comments and small bug fixes regarding MSAA
- always take the "blit" path (rather than quad path) when MSAA
  and is on. we now rely on the render target to have been resolved
  into its texture (implicitly or explicitly). This means in some cases
  there will be 2 bliss in a row -- but that's still better than a
  blit and a quad. These are unavoidable without using a custom resolve.

- removed creating renderbuffer with the EXT_multisampled_render_to_texture
  extension because we didn't support it fully and didn't support
  the fallback mode (for desktop or if the extension is not there).
  Also this case never happens currently.

- added more assert()

- added a bunch of comments explaining the restrictions of using MSAA
  regarding blitting.
2020-02-06 13:05:02 -08:00
Philip Rideout
317d78d7c6 sample-gltf-viewer: enable gzip compression for bin and ktx. 2020-02-05 18:45:30 -08:00
Romain Guy
46090793a8 Fully document refraction properties 2020-02-05 17:45:03 -08:00
Romain Guy
c3a995dd3d Update README.md 2020-02-05 11:01:26 -08:00
Philip Rideout
8020f7eb78 gltfio: add plural version of popRenderable 2020-02-04 12:47:32 -08:00
Philip Rideout
e8e847a662 gltfio: various cleanup in response to PR review 2020-02-04 12:47:32 -08:00
Philip Rideout
d2c883877d gltfio: hide entities with not-yet-ready textures.
This feature adds one new method to `FilamentAsset` and uses it in our
Kotlin, JavaScript, and C++ helpers:

    utils::Entity popRenderable() noexcept;

This pops a ready renderable off an internal queue, or returns 0 if no
renderables have become ready. It provides a simple way for clients to
gradually add renderables to the scene as they become ready. Previously
clients could only get the entire list of entities, regardless of
whether they had Renderable components or complete textures.

To facilitate this feature, this PR adds a new internal-only class to
gltfio called `DependencyGraph`, which is a temporary object used for
bookkeeping during the asynchronous load.

`DependencyGraph` discovers ready-to-render entities by tracking the
textures that each entity depends on. This is a graph because
renderables connect to a set of material instances, which in turn
connect to a set of parameter names, which in turn connect to a set of
texture objects. These relationships are not easily inspectable using
the Filament API or ECS.
2020-02-04 12:47:32 -08:00
Romain Guy
0f7f6f6004 Update to cgltf v1.5 (#2097) 2020-02-04 12:27:38 -08:00
Philip Rideout
ebadf9d6a3 Fix gradle invocation in build.sh for Vulkan. 2020-02-04 11:06:20 -08:00
Philip Rideout
94fb74d6aa Missing backend now throws Java exception, not segfault.
If a client application selects a backend that is not supported by the
build, Engine::create() now returns null, which allows the Java wrapper
to throw IllegalStateException. Prevously, we would crash in the native
layer by hitting a null pointer in Engine::loop().
2020-02-04 11:06:20 -08:00
Mathias Agopian
60b664d3b9 rework refraction filtering/blurring to improve performance
We now use a fixed-size kernel (right now 17), for each mip-level.
And we workout the mapping from roughness to such mip.

This improves performance by reducing significantly the number of taps
per mip, however, we don't control how much blur is actually applied
at each level. This gives a mip-chain that is proportional to
'roughness'.

It's now easier to tune quality vs. speed by tweaking the kernel's width
as well as how we map 'sigma' to a the kernel width.
2020-02-03 11:45:17 -08:00
Romain Guy
eee9249dfc Fix table 2020-02-03 09:35:30 -08:00