Creating a noise texture using GLM
To create a texture for use as a source of noise, we need some way to generate noise values. Implementing a proper noise generator from scratch can be a fairly daunting task. Luckily, GLM provides some functions for noise generation that are straightforward and easy to use.
In this recipe, we'll use GLM to generate a 2D texture of noise values created using a Perlin noise generator. GLM can generate 2D, 3D, and 4D Perlin noise via the function glm::perlin
.
It is common practice to use Perlin noise by summing the values of the noise function with increasing frequencies and decreasing amplitudes. Each frequency is commonly referred to as an octave (double the frequency). For example, in the following image, we show the results of the 2D Perlin noise function sampled at four different octaves. The sampling frequencies increase from left to right. The leftmost image is the function sampled at our base frequency, and each image to the right shows the function...