There's more...

Rather than using unsigned byte values, we could get more resolution in our noise data by using a floating-point texture. This might provide better results if the effect needs a high degree of fine detail. The preceding code needs relatively few changes to achieve this. Just use an internal format of GL_RGBA32F instead of GL_RGBA, use the GL_FLOAT type, and don't multiply by 255 when storing the noise values in the array.

GLM also provides periodic Perlin noise via an overload of the glm::perlin function. This makes it easy to create noise textures that tile without seams. We'll see how to use this in the next recipe.

Get OpenGL 4 Shading Language Cookbook - Third 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.