Random vs Noise

Weird question that may just be that I’m confused or missing something.

Let’s say I want to do procedural generation. So I need to get some repeatably random numbers that I can use.

Cool.

But why would I use say simplex noise or perlin noise or something like that instead of just seeding Random with some value and going “Gimme the next one”?

Let me give an example. I might use say a 3D Simplex noise function for world space since I could put a player’s location in the array and get initial seed values for the objects nearby. But once I’ve got that… why wouldn’t I use (or should I just use) Random with a seed for items in the immediate area?

If you want consistent random values based on location… then use a noise function.

If you want consistent random values based on “the order you ask”… then use Random.

These are two WAAAAY different things.

1 Like

Ah gotcha. So if I want to go “Hey. I want the 12th random value”

In random I’d have to go .next() a buncha times until I got to the 12th one.

In noise I just go valueAt(12) or whatever.

Huh. I knew I was missing something. Thanks!

More like valueAt(12, 34) or valueAt(12, 34, 56) depending on if its a 2D or a 3D noise function. I guess there is one dimensional noise but it’s not used often in my experience.

“How high should this terrain be?” is probably based on 2D noise.

“Should there be a block here like in Minecraft?” is probably based on 3D noise. (or some complicated 2D noise)

“Should the fifth spawned monster drop loot?” could be based on Random… if you want it repeatable.

Though really the cases for Random are kind of rare. If the player goes left versus right and hits a different monster spawner then “fifth spawned monster” could be something totally different than when you played.

I use regular Random in Mythruna’s tree generation but only because I use a statistical distribution for trees/plants instead of a spatial one. (the plan was to always switch to fractal planting patterns later). So I seed the Random object with the seed of that particular “chunk” of the world. Then as I iterate (in consistent order) over the possible tree/plant locations, I check the value of Random() against a set of conditions.

Even if I use a spatial noise-based planting plan, I’d probably skew it by the consistent sequential random values. It turns out that a statistical distribution will produce more interesting results even if they aren’t particularly realistic. Sometimes nature doesn’t make sense, either.

So it will likely be that I never have code that is purely noise based for tree placement because it would be too uniform. Example: large clump of well spaced trees surrounded by plants/grass in a nice border, etc… Likely I will use it as an influence on Random… else I will have to layer several fractal octaves onto it before it’s useful. (And truthfully, the ‘should I plant this here’ question has a lot of potential inputs other than a randomization factor.)

1 Like

So basically go on a per case basis is what you’re suggesting.

For my use case I planned on using some sort of 3D noise to determine the size and existence of asteroids at a given location, but was going to use a Random internally to each asteroid Geometry for making each a unique shape (seeded by the aforementioned noise).

Does that seem reasonable?

It just seemed a bit heavy handed to throw in a noise function into each geometry when the number of actual random points is pretty small (I plan on having a handful of major feature “points” and then tessellating in between them with a smoothing algorithm to make them not spiky).

1 other question. I seem to recall that Perlin noise is under patent protection. Which noise function is “safe” to use in that regard? OpenSimplex?

I don’t think this is true. Minecraft is essentially a 3D perlin noise visualization engine. It’s not even clever about hiding it for those of us who easily recognize what perlin noise looks like.

There are plenty of open source versions out there, too, I guess. I cobbled my own together from a few different sources, as I recall… and from “the book”. The one written (partially) by Perlin himself. (which is really excellent if you can find it)

The one I have from 1992 or so:
https://smile.amazon.com/Texturing-Modeling-Procedural-Approach-1994-11-30/dp/B01K0RQCSQ/ref=sr_1_5?ie=UTF8&qid=1501605721&sr=8-5&keywords=texturing+and+modeling+a+procedural+approach

The more recent version:
https://smile.amazon.com/Texturing-Modeling-Third-Procedural-Approach/dp/1558608486/ref=sr_1_1?ie=UTF8&qid=1501605721&sr=8-1&keywords=texturing+and+modeling+a+procedural+approach

Even for your asteroids, 3D noise might be better. It just depends on the effect you want. The nice thing about things like Perlin noise is that they are spatially coherent. Values near each other tend to change gradually which makes it very nice for seeding terrain fractals and the like. Whether that adapts well to asteroid generation depends entirely on the approach used, I guess.

3 Likes

Perlin noise is in the engine in jme3-terrain

Also simplex noise is basically perlin noise.

1 Like

Thanks for the resources! Once I have the asteroids semi working, so they at least have the right functions, I’ll be sprucing up the code so going the route you’ve suggested might be the way and the light for my project. I’ll have to see. My asteroid approach is… Well… Could be interesting… At least I hope it’ll work.

… Well that certain makes things a bit easier. No need to hunt down a decent jar with a noise function in it. Thanks!

Incidentally, there is a post I did some time (way) back:

It’s a map generator application that I used to design the fractals for Mythruna’s terrain (and I use it for tons of similar stuff as well). It can be fun to play with just because it’s in many cases a direct implementation of a lot of the ideas in the terrain sections of the Texturing and Modeling book already mentioned.

From that thread, a screen shot of the editor with Mythruna’s settings:

2 Likes

Thanks again! Looks like @t0neg0d was mucking with tessellation as well. Might have to rummage through that entire thread as it seems to cover a lot of the topics I’m interested in.