ShadowTex
uniform sampler2D shadowtexN;
There are two samplers for accessing the shadow depth buffer.
shadowtex0
includes all geometryshadowtex1
excludes transparent geometry
These buffers are written to by shadow
program, which renders the scene from the perspective of the sun or moon.
These buffers only store information in a single channel, the red component. The shadow buffer precision is hardware/driver dependent, however most hardware uses either 24-bit or 32-bit precision. The resolution of the shadow pass can be controlled with the shadowMapResolution
constant.
Hardware Sampling
shadowHardwareFiltering
enables support hardware sampling (depth comparison mode) for hardware shadow filtering. This turns the shadowtex samplers into sampler2DShadow
samplers, which when sampled take the full xyz coordinates of the shadow position. The passed z coordinate is then compared to the values in the buffer around the xy coordinate, and the result is the weighted average of these comparisons. This produces a filtering effect on the shadow with very little to no performance impact. More information can be found in the Khronos Wiki.
When hardware sampling is used, the texture read no longer returns the distance stored in the buffer, but the result of a filtering depth comparison. This prevents its use in algorithms such as PCSS that rely on the actual value stored in the buffer. However Iris enables the use of separate buffers for hardware sampling, shadowtex0HW
and shadowtex1HW
, while retaining the original functionality on the base shadowtex buffers. This requires the SEPARATE_HARDWARE_SAMPLERS
feature flag as well as setting shadowHardwareFiltering
to true.
Legacy Aliases
The alias waterShadow
points to the same buffer as shadowtex0
. If waterShadow
is present anywhere in the code, then the alias shadow
will point to the same buffer as shadowtex1
, otherwise it will point to the buffer shadowtex0
.