* Prep work for proper color grading
* Bring back local colorGrading bool to drive that pass
* Fix formatting issue
* Add missing case for the color grading pass
* Fix formatting issues
* Formatting issues
This is now the default, and the tone mapper used
is now the same on desktop and mobile.
In the future this will allow us to implement many features such as
color grading at no cpu cost.
Since AO is computed at 1/4 resolution, it is necessary to upsample
the AO buffer. Until now this was done with a bilinear tap, which is
less than ideal as it can creates jaggies at edges.
High quality upsampling can now be enabled and uses a bilateral filter.
The cost is about 2.0 ms at 250MHz on Pixel 4. ES3.1 is required.
SSAO starts at 1/4 resolution, and because we used derivatives
to calculate a cheap pre-blur, the output was mostly 1/4 resolution
of that, leading to 1/4 of the destination pixels being mostly identical.
This, in turn caused sampling issues when reading the SSAO buffer during
the color pass.
We fix this by getting rid of the pre-blur, and increasing slightly the
size of the gaussian blur from 9 samples to 13, which increases the
SSAO pass time by 20%, or 0.3ms at 430 MHz on Pixel 4.
With this change and bilinear filtering in the color pass, we get rid
of all the sampling artifacts.
- only triangular noise needs to be scaled between +/-1, other noises
have a uniform distribution and need to be scaled between +/-0.5
- all dither routines work in RGBA
- fixed FXAA in opaque mode when dithering modified the alpha channel
(which is used by FXAA). This fixes flickering when FXAA and dithering
was enabled.
- use triangular noise dithering on mobile and desktop. The cost in
not measurable on a pixel 4 / 1080p, and the quality is better.
- refactor dithering code a bit such that:
- noise methods are not temporal
- all dither functions have the same structure
This fixes dynamic lighting and SSAO when a viewport is not in 0,0.
In practice this currently happens only when all post-processing is
disabled.
Instead of using gl_FragCoord we introduce a new API,
getNormalizedViewportCoord(), which as the name implies returns
normalized [0, 1] viewport coordinates with origin at the bottom-left,
on all platforms.
This is implemented in this PR by interpolating gl_Position.
instead of storing two counters for point and spot lights, we now
only have a single counter for both, and the light data structure
has a type, the shader can use to decide what to do -- instead of
using two loops. In practice spot and point light code is very similar
anyways.
This simplify a lot the CPU side (as in make it less complex) and frees
up 8-bits in the per-froxel GPU data structure.
Emissive was previously defined in exposure compensation stops, which
was confusing to many. It is now a value in nits, with the alpha
channel controlling how much the camera exposure affects the emissive.
At 0, the emissive value is just added to the final pixel color, at
1 the emissive value is multiplied by the exposure just like with
regular lights.
The intensity of the emissive property can be computed from an
exposure value (EV) easily with the following formula:
emissive.rgb = emissive.rgb * pow(2.0, EV - 3.0);
This formula is available as Exposure::luminance(float) already
in Filament.
- contact shadows are now supported for point and spot lights
- and are now independent from regular shadows, that is they can
be enabled without enabling regular shadows
The only limitation currently is that the distance and step count for
ALL contact shadow are taken from the directional light options.
The user can now choose amongst 3 specular AO methods:
- None, specAO is off
- Simple, specAO is inferred from roughness and diffuse AO
- Bent normals, specAO is computed accurately from cone intersections
The last method is more expensive but produces the best results.
This change also fixes a few issues:
- Rename materialRefraction() and materialRefractionType() for
consistency
- Fixes user time in shaders
On metals (made only of specular light), specular AO can
create large black spots. This change simply kills specular
AO to avoid this artifact. In practice we should take into
account multiple bounces but this is rasterization...
* Add support for bent normals
Bent normals can be enabled via the bentNormal property of a material.
When specular occlusion is enabled, bent normals improve the quality
of the computation.
* Save a couple of multiplications in bent specular AO
- handle heightFalloff=0 (i.e. fog doesn't depend on height) correctly,
previously, a divide-by-zero on the cpu side would get in the way.
The fix is to clamp heightFalloff to a small-enough value, and to
make sure that this is handled correctly in the shader.
- default fog distance is 0 instead of 1m
- inScatteringSize parameter should be allowed to be large in samples
* Add support for screen-space contact shadows
This CL adds support and always enables it.
toggles and setting in the next CL (same PR).
* Plumb settings for screen-space contact shadows
screen-space contact shadows is handled like a shadow option,
parameters (including on/off) are set in the LightManager, using
the existing ShadowOptions API.
Additionally there is a per-renderable toggle.
Both toggles are off by default.
* Allow contact shadows when shadowing is auto-disabled
Shadowing can be auto-disabled when for instance there are no
shadow casters in the scene. We still allow contact shadows in
that case.
This would allow for instance, to make the vegetation on a terrain
not shadow-casting, and still get some shadowing there by using
contact shadows instead.
* apply micro-shadowing after contact shadows
also, don't compute contact shadows when we know we're fully shadowed.
- minor uniform optimizations (saves ~0.1ms)
- fix some missing highp precision qualifers
- make it easier to tweak the blur filter
- make sure samples's radius goes from 0 to 1
- update comments
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.