Graphics Reference
In-Depth Information
Similar kinds of textures can be created with other
iterative processes [36]. An example would be a Julia set
texture that uses a slightly different kind of computa-
tion. For the function sequence as defined above,
() =+ and f
+ () = () +
2
2
fz zc
0
z fz c
,
n
1
n
we change the focus and start with the point z as the
input and some fixed complex number c as a constant.
This yields a rather different kind of image, but one
related to the Mandelbrot set image by whether the
complex number c is in the Mandelbrot set, and if so,
where it is. The fragment shader code to implement this
is quite similar to the code given above, and is left as an
exercise to the reader.
Bump Mapping
Bump mapping is a technique that simulates variations in
a surface by manipulating the surface normals, allow-
ing the lighting process to create the appearance of the
variations. The key is to think about normals, not ver-
tices, and to realize that in a fragment shader, you are
touching each pixel individually. This technique can
use an analytic approach and compute normals as func-
tion derivatives, as we will see with the ripple example
below, or it can use a more geometric approach and
compute normals based on location and the slopes of
the shape of the bump patern, as we will see in the pyr-
amid map example.
Figure 9.5. A region of the Mandelbrot
set computed with single precision
(top) and double precision (botom).
Height Fields with Bump Mapping
Many effects can be created by bump mapping. One important use is in dis-
playing height fields. . For example, bump mapping can create the ripples on a
surface, as shown in Figure 9.6; the figures also include a coordinate system
for a particular pixel on the surface. Notice the difference between the ripples
made by bump mapping, where the ripples do not, in fact, have any height,
and ripples made in a vertex shader, as shown in Figure 3.4 of Chapter 3.
To analyze these bumps so that we can design appropriate mappings of
normals, let's start working in 2D, where we can draw figures more easily. If a
Search WWH ::




Custom Search