Then, when actually applying lighting during rendering of the
scene, a given
eye space
position
p is transformed to
light-clip space
and mapped to the range
[(0, 0, 0), (1, 1, 1)], producing
a position
pos_light_clip. The
same
p is also transformed to
light-eye space, producing a position
pos_light_eye.
The
pos_light_clip position is used
directly in order to sample a value
d
from the shadow map (as with sampling from a projected texture with projective
lighting). The negated
z component of
pos_light_eye is encoded as a logarithmic
depth value using the same
depth coefficient
as was used when populating the shadow map, producing a value
k. Then,
k is compared against
d. If the
k
is less than
d, then this
means that
p is closer to
the light than whatever surface resulted in
d during the population
of the shadow map, and therefore
p
is not in shadow with respect to the light.