Stateless noise algorithms?

Get answers to all your basic programming questions. No Ogre questions, please!
Trioxin
Halfling
Posts: 63
Joined: Thu Jul 15, 2010 6:04 am
x 6

Stateless noise algorithms?

Post by Trioxin »

Evening Ogre forum :)
I'm creating a terrain paging component. (I know ogre has one, but I'm doing this for fun :D)

I'm making 128x128 "square" maps, using 129x129 points to overlap, creating a visually seamless connection when placed beside each other.

The thing I particularly enjoy about the perlin noise algorithm is how seemingly stateless it is.

For example if I was using a diamond square algorithm to generate a cloud grid, when moving onto a new block I would fill the borders of that block with the borders of surrounding blocks. The unfortunate effect here is that as no block will ever know what's happening on the blocks that haven't been reached yet, I would achieve a different result depending on how I reach it. For example if I go directly right, it fills the borders on one edge, but if I go up-right-down, it fills the borders on two edges, resulting in a different map since there's greater constraint.
Errrr I hope I was clear there.

With perlin noise, I just tell it what coordinate I want, and it will consistently give me the "correct" value regardless of what surrounds it.
The beauty of this is that when calculating normals, I will always be able to access adjacent vertices, even if they don't exist, allowing me to create a fully seamless mesh.

Unfortunately perlin noise is fairly limited on its own, and I'd like to combine it with other forms of noise in order to enhance the interestingness of my scene.

Inverted Voronoi noise for example would make for some fantastic natural pathways with a little bit of filtering or capping of values:
Image

Unfortunately I can't find (nor do I believe exists) a stateless system, as it must build the list of points per square. This makes it particularly prone to visual predictability of map edges, and creates seams if those wall edges aren't corrected based on prior, existing edge blocks. This brings me back to the problem of diamond square generation, and makes normal calculation for edges a nightmare :p


So, in order to boost my morale and generally just help me out, is anyone aware of a stateless noise algorithm other than perlin? I'd be ever so grateful!
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Stateless noise algorithms?

Post by bstone »

I'll guess you will have to stick with cleverly mapping perlin noise to suit your needs. Stateless is not the only thing here. Other features of perlin noise are important too.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: Stateless noise algorithms?

Post by jacmoe »

It's called 'coherent noise'.

No matter how many pages you have, it will be seamless.

I use Libnoise currently, but I am sure that a search for 'coherent noise' will turn up something else.. Like Noise++.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: Stateless noise algorithms?

Post by Kojack »

Accidental Noise looks like a pretty cool library, maybe it has something.
(It's zlib licensed)
Trioxin
Halfling
Posts: 63
Joined: Thu Jul 15, 2010 6:04 am
x 6

Re: Stateless noise algorithms?

Post by Trioxin »

Accidental Noise looks nice. Since I haven't had any indepth look yet I've no idea how it compares to libnoise, but I always prefer the liberal licenses.
Trioxin
Halfling
Posts: 63
Joined: Thu Jul 15, 2010 6:04 am
x 6

Re: Stateless noise algorithms?

Post by Trioxin »

Hmm, it seems to still use a memory-eating points list, so I expect voronoi noise will be out of the question for me. Ideally I'm looking at minimal (or constant) memory usage whereby I can just fire in a 1/2/3d coordinate and get the result of a calculation back out without having to store arrays of data.
So far perlin noise DOES seem like the only option.
I did try rather unsuccessfully to make a "fake" voronoi noise algorithm, but it looked much too uniform. Looks like I'll need to try harder than that ;)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: Stateless noise algorithms?

Post by Kojack »

Perlin Noise stores arrays of data too. The original code uses 514 ints and 3084 floats.
Trioxin
Halfling
Posts: 63
Joined: Thu Jul 15, 2010 6:04 am
x 6

Re: Stateless noise algorithms?

Post by Trioxin »

Ah but that data is constant, and never grows in size, which is what I'm after.
I can potentially create one perlin noise class to provide data to as many 128x128 blocks as I want, without exponential memory usage as my array of chunks grows.
It allows me to keep the code to generate a chunk fairly simple. All I have to do is pass in three variables, a pointer to the perlin class, and the X/Y offsets to use for the block.
To avoid repetition if it eventually starts looping round sooner than I would expect, I can create a second perlin class to offset the values by, using an out of sync frequency and combine them.
Or as I'm hoping, a second, different noise function to modify the terrain and add sufficient variance that it would go undetected unless someone was specifically looking for the pattern, and was fluent in the techniques used for the noise.


In the map itself, the 3d model is saved out once created, and once the predefined cache of maps is exceeded, the furthest away ones are cleared from memory and if needed, will load back in from a file rather than generate through a function.

The reason I'm concerned about voronoi or any other storing a list of values,
I'd need to also create all adjacent tiles to ensure that it meshes seamlessly at the borders. (Most likely controlled by the library if I take that route)
This creates the problem of memory management, particularly if controlled by a third party library where I'm not expected to want to clear lists, and it ahs issues regenerating should I need to.
I've already tried chopping up the ANL library to just take out what I need, but the scope of the project leaves me somewhat daunted by the sheer volume of code, most of it useless to me. (3D, 4D, 6D noise) and some coding practices I personally wouldn't want in my project due to inconsistency with my own style. (Namespaces, separating generators and modules, classless functions, etc)
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: Stateless noise algorithms?

Post by lingfors »

libnoise voronoi noise doesn't use a list of points, it uses coherent noise to generate the points surrounding the position you are querying.
Trioxin
Halfling
Posts: 63
Joined: Thu Jul 15, 2010 6:04 am
x 6

Re: Stateless noise algorithms?

Post by Trioxin »

Accidental Noise doesn't seem to either, so I may very well be good old fashioned wrong. :roll:

I've began crowbarring the bits I want into my toy project and at least as far as separating the files from the main library, it works on my test heightmap.
I do believe all's going rather well now :mrgreen: