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.
In PR #1906 we enabled depth for all backends, but we forgot web.
Note that this required 0 new codelines whereas Vulkan required 116
additional codelines. :)
This cleans up 3 related issues, but only the first of these caused an
actual user-visible bug:
(1) When the IBL was null, prepareLighting was failing to bind the black
1x1 texture.
(2) If you added and removed an IBL from a Scene, then Scene was not
returned to its initial state.
(3) The default 1x1 IBL used an intensity of 1 rather than 30000, which
is inconsistent with the null IBL.
Fixes#1940.
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.
Filament will now allow incomplete mipmap chains for the IBL and
map the roughness to the available chain.
This allows to create roughness cubemaps with a minim size for
roughness==1, instead of always mapping it to 1x1.
cmgen will now use 16x16 cubemaps for roughness==1, which
improves the quality of rough objects significantly.
The beauty of this is that there is no asset or API change. Old assets
will continue to work like before.
This cleans up 3 related issues, but only the first of these caused an
actual user-visible bug:
(1) When the IBL was null, prepareLighting was failing to bind the black
1x1 texture.
(2) If you added and removed an IBL from a Scene, then Scene was not
returned to its initial state.
(3) The default 1x1 IBL used an intensity of 1 rather than 30000, which
is inconsistent with the null IBL.
Fixes#1940.