Graphics Reference
In-Depth Information
Integer
Z
buf
Reverse Mapped Integer
Z
buf
1
1
0.8
0.8
0.6
0.6
0.4
0.4
0.2
0.2
0
0
0
0.5
Xwin
1
2
1
2
0.5
0
0.5
1
Xeye
Warped
Z
buf
Reverse Mapped Warped
Z
buf
1
1
0.8
0.8
0.6
0.6
0.4
0.4
0.2
0.2
0
0
0
0.5
Xwin
1
2
1
2
0.5
0
0.5
1
Xeye
Figure 36.13: The points in (x
,
z bufferValue) space that are exactly representable under
fixed-point, reverse-mapped fixed-point, and floating-point schemes. Fixed-point represen-
tations result in wildly varying depth precision with respect to screen-space x (or y).
topic. We summarize the basic ideas of the common mappings here and show Fig-
ures 36.13 and 36.14 by them to give a sense of the impact of representation on
precision throughout the frustum.
Following (arbitrary) OpenGL conventions, for the following definitions let
z
be the position on the camera-space
z
-axis of the point coloring the sample. It is
always a negative value. Let the far and near clipping planes be at
z
f
=
−
f
and
z
n
=
−
n
.
36.3.1.1 Hyperbolic
The classic graphics choice describes a hyperbolically scaled normalized value
arising from a projection matrix. This is typically called the
z
-buffer
because
it stores the
z
-component of points after multiplication by an API-specified per-
spective projection matrix and homogeneous division. This representation is also
known as a
warped
z
-buffer because it distorts world-space distances.
The OpenGL convention maps
−
n
to 0,
−
f
to 1, and values in between hyper-
bolically by
f
+
n
f
2
fn
1
z
.
z
→
n
+
(36.1)
−
f
−
n
Direct3D maps to the interval [
−
1, 1] by
f
fn
1
z
.
z
→
f
−
(36.2)
n
−
n
−
f