Followers 0

# Tileable fBM Noise ?

## 7 posts in this topic

Hi guys, I'm trying to make 2D fBM tileable. I can make the underlying Perlin Noise tileable by adding an integer period to the implementation but the fBM built from it does not come out tileable. Any info would be appreciated.

0

##### Share on other sites

You should reduce x and y modulo px and py, once at the beginning; then you wouldn't need per-octave tricks.

Multiplying x and y by the scale factor is seriously wrong; the correlation s very likely to be visible. Instead, you could reduce px and py for finer scales and perturb the noise function (does it include a "seed"?) to make completely unrelated noise at each octave.

Another missing detail: the amplitude of each octave, definitely different if you want fBM noise.

0

##### Share on other sites

The simplest way to make 2D noise tileable is to make it periodic using some periodic function(s). Eg:

fScaleX = x / fPeriodSize; //0 <= x <= fPeriodSize
fPeriodX = fScaleX * 2 * PI; //0 <= fPeriod <= 2PI
fRadius = 1.f; //modify this to scale noise

//apply same to y

Edited by irreversible
0

##### Share on other sites
You can also use some form of interpolation noise (value noise or gradient noise) where the values assigned in the grid are periodic.
0

##### Share on other sites

Hi guys,

I am indeed using a 2D noise function, it's Perlin's Improved Noise, here it is:

It makes some pretty nice tileable textures but maybe they aren't as nice as they can be ? Some of your posts are hard to understand, maybe now that you see my code you can be more specific ? Thanks.

float pnoise2( float x, float y, int px, int py )
{
int ix0, iy0, ix1, iy1;
float fx0, fy0, fx1, fy1;
float s, t, nx0, nx1, n0, n1;

ix0 = FASTFLOOR( x ); // Integer part of x
iy0 = FASTFLOOR( y ); // Integer part of y
fx0 = x - ix0; // Fractional part of x
fy0 = y - iy0; // Fractional part of y
fx1 = fx0 - 1.0f;
fy1 = fy0 - 1.0f;
ix1 = (( ix0 + 1 ) % px) & 0xff; // Wrap to 0..px-1 and wrap to 0..255
iy1 = (( iy0 + 1 ) % py) & 0xff; // Wrap to 0..py-1 and wrap to 0..255
ix0 = ( ix0 % px ) & 0xff;
iy0 = ( iy0 % py ) & 0xff;

nx0 = grad2(perm[ix0 + perm[iy0]], fx0, fy0);
nx1 = grad2(perm[ix0 + perm[iy1]], fx0, fy1);
n0 = LERP( t, nx0, nx1 );

nx0 = grad2(perm[ix1 + perm[iy0]], fx1, fy0);
nx1 = grad2(perm[ix1 + perm[iy1]], fx1, fy1);
n1 = LERP(t, nx0, nx1);

return 0.507f * ( LERP( s, n0, n1 ) );
}


0

##### Share on other sites
It probably does work okay, and if it works for your needs then awesome; but a potential issue with performing tiling by constraining each octave to a repeating lattice pattern can be demonstrated by this image, of a ridged fractal being built up in layers:

The upper-left portion is 1 octave, upper right is 2, lower left is 3, and bottom right is 4 octaves. If you look at that image closely you will see some horizontal and vertical lines that grow more pronounced as more octaves are added. This is a consequence of generating noise on a lattice grid. Even though Perlin's gradient and simplex noise variants use wavelet functions to throw the peaks and valleys off of the grid points, the underlying grid structure is still there and it can appear as artifacts in the final result. Some fractal variants demonstrate the artifacts more strongly than others, but they are always going to be there. You can modify lacunarity to use non-integral values, and this will help to mitigate the problem somewhat since this ensures that successive grid lines don't exactly line up with one another. (Of course, this prohibits using your method of seamless tiling, due to the fractional sizes of successive layer grids.)

In order to make a noise fractal tile in your method, you have to use the underlying grid and make the grid pattern repeat based on some period, so you're going to have to live with the artifacts.

However, one common trick to reduce or eliminate the grid artifacts is to apply a randomized rotation around an arbitrary axis for each successive noise layer. That is, for each layer you generate a random axis/angle and use it to rotate the input coordinate before sampling the noise function for that layer. Here is a build-up of a ridged 4-layer fractal with random domain rotations:

If you look closely at it, you don't see the horizontal and vertical lines that occur in the previous image. That is because each layer is rotated on a different axis, and the rotation of a layer removes the pattern of noise from the grid axis (or, at least, causes you to "view" the grid from something other than straight-on). Thus, successively layer grid artifacts do not line up with previous grids, and the result is that no grid artifacts are manifest in the final result.

The problem with this approach is that you can't implement tiling using the periodic grid-based method you use, since that relies upon the edges of the periodically repeating grid pattern you use for each layer lining up with the edges of the image in the output, but the rotation throws that off completely.

Additionally, constraining your tiling algorithm to act upon the underlying grid of each layer of noise assumes that the noise that you are using is grid-based in the first place. If you want to use something that isn't grid-based, such as sparse convolution noise (where you take a scattering of non-grid-based randomized points and convolute them to produce the final signal) then you are stuck, since there is no underlying grid to manipulate to create periodicity. In that case, you would need to use some other type of seamless tiling algorithm (such as the blending or the 4D mapping I mentioned) in order to make it tile seamlessly.

It might not be an issue for you, though, depending on your application. If your algorithm works for you, then you probably don't need to mess with it. Just be aware that there can be artifacts that you might have to deal with.

Edit: Holy crikey, this post editor is funky sometimes Edited by JTippetts
1

##### Share on other sites

JTippetts, thanks a lot for explaining all that to me, I am really understanding it now; I can see you've done a lot of work with noise functions. Right now I'm pretty happy with my tileable 2D noise because I'm using it only for textures. One day I'd like to spend more time with this stuff, I find it fascinating.

Thanks again.

0

## Create an account

Register a new account