- 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.
With this PR screen-space refraction is functional.
Caveats:
The blur passes for supporting rough refractive materials is quite
heavy and increases with the resolution.
SSR uses a gaussian approximation for the brdf and therefore doesn’t
match perfectly cubemap-based refraction and IBL.
The use of MSAA with screen-space effects, while working, is going
to incur a large cost, especially on tilers.
We were conflating two concepts in our comments about the roughness
remapping, which was confusing. Also changed the remapping so it
matches a log2 mapping in our default configuration.
If spherical harmonics are not specified in IndirectLight (i.e.
omitted entirely), we instead use the roughness==1 LOD in the shader.
This produce much better results with absolute HDR environment, and
generally works better more often.
This is now the preferred solution.
For cases where spherical harmonicas are better or preferred, they
can simply be supplied as before.
The thin roughness remapping only makes sense for thin surfaces, it was
a mistake to apply it to solids. It assumes that a ray will go
undisturbed though the thin surface with an ior of 1.
We now take into account the light bouncing between the two interfaces
of the materials. We can do this because we assume thin surfaces,
meaning that the light will exit where it entered and with the same
direction that the specular.
This strengthen the specular at grazing angles (and reduces the transmission).
When dealing with thin objects we really have two thicknesses to
consider, the thickness in the direction of the normal, which
corresponds to the value used for solid objects, and the thickness of
the object's walls, which generally is a constant.
Reusing thickness in the later case is problematic for assets that have
a thickness map, but are rendered hollow.
In the future we can even imagine handling double-sided hollow objects
by using the thickness information -- e.g. a hollow cube.
this is because for solids we're also handling both interfaces in one
go (as opposed to calculate the actual btdf), and roughness should
depend on the ior.
Also rename some variables for less confusion (we now use
incident(I)/refracted(R)).
We also now assume a thickness of 0, if it's not set in the material.
We don't want to assume any particular thickness, because it depends
on the scene's scale.
Also clamp the remapped roughness.
Normally the IOR is deduced from the reflectance, but now we allow to
specify the IOR instead or in addition to the reflectance.
In the later case, it's possible to create physically impossible
materials, but this can be useful for artistic reasons.
The "clampNoV" shader function is ignoring the passed dot product argument and recomputing the dot product itself. This will result in the wrong NoV value being used for clear coat IBL computations.
* Add the ability to modify clip space coordinates in the vertex shader
This introduces MaterialVertexInputs.clipSpaceTransform, a mat4 that
is applied to gl_Position before exiting the vertex stage.
* Address code review comments
If you tried removing `culling: none` from any post-process materials,
everything would be fine in GL but Vulkan would be black because
our full-screen triangle was back-facing.
Continue reading only if you thrive in absurd situations.
- Metal and OpenGL define clip space as Y-up whereas Vulkan is Y-down.
- Metal and Vulkan define tex coords as Y-down whereas OpenGL is Y-up.
* Improve materials under white furnace test
Two major changes:
- Mobile target now implements a cheaper variant of the off specular
peak bias (which moves the reflected vector towards the normal).
This greatly helps with rough surfaces that may otherwise point
toward a bright part of the IBL.
- The indirect diffuse love is now properly attenuated to avoid adding
the energy reflected by the specular layer. This allows dielectrics
to be correctly energy conserving under a white furnace.
- Tweak the (hacky) clear coat layer attenuation to behave properly
under a white furnace.
* Use the same reflected vector modification everywhere