Graphics Reference
In-Depth Information
Figure 15.38.
A cow's head showing detailed surface normals (left) compared with the “Chia Pet” cow (right).
Exercises
1.
You have been given the
Rainbow( )
and
HeatedObject( )
color mapping
routines. Now write:
GrayScale( ), BlackGreen( ), GrayGreen( ),
GreenBrown( ), BlueWhiteRed( ),
and
RainbowWithContours( ).
2.
Sometimes it is useful to not show the scalar value as a continuous range
but as a series of stepped values. This is called
quantizing
. Redo the vol-
ume tracing, but with quantized scalar values. The results should look
something like the right-hand image in Figure 15.39.
3.
Add a tolerance,
uTol
, to the
volumetrace
shader, as shown in Fig-
ure 13.40.
4.
Add lighting to the volumetracing shader, as shown in Figure 15.41.
Hint: to do this, you need to have surface normals, but a volume has
no surface, so it shouldn't have normals. Fortunately, volume data has
pseudo-normals
, which can be used like real surface normals. You com-
pute a pseudo-normal at a particular location by taking the gradient
there,
=
∂
∂
S
x
∂
∂
S
y
∂
∂
S
z
n
,
,
,
that is, by sampling scalar values around the point where you are now.