How to do it...

Modify the code from the previous recipe in the following way.

Within the innermost loop, instead of calling glm::perlin, we'll instead call the overload that provides periodic Perlin noise. You will need to replace the following statement:

float val = glm::perlin(p) / scale; 

Replace it with the following:

float val = 0.0f; 
if( periodic ) { 
  val = glm::perlin(p, glm::vec2(freq)) / scale; 
} else { 
  val = glm::perlin(p) / scale; 
} 

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.