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; }