• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Endemoniada

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.

Edited by Endemoniada
0

Share this post


Link to post
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 this post


Link to post
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
x = fRadius * sin(fPeriodX);

//apply same to y
y = fRadius * cos(fPeriodY);
Edited by irreversible
0

Share this post


Link to post
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 this post


Link to post
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;
    
    t = FADE( fy0 );
    s = FADE( fx0 );
 
    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 ) );
}

Edited by Endemoniada
0

Share this post


Link to post
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:


rkwOkTz.png

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:

4QM9k4o.png

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 this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0