i
i
i
i
i
i
i
i
192 6. Texturing
is
p
adj
= p +
h · v
xy
v
z
. (6.7)
Note that unlike most shading equations, here the space in which the com-
putation is performed matters—the view vector needs to be in tangent
space.
Though a simple approximation, this shifting works fairly well in prac-
tice if the bump heights change relatively slowly [846]. Nearby neighboring
texels then have about the same heights, so the idea of using the original
location’s height as the new location’s height is reasonable. However, this
method falls apart at shallow viewing angles. When the view vector is near
the surface’s horizon, a small height change results in a large texture co-
ordinate shift. The approximation fails, as the new location retrieved has
little or no height correlation to the original surface location.
To ameliorate this problem, Welsh [1338] introduced the idea of offset
limiting. The idea is to limit the amount of shifting to never be larger than
the retrieved height. The equation is then
p
adj
= p + h ·v
xy
. (6.8)
Note that this equation is faster to compute than the original. Geometri-
cally, the interpretation is that the height defines a radius beyond which
the position cannot shift. This is shown in Figure 6.32.
At steep angles, this equation is almost the same as the original, since
v
z
is nearly 1. At shallow angles, the offset becomes limited in its effect.
Visually, this makes the bumpiness lessen at shallow angles, but this is much
better than essentially random sampling of the texture. Problems also
remain with texture swimming as the view changes, or for stereo rendering,
where the viewer simultaneously perceives two viewpoints that must give
consistent depth cues [846].
Figure 6.32. In parallax offset limiting, the offset moves at most the amount of the height
away from the original location, shown as a dashed circular arc. The gray offset shows
the original result, the black the limited result. On the right is a wall rendered with the
technique. (Image courtesy of Terry Welsh.)
i
i
i
i
i
i
i
i
6.7. Bump Mapping 193
Even with these drawbacks, parallax mapping with offset limiting costs
just a few additional pixel shader program instructions and gives a consid-
erable image quality improvement over normal mapping. For these reasons,
it has seen wide use in games and is today considered the practical standard
for bump mapping.
6.7.4 Relief Mapping
Bump mapping does not consider the heightfield itself, and so does not
modify texture coordinates. Parallax mapping provides a simple approxi-
mation of the effect of the heightfield, working on the assumption that the
height at one pixel is similar to the height at another. This assumption
can quickly break down. Also, where the bias (i.e., the “sea-level”) is set
affects how the heightfield is displayed. What we want is what is visible at
the pixel, i.e., where the view vector first intersects the heightfield.
Researchers have tackled this problem in a variety of different ways.
All methods perform some approximation of ray tracing along the view
vector until an intersection point is found. In a traditional ray tracer, the
algorithm would walk along the ray through the grid, forming the height
field and checking intersection with the relevant geometry in each grid cell
encountered. GPU-based approaches usually take a different approach,
leveraging the ability of the pixel shader to access texture data.
In computer graphics, just as in other fields, sometimes the time is
ripe for a particular idea. With relief mapping, three sets of researchers
independently developed the idea at about the same time, each without
knowledge of the others’ efforts. Brawley and Tatarchuk [138] presented
a straightforward method for finding the intersection, extended later by
with improved root finding [1244, 1248]. Policarpo et al. [1020, 1021] and
McGuire and McGuire [846] independently discovered and explored similar
methods. These algorithms have a variety of names—parallax occlusion
mapping (POM), relief mapping,andsteep parallax mapping—but take
essentially the same approach. For brevity, and to differentiate these ray-
tracing related methods from Kaneko and Welsh’s single-shift methods, as
a class we will call these relief mapping” algorithms. What is particularly
interesting about this case of parallel development is that the basic algo-
rithm of sampling a texture along a ray had actually been discovered 13
years earlier by Patterson et al. [991], which they call inverse displacement
mapping.
13
None of the newer researchers had been aware of this work at
13
This problem of multiple names persists today, with “parallax occlusion mapping”
and “relief mapping” being the two popular terms. The name “parallax occlusion map-
ping” was rather long, and the word “occlusion” confuses some readers (it does not
refer to shadowing, but to the fact that bumps can occlude each other), so we chose
“relief mapping. Even this name is not ideal, as this term was introduced by Oliveira
i
i
i
i
i
i
i
i
194 6. Texturing
Figure 6.33. The green eye ray is projected onto the surface plane, which is sampled at
regular intervals (the violet dots) and the heights are retrieved. The algorithm finds the
first intersection of the eye ray with the black line segments approximating the curved
height field.
the time of their parallel discoveries. There are undoubtedly more little-
remembered nuggets of research originally implemented on the CPU that
are ripe for GPU implementation.
The key idea is to first test a fixed number of texture samples along
the projected vector. More samples are usually generated for view rays at
grazing angles, so that the closest intersection point is not missed [1244,
1248]. Each texture location is retrieved and processed to determine if it
is above or below the heightfield. Once a sample below the heightfield is
found, the amount it is below, and the amount the previous sample is above,
are used to find an intersection location. See Figure 6.33. The location
is then used to shade the surface, using the attached normal map, color
map, etc. Multiple layered heightfields can be used to produce overhangs,
independent overlapping surfaces, and two-sided relief-mapped impostors;
see Section 10.8.
The heightfield tracing approach can also be used to have the bumpy
surface cast shadows onto itself, both hard [1021, 846] and soft [1244, 1248].
See Figure 6.34 for a comparison.
et al. [963] to denote a similar effect, though performed in a different way. Given that
Oliveira worked on both methods and has no problem with reusing the term, we decided
on “relief mapping.”
i
i
i
i
i
i
i
i
6.7. Bump Mapping 195
Figure 6.34. Parallax mapping compared to relief mapping. On the top of the cube
there is flattening with parallax mapping. Relief mapping is also able to provide self-
shadowing. (Images courtesy of Manuel M. Oliveira and Fabio Policarpo.)
The problem of determining the actual intersection point between the
two regular samples is a root-finding problem. In practice the height-
field is treated more as a depthfield, with the polygon’s plane defining
the upper limit of the surface. In this way, the initial point on the plane
is above the heightfield. After finding the last point above, and first
point below, the heightfield’s surface, Tatarchuk [1244, 1248] uses a sin-
gle step of the secant method to find an approximate solution. Policarpo
et al. [1021] use a binary search between the two points found to hone in
on a closer intersection. Risser et al. [1068] speed convergence by iterat-
ing using a secant method. There is a tradeoff here: Regular sampling
can be done in parallel, while iterative methods need fewer overall texture
accesses but must wait for results and perform slower dependent texture
fetches.
There is critical importance in sampling the heightfield frequently
enough. McGuire and McGuire [846] propose biasing the mipmap lookup
and using anisotropic mipmaps to ensure correct sampling for high-
frequency heightfields, such as those representing spikes or hair. One can
also store the heightfield texture at higher resolution than the normal map.
Finally, some rendering systems do not even store a normal map, preferring
to derive the normal on the fly from the heightfield using a cross filter [23].
Equation 12.2 on page 547 shows the method.
Another approach to increasing both performance and sampling ac-
curacy is to not initially sample the heightfield at a regular interval, but
instead to try to skip intervening empty space. Donnelly [271] preprocesses
the height field into a set of voxels, storing in each voxel how far away it is
from the heightfield surface. In this way, intervening space can be rapidly
i
i
i
i
i
i
i
i
196 6. Texturing
skipped, at the cost of higher storage for each heightfield. Wang [1322]
uses a five-dimensional displacement mapping scheme to hold distances to
the surface from all directions and locations. This allows complex curved
surfaces, self-shadowing, and other effects, at the expense of considerably
larger amounts of memory. Dummer [283] introduces, and Policarpo and
Oliveira [1023] improve upon, the idea of cone step mapping. The concept
here is to also store for each heightfield location a cone radius.Thisradius
defines an interval on the ray in which there is at most one intersection
with the heightfield. This property allows rapid skipping along the ray
without missing any possible intersections, though at the cost of needing
dependent texture reads. Another drawback is the precomputation needed
to create the cone step map, making the method unusable for dynamically
Figure 6.35. Normal mapping and relief mapping. No self-occlusion occurs with normal
mapping. Relief mapping has problems with silhouettes for repeating textures, as the
polygon is more of a view into the heightfield than a true boundary definition. (Images
courtesy of NVIDIA Corporation.)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset