Previous to this change, we suffered from a flash-of-red followed by a
flash-with-wrong-projection every time we resized an OpenGL window.
SDL throttles the window resize events, so FilamentApp updates the View
only on the final low-level resize event. However we were calling
Cocoa's update method on every low-level resize event. Thus we were
showing uninitialized content during the resize.
FilamentApp recreates the SwapChain after the final resize event; one
reason for this is the fact that Vulkan swap chains must be recreated.
The fix is to defer the Cocoa update until the swap chain gets
recreated. This is the perfect time because FilamentApp has already set
the new Viewport at this point.
We now should be able to use PlatformEGL for all generic EGL platforms
(not tested though). Most texture streaming operations are not supported
in that case, since they're platform specific.
An version of clang is smarter about generating warnings for template code. `assert` here is not included, so clang generates: `error: use of undeclared identifier 'assert'`
When doing the depth path for ssao, we need to remove the blended
objects, i.e. produce a depth path similar to the regular depth prepass.
We also need to clear the SAO buffer. It's not needed for opaque
objects because they are written in the SAO's depth buffer. This fixes
"ship in a bottle" scenario.
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.