ShadowTex
uniform sampler2D shadowtexN;
There are two samplers for accessing the shadow depth buffer.
shadowtex0
includes all geometryshadowtex1
excludes transparent geometry
Writing
These buffers are automatically written to by the shadow
program, and store the screenspace z coordinate at each pixel. You can manually write to this buffer by setting the gl_FragDepth
variable in any gbuffers
fragment shader. If gl_FragDepth
is used in a shader, the automatic writing will be disabled and the shader is responsible for writing all depth values.
Size
These buffers are the same resolution as the Minecraft window. This cannot be configured.
Format / precision
These buffers only store information in a single channel, the r component. The precision is hardware/driver dependent. However, most hardware uses either 24-bit or 32-bit (R24 or R32) precision.
Clearing
These buffers all clear to vec4(1.0)
. This cannot be configured.
Flipping
These buffers do not flip.
Legacy
AliasesThe 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
.
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.