* Add support for sheenColor and sheenRoughness
This work is necessary to support the glTF extension KHR_materials_sheen.
This change effectively adds the specular lobe from the cloth material
model to the base material model. The cloth model remains useful for
its extra subsurface color feature but also because it's cheaper.
* Add support for KHR_materials_sheen to gltfio
* Update documentation
* Document default shading values
This was tested by replacing the node 0 scale in BusterDrone with
[-1, 1, 1].
For future reference, commit f728776 shows when we switched from
transpose(inverse()) to cof(). This was a good change, but before that
particular change, we had a "two wrongs made a right" situation for
mirrored normals.
Fixes#3001.
- 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
- 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)
- 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)
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.
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
- 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.
- more flexible linearization of depth, doesn't impact performance
at all in the shader, but takes into account 3 parameters of
the projection matrix instead of true. Mathematically identical
to before.
- use depth test "less or equal" for depth only passes to be consistant
with the color pass. Unsure if using "less" would be better.
- use textureLod() when sampling the skybox
- use mediump for all samplers in the shadowing.fs, which correspond to
their actual definition.
This is more similar to the Vulkan shader pipeline and less magical.
There are 3 places in our shader code where we perform fixups like this:
- main.vs
- depth_main.vs
- post_process_getters.vs
That last one needs no change since it does not involve Z.
Sets of post-process materials are in their own folder now.
Also moved fxaa.fs from shaders/ to materials/ so it's next to the
material that includes it. This file is not shared with any other
material.
This chooses type=THIN, mode=SCREENSPACE, and blending=TRANSPARENT.
Due to sampler overload, we print a friendly error message and enable a
fallback if the user tries to simultaneously enable ubershader mode, the
clearcoat extension, and the transmission extension.
This implementation is an order of magnitude more efficient, running
in about 6ms on Pixel 4.
We're using the ring binning technique described in "Life of a Bokeh",
SIGGRAPH 2018.
* 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.