Creating a seamless noise texture
It can be particularly useful to have a noise texture that tiles well. If we simply create a noise texture as a finite slice of 3D noise values, then the values will not wrap smoothly across the boundaries of the texture. This can cause hard edges (seams) to appear in the rendered surface if the texture coordinates extend outside of the range of zero to one.
We can create a noise texture that is seamless by making use of the fact that the noise functions are defined on an infinite domain. Instead of simply storing the noise values directly within the texture, we store a linear interpolation of the noise value with three other noise values located at the corners of a rectangle with the same dimensions as the texture itself.
In the following figure, the solid line represents the boundaries of the texture within the noise function's space. The value that we store in the texture at point A will be the linear interpolation of the raw noise values at A, B, C, and...