Graphics Reference
In-Depth Information
Figure 10.8. Three-dimensional noise visualized by isosurfaces through the middle value;
one octave (left) and four octaves (right).
Using Noise with glman
The glman tool automatically creates a 3D noise texture and places it into
Texture Unit 3. Your vertex, geometry, or fragment shader can access it through
the pre-created uniform variable called Noise3 . You can reference it in your
shader as
uniform sampler3D Noise3;
. . .
vec3 stp = ...
vec4 nv = texture( Noise3, stp );
The “noise vector” texture nv is a vec4 whose components have separate
meanings. We will access these components through the rgba nameset, though
you can use indices or any other nameset if you wish. The .r component is
the low frequency noise. The .g component is twice the frequency and half
the amplitude of the .r component, and so on for the .b and .a components.
Each component is centered around the middle value of .5, so that if you want
a plus-or-minus effect, subtract .5 from each component. To get a nice four-
octave noise value between 0 and 1, useful for features such as noisy color
mixing, add up all four components, subtract 1, and divide the result by 2, as
shown in Table 10.1.
Search WWH ::




Custom Search