Game Development Reference
In-Depth Information
After dividing by w , we arrive at the following value for the projected z
coordinate.
+
n
fn
f
2
(
)
P
′ =+
1
ε f
+
z
(
)
nPf
n
z
f
+
n
2
fn
f
+
n
=
+
+
ε
(9.4)
(
)
f
nPf
n
f
n
z
Comparing this to the z coordinate in Equation (9.2), we see that we have found a
way to offset projected depth values by a constant
ε
f
n
.
f
n
9.1.2 Offset Value Selection
Due to the nonlinear nature of the z -buffer, the constant offset given in Equation
(9.4) corresponds to a larger difference far from the camera than it does near the
camera. Although this constant offset may work well for some applications, there
is no single solution that works for every application at all depths. The best we
can do is choose an appropriate ε , given a camera-space offset δ and a depth val-
ue P , that collectively represents the object that we are offsetting. To determine a
formula for ε , we examine the result of applying the standard projection matrix
from Equation (9.1) to a point whose z coordinate has been offset by some small
δ as follows.
f
+
n
2
fn
f
+
n
2
fn
(
)
P δ
+
P δ
+
z
z
f
n
f
n
f
n
f
n
=
(9.5)
1
(
)
1
0
−+
P δ
z
Dividing by w , we have the following value for the projected z coordinate.
f
+
n
2
fn
P
′ =
+
z
(
)(
)
f
n Pδ f
+
n
z
f
+
n
2
fn
2
fn
1
1
=
+
+
(9.6)
(
)
f
nPf
n f
nPδ P
+
z
z
z
Equating this result to Equation (9.4) and simplifying a bit, we end up with
2
fn
δ
ε
=−
.
(9.7)
(
)
f
+
nPPδ
+
z
z
Search Nedrilad ::




Custom Search