11
Algorithms for procedural
textures
In chapter 4 the basic idea of the procedural (or algorithmic) texture was in-
troduced. In this chapter we will look at some examples that take advantage of
those ideas to produce a collection of interesting surface textures. We will con-
centrate on what one might describe as following the basic principles of mixing
geometric and noise patterns.
It is important to realiz e that the procedural textures described in this chapter
do not have any basis in physical or biological principles; they are essentiall y just
“computer hacks” that look good and do the job.
All the textures con s id er ed in this chapter have b een implemented as either
DLL plug-ins or as GLSL shaders for OpenFX. After readin g this chapter and
chapter 9 you should be able to follow the finer details of a practical imple-
mentation of the algorithms in the OpenFX code. Since the first edition of this
book was printed it has become routinely possible to make use of the hardware
acceleration offered by the GPU, so algorithmic textures can now be generated
in real-time and with increasing sophistication. Despite their programmability,
GPUs are still specialized processors that are n owhere near as flex ib le as the
CPU of a traditional general purpose processor. They also have quite a limited
memory, especially for storing the s h ad er codes. Despite the C like form of the
GLSL it is usually necessary to re-engineer an algorithm’s implementation, from
the way it would be written in a standard high level langu age, to the way it
must be structured as a pair of G LS L shader programs. For examp le, rather
than generate a noise value using the Perlin algorith m an image map is used as
a lookup table.
Another reason for adopting a different approach to texture implementation
is the fact that the GPU is expected to render textures repeatedly in real-time,
and therefore, moving as many operations as possible into a execute once set-up
step becomes essential. For these reasons we offer two versions of the procedural
texture algorithms in this chapter, one that is usable within the limits imposed
by the GPU hardware and another for the general software approach where there
are no limits.
453

Get Practical Algorithms for 3D Computer Graphics, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.