Commit Graph

3614 Commits

Author SHA1 Message Date
Mathias Agopian
e7364cdcb3 DoF: don't rely on texture swizzle being supported 2021-03-31 12:17:34 -07:00
Mathias Agopian
e5bfe81d0c DoF: use only a single low res source for both fg and bg
Before we were keeping a foreground and background version of the
low resolution source, but in practice it really doesn't make a big
difference and we save a fair amount of bandwidth this way.

The bulk of the change is to remove a texture/target which mostly
affects the downsample and mipmap passes.
Also renamed some variables to be less confusing (MaxMin to MinMax for e.g.)
and fixed a few typos.
2021-03-31 12:17:34 -07:00
Mathias Agopian
c4eb790065 Add support for texture swizzling in framegraph 2021-03-31 12:17:34 -07:00
Romain Guy
ac56efcd95 Revert misguided attempt to fix bloom with glTF (#3728)
* Revert misguided attempt to fix bloom with glTF

* Put back line removed by mistake
2021-03-31 10:08:36 -07:00
Mathias Agopian
9fcb8ccb9e DoF: document a typo
there has been a typo in the DoF code a while, but fixing it looks
much worse. we need to understand why. so for now we at least
document the typo in the code.
2021-03-30 21:34:59 -07:00
Mathias Agopian
67a936d845 fix a linker warning 2021-03-30 15:58:17 -07:00
Ben Doherty
d11f3f7d5a Implement Metal texture swizzling (#3720) 2021-03-30 15:38:55 -07:00
Mathias Agopian
625c4d8968 implement query for texture swizzle
unfortunately metal does support texture swizzle on all versions of
macos we support.
2021-03-30 14:24:17 -07:00
Ben Doherty
239b933d5e Fix VSM on Android (#3719) 2021-03-30 14:05:53 -07:00
Philip Rideout
3161f6a8f1 Remote UI now handles keyboard input. 2021-03-30 08:15:01 -07:00
Philip Rideout
d2bff95c90 Easy build: add matdbg option and help message. 2021-03-30 08:14:23 -07:00
Philip Rideout
a0e7c26a63 Remote pip lockfile from web docs generator. 2021-03-29 14:49:12 -07:00
Ben Doherty
5bfa9633d2 Fix, regression with Metal buffers (#3715) 2021-03-29 14:20:40 -07:00
Benjamin Doherty
ff5ecb17ea Update RELEASE_NOTES for 1.9.18 2021-03-29 11:06:35 -07:00
Benjamin Doherty
83ba56d3e7 Release Filament 1.9.18 2021-03-29 11:05:44 -07:00
Mathias Agopian
2d398c2398 DoF: fix noise radius calculation (#3709)
This small bug was introduced recently with the dynamic kernel size
changes, the noise radius depends on the number of rings in the kernel.
2021-03-29 10:46:34 -07:00
Philip Rideout
cf070c6bc7 RenderTarget: fix NPE when depth is not present.
This fixes a recent regression that would occur when a RenderTarget
does not have a depth attachment.
2021-03-29 10:31:04 -07:00
Mathias Agopian
3c577b6191 DoF: fix several mediump-related bugs
The gist of it is that we can't always accumulate samples naively, and
we have to use different strategies with different tile types.

For the fast tiles it seems enough to reorder the sum, accumulating each
ring first, and then accumulating that into the output, because all
samples have the same weight.

For the foreground tiles, for some reason I couldn't find any major
issue and I'm not sure why.

For the background tiles, we need to use highp intermediates because
every sample has different magnitudes (weights)
2021-03-29 09:48:51 -07:00
Mathias Agopian
acb2da7759 Improvements to Camera APIs (#3701)
* move the focus distance from DofOptions to Camera

The DofOption parameter is now deprecated, but will still work if the
focus distance is not set on Camera.

* A few new helper APIs on Camera

- getFocalLength() which returns the focal length used internally for
  DoF computations.

- computeEffectiveFov() and computeEffectiveFocalLength() which can be
used to better simulate a real camera's FOV changes with the
focus distance.

Modified gltf_viewer so it uses the effective fov/focallendth when
DoF is active.

* simplify setLensProjection

We can call setProjection directly instead of converting to a fov
first, which ends up performing atan(tan(x)).

Also improve parameters names.
2021-03-25 15:22:19 -07:00
Mathias Agopian
a0c2edd1a2 DoF: dynamically and conservatively adjust the kernel density per tile
This adjustment is conservative, i.e. we limit the number of rings in
the kernel based on the kernel size in a way that it won't impact the
result. For instance, if the kernel size is 2 or lower, we don't need 4
rings.

This improves performance significantly, especially with large maximum
right counts.
2021-03-25 15:19:57 -07:00
Ben Doherty
ad555d897d Expose MaterialInstance APIs that should have been public (#3703) 2021-03-25 11:29:39 -07:00
Mathias Agopian
4a6e62070b DoF: slightly better opacity for the background
We now use the same calculation than for the foreground, this seems
to produce slightly smoother transitions
2021-03-24 22:10:40 -07:00
Mathias Agopian
0c081d4295 DoF: implement fix for foreground opacity
This fixes an issue where objects in-focus show through the blurred
foreground.
2021-03-24 16:22:22 -07:00
Mathias Agopian
04ff2fb806 DoF: shader code refactoring
here we just move the fast/foreground and background tiles processing
into their own function. this is just to make the code more readable.
2021-03-24 16:22:22 -07:00
Philip Rideout
4fb9ee4470 Remove old emscripten workaround from GL backend.
This was put in as a workaround for #2856. I made a fix to emscripten
itself (yay open source) in July. So, this workaround is no longer
necessary.

Verified with the rigged figure model.

https://github.com/emscripten-core/emscripten/pull/11742
2021-03-24 14:58:53 -07:00
Philip Rideout
3d2734b163 Minor Driver API simplification.
As far as I can tell, there is no need for the `enabledAttributes`
argument in `setRenderPrimitiveBuffer`. This helps pave the way for
the upcoming BufferObject API.
2021-03-24 14:31:18 -07:00
Philip Rideout
c4a12fe48a Update cgltf to v1.10 2021-03-24 14:31:09 -07:00
Ben Doherty
40b8667aef Fix Metal bug when setGeometryAt is called multiple times (#3693) 2021-03-24 12:42:55 -07:00
Mathias Agopian
cb9578327b attempt to improve doxygen formating
fixes: #3692
2021-03-24 12:24:12 -07:00
Mathias Agopian
7b0a8cf2c2 fix JNI setImage and friends buffer size calculation
- setImage() used the width of the texture for calculating the required
  user buffer size, but this was too large when only updating a
  portion of the texture. It would result in a BufferOverFlowException.

- setImage3D() had the opposite problem where it didn't take into
  account the depth of the texture.

- the offset in the user buffer was called "bottom" on the C++ JNI side,
  but it is called "top" on the java and filament side.

Fixes #3685
2021-03-24 12:20:16 -07:00
Philip Rideout
4197afba49 Web site: update Filament in /remote. 2021-03-24 08:24:00 -07:00
Philip Rideout
495fb14b9c Move Camera settings from gltf_viewer to SimpleViewer. 2021-03-24 08:24:00 -07:00
Mathias Agopian
4de1b0de2d DoF: add a "filter" parameter to the DoF settings
Currently the only NONE and MEDIAN are available options, at some 
point we may add a "MAX" option which is cheaper.

There is no real practical uses for this option with these only two
choices, other than for debugging.
2021-03-23 17:27:31 -07:00
Mathias Agopian
abcf4010dd DoF: support full-resolution DoF
This is mostly used for debugging and having somewhat of a reference.
Change to the shader are minimal because all CoC values were always
treated as full-resolution. We just need to replace the downsampling
shader by one that just calculates the CoC. And we need to introduce
a CoC scale factor to compute the LOD to use (this was hardcoded
before).

On the C++ side, it's mostly a matter of replacing hardcoded buffer size
scales by a runtime or compile time variable.
2021-03-23 16:12:03 -07:00
Philip Rideout
65928612b1 Add vkshaders to README. 2021-03-23 12:38:50 -07:00
Adrian Perez
a33c85bdd4 CString can construct from a string_view (#3677)
* CString can construct from a string_view

(string_views lack a null terminator)

* Update libs/utils/src/CString.cpp

Co-authored-by: Mathias Agopian <pixelflinger@gmail.com>
2021-03-23 00:46:18 -07:00
Mathias Agopian
3ec3f222c5 Dof: improve significantly foreground layer
We're implementing the two-layer technique described in
Jimenez DoF paper, where the foreground field is split in two layers, front
and back. In addition we compute accurately the foreground field alpha.

From a performance standpoint, most of the extra work is increased
register pressure and a bit of ALU.
2021-03-22 16:55:40 -07:00
Mathias Agopian
e9a43e7344 DoF: code cleanup
- mostly rename variables
2021-03-22 16:55:40 -07:00
Mathias Agopian
fc835aebc6 DoF: fix a few small bugs
- foreground in-layer feather was off
- sample weights was off my 2x
2021-03-22 16:55:40 -07:00
Mathias Agopian
a3504bd9b6 DoF: make code a bit less confusing
Always store min CoC in the red channel and max Coc in the green
channel for both the CoC and Tiles textures.
(The tiles texture was doing the opposite).
2021-03-22 16:55:40 -07:00
Mathias Agopian
7c604623e6 DoF: code cleanup
Remove the RING_DENSITY variable because it
can't be changed.
2021-03-22 16:55:40 -07:00
Ben Doherty
3d3f19aa71 Enable VSM shadows with shadow multiplier (#3678) 2021-03-22 12:37:07 -07:00
Benjamin Doherty
00f4b45df6 Update RELEASE_NOTES for 1.9.17 2021-03-22 10:16:20 -07:00
Benjamin Doherty
07140cf2fa Release Filament 1.9.17 2021-03-22 10:16:02 -07:00
Romain Guy
28acd0fa6a Update build scripts to match latest AGP and Kotlin 2021-03-19 12:44:25 -07:00
Philip Rideout
0b91f3d785 Add deprecation annotation to Camera. 2021-03-19 11:04:30 -07:00
Mathias Agopian
1bb18f5f0a DoF: fix a bug that caused black dots around the fast tiles
this would happen only when a fast tile had a CoC < 2, because it
would then have an opacity, but we were ignoring it. It's color then
didn't match the color of the surrounding layer and the median filter
would spread a pixel from the surrounding layer into the fast tile.

we simply fix this by (1) generating the alpha/color for fast tiles,
which is easy to do and on the combine pass, skip the fast tile 
combine when the tile has a an opacity.
2021-03-18 14:57:46 -07:00
Mathias Agopian
2e1d88caae DoF: always apply the correct sample weight
before we were not doing that because it caused some aliasing
artifacts with mipmapping, however it turns out that there are artifacts
anyways, and using the proper weights actually reduces the most severe
ones.

the artifacts are due -- it seems -- to the low density of the kernel.
2021-03-18 14:57:46 -07:00
Mathias Agopian
a59f4dd3fc DoF: minor optimizations
we can refactor the code to get rid off the call to mergeRings() for 
the first ring, and we don't need to initialize the current bucket
either.
2021-03-18 14:57:46 -07:00
prewettg
46b356cb2c Fix blanking windows not being drawn into on macOS (#3616)
* Fix blanking windows not being drawn into on macOS

* Refactored to create swap chain info object; added fixes for resizing; added sample.

* CocoaGLSwapChain should inherit from Platform::SwapChain

* Link to SDL directly for multiple_windows example

* SDL apparently redefines main to SDL_main and requires C++ linkage

* Fix main to have SDL-approved signature
2021-03-18 09:49:20 -07:00