Commit Graph

3188 Commits

Author SHA1 Message Date
Pixelflinger
377f043ded smooth out the transition from the background layer
This is a bit of a hack but it helps a lot -- for some reason the
background layer often has a sharp transition to the in-focus plane and 
because we're calculating the DoF at 1/4 resolution these transitions
are quite visible. We work around this by fading out the transition over
a 1 CoC unit, specifically between a CoC of 2 to 1 pixel. Below 1 pixel,
we currently clamp to 0.
2020-09-18 09:42:23 -07:00
Pixelflinger
ea057ca754 fix typo -- ResourceAllocator is not in fg:: namespace anymore 2020-09-17 15:17:22 -07:00
Romain Guy
60ef6581c1 Fix compilation issue with clang 12 2020-09-17 10:02:08 -07:00
Romain Guy
2708b3d076 Initialize fields to nullptr to avoid crashes
This happens when a Texture with no callback is created.
2020-09-17 09:00:34 -07:00
Romain Guy
6dc278c551 Update cgltf (#3092)
Adds support for glTF extensions we want to support:
  KHR_materials_ior
  KHR_materials_specular
2020-09-17 08:52:30 -07:00
Pixelflinger
e4c1557159 fix how we handle "emulated" MSRTT
The sidecar buffer for multisampled_render_to_texture emulation was
stored with the texture, instead of the rendertarget, this prevented
a single texture to be used as an attachment of multiple render targets
with different sample counts.
2020-09-16 17:36:41 -07:00
Pixelflinger
090c02b2cf non-sampleable textures didn't support "magic resolve"
There was an inconsistency in the gles backend where non-sampleable,
non-MS textures failed (assert) if they were used with a render target 
with MS (i.e. "magic resolve" case).

We fix this by taking the same code path for textures and renderbuffers,
the only difference being the calls to glFrameBufferRenderbuffer
instead of glFramebufferTexture2D.
2020-09-16 17:36:41 -07:00
Pixelflinger
86125ca72a fix use after free in the framegraph
resources structures where not cleared when destroyed, and some code
relies in the handles being set or not to decide if a texture should
be used.  in this case, the texture would be set in the shader after
it was destroyed, because its handle wasn't cleared.
2020-09-16 16:55:59 -07:00
Pixelflinger
14532a2e69 several fog fixes
- inScatteringSize actually cannot be set to zero because it produces
  a 0^0 in the shader. So with this change, in-scattering must be
  strictly > 0 to enable.

- inScatteringSize on the java side had an incorrect default value of
  zero (which of course, now doesn't matter anymore).

- also clamp the fog altitude to 1mm which simplifies the shader quite
  a bit for the same result.

Fixes #3069
2020-09-16 00:18:49 -07:00
Pixelflinger
2312d483c1 fix typo and static analysis warnings in libutils 2020-09-15 15:43:03 -07:00
Mathias Agopian
842425e784 code cleanup (typos and warnings) (#3082)
fix typos and some static analysis warnings
2020-09-15 08:33:03 -07:00
Pixelflinger
6211820a70 increase framegraph vector heap
this is needed now that shadows are using the framegraph
2020-09-14 22:23:13 -07:00
Pixelflinger
dc16eb04f8 rename .blurScale to .cocScale in dof options
.blurScale was in fact a scale factor applied to the circle of
confusion (which makes it indeed a "blur scale", but let's use
a more precise language here). 

Update comments to show how to  use .cocScale to control the DoF
effect independently from the camera aperture, which can be useful for
artistic reasons.
2020-09-14 22:22:52 -07:00
Ben Doherty
15a24318e8 Render shadow passes with frame graph (#3073) 2020-09-14 15:57:40 -07:00
Ben Doherty
c0bd3590b2 Support texture layers in frame graph (#3072) 2020-09-14 15:35:25 -07:00
Ben Doherty
b1c78dfc8c Add branching guide (#3077) 2020-09-14 12:12:12 -07:00
Romain Guy
489e926635 Update README.md 2020-09-14 11:36:39 -07:00
Benjamin Doherty
b7c38ef0f1 Update release notes for 1.9.0 2020-09-14 11:07:22 -07:00
Benjamin Doherty
38d37d0d59 Bump version to 1.9.0 2020-09-14 11:07:22 -07:00
Pixelflinger
5701ca939a Improvements to SSAO quality
- simulate a standard deviation of 8 by skipping every other pixel
  when blurring the AO buffer at LOW or MEDIuM quality. This creates
  a faint checker pattern, but does look much better than the low
  frequency noise that is introduced otherwise.

- tweak AO parameters to give a more uniform and smooth AO effect by
  default. This also makes AO even more consistant between quality
  modes.

- add a simple dithering stage to AO blur to help eliminate banding
  artifacts at higher sample counts.
2020-09-13 20:26:11 -07:00
Benjamin Doherty
014abbfb63 Fix documentation bug 2020-09-11 15:43:20 -07:00
Benjamin Doherty
f097ec7d5a Fix const warning 2020-09-11 15:00:40 -07:00
Ben Doherty
be8bd92a34 Remove Google-style line directives driver-side (#3064) 2020-09-11 11:59:50 -07:00
Pixelflinger
fb42817304 add float versions of math constants to libmath
e.g. `F_PI` is also available as `d::PI` and `f::PI` as `double` or
`float` respectively.

Most of our uses of those constants are `float` and it was error prone
and cumbersome to have to cast to that each time we used them.

The `F_` constants are intended to mimic `math.h`, however these new
constants are not, and all the "n over" constants are named
`N_OVER_` instead of `N_`, which helps avoiding the confusion that e.g.:
`F_2_PI` is actually `2/pi` and not `2*pi`.

Also added `F_TAU` which is 2 * PI.
2020-09-10 15:39:16 -07:00
Romain Guy
c92ebada6f Fix simpler viewer UI, add SSAO options 2020-09-10 09:17:40 -07:00
Pixelflinger
c3c535e256 bilateral blur is more configurable
all parameters of the bilateral blur can now be set from the CPU, 
instead of being hardcoded -- this probably prevent the shader compiler
from unrolling the filter, but it's also probably not a big deal.

additionally, we now use a kernel size of 23 (12 samples) when the
SSAO quality is set to HIGH or more.

ssaogen is no longer needed

Higher quality levels used to darken the ssao a lot, now they all have
a consistant look.

Add quality control to material sandbox.

Slightly simplify shader code.
2020-09-09 18:15:31 -07:00
daichen
6c25f5e50f CoroutineScope job should be canceled before destory (#3056) 2020-09-08 21:31:26 -07:00
Pixelflinger
b57510cb3c attempt at a better noise for SSAO
We add noise do the radius of the samples on the spiral 
(instead of adding noise only to the angle), this reduces a visible
"echo", especially at higher radii.
2020-09-08 19:17:02 -07:00
Pixelflinger
69d9a178bf rework a bit dithering noise
- don't use frameUniform.time as the temporal noise seed because
  this has a cycle to it. It's not very visible on dithering but
  obvious when used for other things.

- don't use fract(time) since time was already in [0,1] -- though it's
  moot now.

- instead of time pass a random number in [0,1] generated on the CPU
  each frame.
  This will also allow to control temporal noise more easily if
  needed in the future (e.g. for accessibility or rendering tests)
2020-09-08 13:54:54 -07:00
Ben Doherty
4ddd28a542 Update GitHub workflows to build release and release candidate branches (#3052) 2020-09-08 10:28:13 -07:00
Romain Guy
3092063ebb Revert recent change to depth_main
This shader is only used when the user doesn't specify anything that
could affect depth rendering. As such it must not attemp to read
material inputs.
2020-09-04 10:19:06 -07:00
Pixelflinger
b1070c6508 ssao code improvements and bug fixes
- fix a recent typo that affected SSAO quality
- add a upsampling quality checkbox in material_sandbox
- make use of textureLodOffset instead of texelFetch, so that
  we emulate more closely textureGather
- don't hardcode bilateral filter edge-distance in the shader
  (still hardcoded on the cpu side)
2020-09-03 22:44:48 -07:00
Ben Doherty
604e4ea77d Add VSM control to SimpleViewer (#3043) 2020-09-03 15:52:29 -07:00
Romain Guy
949855f1c8 Update README.md 2020-09-03 09:21:17 -07:00
Romain Guy
e984d92968 Update release notes 2020-09-03 09:20:16 -07:00
Pixelflinger
915c4d89f3 don't do the "reverse-z" in the shader for shadows
it can be done more easily on the cpu side
2020-09-02 20:52:46 -07:00
Pixelflinger
7fb1b853ac fix dynamic lighting frozen calculation
this broke recently with the reverse-z, the froxel calculation relies
on the depth, which is now inverted.

we actually fix our getNormalizedViewportCorrd() public API, which the
froxel code uses.
2020-09-02 15:13:34 -07:00
Mathias Agopian
513b3b8c3a improve stability of DoF with highlights (#3035)
apply the "fireflies" reduction during the downsampling pass instead of
the mipmap pass -- which didn't make a lot of sense.
2020-09-02 14:20:23 -07:00
Pixelflinger
f1b310ba0f minor refactor + comments in the main render pass
This just move the "finish color passes" pass before TAA and 
depth-resolve, where it belongs.
2020-09-02 09:18:13 -07:00
Pixelflinger
6329b865cf New API to create an Engine asynchronously
Because initializing the backend can be relatively slow, creating an
Engine can block the main thread, is this is a problem, this new API
can be used instead; while a bit more complex, it allow the engine to
be initialized asynchronously.
2020-09-01 15:34:04 -07:00
Pixelflinger
13cfad43b7 Use "inverted-Z" depth buffer
This significantly improve the depth-buffer resolution utilization
through the near-infinity range on Metal and Vulkan.

On OpenGL, this benefit is only seen when glClipControl is available.

The user-facing clip plane is unchanged [-1,1], the conversion
happens in filament's vertex shaders.


The bulk of this change consists in:

- invert the clip space's z in the vertex shader
- clear the depth buffer with 0
- invert all depth function comparisons
- fix all screen-space effects, e.g. ssao, DoF
- fix shadows and shadow biases
- use floating-point depth
- add a driver API to query which clip-space is used
- add glClipControl support to the gl backend
2020-09-01 09:46:46 -07:00
Pixelflinger
bb8cd6677d optionally compress highlights before bloom
This avoid unrealistic looking bloom halos from very strong highlights.
This is enabled by default.
2020-09-01 09:46:23 -07:00
Romain Guy
35ed1cb906 Update release notes 2020-08-31 13:52:04 -07:00
Pixelflinger
bcd8ce3c93 fix refraction + MSAA + TAA (depth resolve)
the depth buffer wasn't resolved in this case. We fix this by always
creating a depth buffer resolve pass -- which is a lot more robust.
this pass automatically culled if the depth is not used (i.e. TAA or 
DoF are off). The pass is a no-op if resolving is not needed.
2020-08-31 12:00:41 -07:00
Pixelflinger
84f0e97c78 apply the material clip-space transform to the depth 2020-08-31 11:59:52 -07:00
Philip Rideout
ae9504cbf9 Remove third_party/swiftshader.
These standard headers were unused, we already have them elsewhere in
the repo.
2020-08-31 11:34:07 -07:00
Philip Rideout
696327b35a Add SwiftShader to BUILDING.md 2020-08-31 11:34:07 -07:00
Pixelflinger
1a95c2b39b Fix a few issues with alpha-masked objects
- don't apply SSAO to blended objects
  these are not drawn into the structure buffer, so they don't 
  participate in SSAO.

- remove unused code that was needed for the depth prepass, which
  simplifies handling of blended objects.

- always treat alpha-masked objects as opaque.
2020-08-28 17:27:54 -07:00
toppa102
07393d6237 Changed ifdef WIN32 to WIN32 or _WIN32 (#3022) 2020-08-28 11:27:31 -07:00
Philip Rideout
2f294549a7 Migrate the SwiftShader build to Vulkan.
This also adds a -t flag to the easy build script for convenience.

SwiftShader on Vulkan can now be used as follows.

    git clone https://github.com/google/swiftshader.git
    cd swiftshader/build
    cmake .. &&  make -j && export SWIFTSHADER_LD_LIBRARY_PATH=`pwd`
    cd ../filament
    ./build.sh -t debug && ./out/cmake-debug/samples/gltf_viewer -a vulkan

Note that third_party/swiftshader does not need to exist since we
already have Vulkan headers. I will remove it in a subsequent PR.
2020-08-28 09:47:29 -07:00