Graphics Reference
In-Depth Information
This 1D noise function makes up the botom edge of the 2D noise func-
tion shown in the 2D noise window in Figure 10.18. As you interactively make
changes in the 1D noise function, the changes also show up in the 2D func-
tion window. The 2D noise function can be displayed with your choice of
four color transfer functions according to the 2D Noise Texture radio butons.
Figure 10.18 shows the same 2D noise function with a rainbow scale (blue-to-
green-to-red), sky scale (blue-to-white), and fire scale (red-to-yellow).
Exercises
1. Experiment with noise: in the fragment shader for any of the chapter's
examples, use the different octaves of noise in different ways, as we did
with the cloud shader, to see how that can affect the texture. For example,
you might use
nv.r + 2.*(nv.g-.5) + 4.*(nv.b-.5) + 8.*(nv.a-.5) + 1.5
to use all four of the octaves at the same amplitude.
2. Illustrate a 2D noise function as a surface in the same way one would
develop a surface as the graph of a simple function of two variables. Use
a rather fine mesh in the domain to capture the shape of the function. Do
this for one-octave noise and four-octave noise, and compare the relation
between the shapers to the relation between the pseudocolor 2D noise
functions in Figure 10.5.
3. Use glman to examine the nature of the four individual octaves of noise by
creating a very simple fragment shader similar to that in the turbulence
shader shown in Figure 10.9. For each octave, write a shader that derives
a texture from that octave and uses a uniform slider variable to discard
pixels whose value is less than that slider's value. From that, determine
the smallest and largest value of the octave of noise.
4. Explore the difference between transparency and pixel discarding.
Instead of discarding pixels in the erosion shader, set the alpha value of
the pixels you would discard to zero. Describe what happens when you
rotate the scene, and why that happens.
5. Most of the examples in this chapter have used noise to set or modify
the color of a fragment, but you can also use it in other ways. Modify
the previous exercise to set the alpha component of each pixel with the
noise function so that the “transparency” is noisy, and note the effect.
(The effect might be best observed if you have two planes of different
Search WWH ::




Custom Search