bb44bce95c925d0acc8b8b5f8ebc8557fe042801
The goal of this PR is to remove any user facing parameter bias that fixes issues that are caused by inherent nature of the shadow map (aliasing or discretization). Compute shadow bias in the normal direction to avoid both shadow leaking at certain angles or shadow acnee. This bias is computed automatically based on the minimum bias amount required to remove all errors. The render setting is removed as of no use for now. #### Normal bias We do the bias in world space instead of shadow space for speed and simplicity. This requires us to bias using the upper bound of biases for the same location in space (using biggest texel world radius instead of UVZ bias). This isn't much of an issue since the bias is still less than 2 texel. The bias is still modulated by facing ratio to the light so surfaces facing the light have no biase. This fixes both self shadowing and flat occluders aliasing artifacts at the cost of moving the shadow a bit on the side. This is the blue arrow in the diagram. We always bias toward the normal direction instead of the light direction. This is alike Cycles geometric offset for the shadow terminator fix. This is better since it does'nt modify the shading at all. #### Slope bias To avoid aliasing issue on zero slope receiver, we still have to use the slope bias with a size of 1 pixel. #### PCF filtering We now parametrize the filter around the normal instead of using the shadow map local space. This requires to use a disk filter instead of box, which is also more pleasant for most light shapes (all except rectangle lights). Setting the filter around normal avoid overshadowing from zero slope occluders. This cannot be fixed by more slope bias in light space PCF. We could fix it in light space by projecting onto the normal plane but that gives an unbounded bias when `N.L` is near 0 which causes either missing shadows or self shadow if using an arbitrary max offset value. To avoid overshadowing from any surface behind the shading point, we reflect the offset to always face the light. Doing so instead of using the perpendicular direction is better for very sharp geometric angles, has less numerical precision issue, is symetrical and is cheaper. To avoid any self shadowing artifact on zero slope receivers with angled neighbors (like a wall and the floor), we have to increase the slope bias according to the filter size. This might be overkill in most situation but I don't feel this should become a setting and should be kept in sync with the filter. If it has to become an option, it should simply a factor between unbiased filter and best bias. #### Shadow terminator The remaining artifacts are all related to shadow terminator one way or another. It is always caused by the shading normal we use for biasing and visibility computation not being aligned with the geometric normal. This is still something we need a setting for somewhere. Pull Request: https://projects.blender.org/blender/blender/pulls/121088
…
Blender
Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.
Project Pages
Development
License
Blender as a whole is licensed under the GNU General Public License, Version 3. Individual files may have a different, but compatible license.
See blender.org/about/license for details.
Description
Languages
C++
78%
Python
14.9%
C
2.9%
GLSL
1.9%
CMake
1.2%
Other
0.9%
