Files
test2/source
Clément Foucault 410282e156 EEVEE: Add quantized geometric normal for shadow bias
This improves the situations where the shading normal is far from the
best shadow bias direction. This is particularly noticeable on low poly
meshes with smooth normals.

This patch fixes the issue by storing a quantized version of the
geometric normal in the Gbuffer.
Only 6 bits are used (each axis uses 2 bits). This is stored inside the
gbuffer header since it is always available and has some spare bits to
store this data.

This quantization is only done if the error introduced by using the
shading normal is higher than using the quantized normal. This means
that flat shaded surfaces will not have any quantization artifact.
For smooth shaded surfaces, the quantization is only effective if the
shading normal is quite different (greater than ~20° difference)
than the geometric normal.

The attached blendfile contains an example Material that shows
how the quantization is done. This was used to find the threshold
value with the least amount of error.

To compensate the quantization error,  we increase the normal bias by
~20% which is subpixel if the shadow texel density is high enough.

This also changes the forward shading pipeline to use the geometric
normal for bias.

The first Light closure normal is now used for the attenuation function
since this is the most representative of the final shading. This normal
being inverted for transmission closures, we have to negate the normal
in the attenuation computation.

Pull Request: https://projects.blender.org/blender/blender/pulls/136136
2025-03-21 19:07:46 +01:00
..