[C#] Implementing 3DPerlin/Simplex Noise

Ok. I have some idea of how Perlin noise works and how Simplex noise is faster. I also get how you implement 2D noise. (You give x,y coords and receive float between -1.0 and 1.0 which you can use for z coords) But I can’t grasp the idea of implementing 3D Noise algorithm. I tried:

if(SimplexNoise.Generate(xWorldp, yWorldp, zWorldp)>0){
     ChunkHolder = 1; // Then i have another code that converts this into blocks.
}else{
     ChunkHolder = 0;
}

But it works just like normal Random generator.
Help?

A while ago I started on a Minecraft-clone project in my sparetime just for the interest in doing so, so I’ve worked a lot with procedural generation of terrain (which now works really great!), and while I’m still new to the area, hopefully I can help out a bit here :slight_smile:

First of all, I also started out trying to implement my own Perlin Noise methods, but in the end I actually ended up going with quite an awesome free Unity library which does an awesome job of offering a whole host of different noise functions. You can find it on the asset store here:
CoherentNoise for Unity3D

The library uses 3D perlin noise but can be used for 1D and 2D as well.

And in any case you should really refer to it’s manual for pure learning purposes, it has some great clear and basic explanations of the theory behind it all:
CoherentNoise manual

Now I don’t know if you are interested in implementing the perlin noise function purely for learning reasons. If you simply need to use the functionality but are not interested in how it is calculated please use the above library, no reason to do anything else :slight_smile:

Now if you want to implement it to learn how it’s actually done, there’s a few great articles that shows the actual implementation. The first one is:
Perlin Noise Article

The other one that I’ve found great is the documentation for the C++ perlin noise library LibNoise: LibNoise documentation

Is this what you are asking from your question? Or are you more concerned about how to actually use perlin noise in your application? In that case you would have to give me more specific examples of what you are trying to achieve :slight_smile:

Sounds like you’re trying to figure out how to get from random noise to a Minecraft-like world. The trick is to layer up multiple noise patterns at different sizes, along with rules that guide the randomness towards the ballpark result you’re after.

For example…(I’ll use a 2D heightmap rather than 3D voxels, because it’s easier to describe)

If you’re using a single noise pass to set cell heights, you’ll get random spikes. If you shrink the noise lookup dimensions then you should get rolling hills instead, as the heightmap picks up the interpolation between the noise values. That will give you very curvy fake-looking mountains and valleys.

So you also do a second noise lookup at a smaller scale (ie. a scale that gives you smaller landscape features), and add it to the first. This will add small hillocks onto your mountains and valleys.

Then you do another lookup at an even smaller scale and add a layer of small bumps and divots. Three passes is about the minimum to get a reasonably natural-looking terrain. These different-scaled noise lookups are called “octaves” after music.

Then you can also apply custom rules, such as “scale height down with distance from origin” which will give you an island centered on the origin. Make sense?

Minecraft does a ton of clever stuff to create it’s world, including erosion passes on the generated data. What you’ll want to do depends on what you’re trying to create.

why is that nobody ever really gives you a solution to a problem the just bog down your code with third party’s, general approach plugins take the time to learn it i will give you a link to the perlin noise creators newest pseudo noise algorythm. maybe youj can figure it out.

http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

@PastryGood covered almost everything I think, but if you want more examples, take a look here.