Trade-offs

As previously mentioned, three methods can be used to generate noise values in a shader. How do you know which is the best choice for your application? A lot depends on the underlying implementation, but generally speaking, if we assume a hardware computation of noise that does not use texturing, the points favoring usage of GLSL built-in noise function are the following:

• It doesn’t consume any texture memory (a 128 × 128 × 128 texture map stored as RGBA with 8 bits per component uses 8MB of texture memory).

• It doesn’t use a texture unit.

• It is a continuous function rather than a discrete one, so it does not look “pixelated” no matter what the scaling is.

• The repeatability of the function should be undetectable, especially ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth 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.