Thursday, April 7, 2016

Simplex Noise

Last time we made good progress on our planets. We made it so that when we are high above them they will have very little detail and when we are own the ground they will have lots of detail. However, we still just have a circular planet. We are going to need a way to give it more detail. To do this we are going to use a new noise algorithm, Simplex Noise.

Simplex Noise was actually designed by the same person who designed Perlin Noise, Ken Perlin. He considered Perlin Noise to have too many problems and to be poorly done and he wanted to correct those. Not only did he fix the problems that Perlin Noise had, he also successfully made a faster algorithm. Speed is going to be vital to us when we start moving around the planet because we want to render this in real time so this algorithm works perfectly for us. Let's take a look at how it works.

We can see here that the bulk of our algorithm is in the method called RawNoise3D. Simplex Noise has the advantage of being able to be done in multiple dimensions. We are rendering a 3D planet so we want 3-dimensions. This means that noise will wrap around the planet evenly and we will not see differences across different faces. Perfect!

The actual algorithm uses a "seed" of permutations to manipulate the data around a certain point, not the actual point itself. The math behind it is rather complex so I will not be going over it in detail. The next snippet we see is our two methods that we will use.

The method OctaveNoise3D is where we have variables that start to make the algorithm work. Then ScaledOctaveNoise3D will generate values that are in between an upper and lower bound. These are the two that we will use when generating our examples. Lets run it and see how it looks.
We can see here that this looks a lot like Perlin Noise! That's because it is. They both generate similar results but they do so in different ways. This will be what we use to make our terrain for our planet.

As usual the code is in Github here. I hope you enjoyed this and learned something new. Thanks for reading.

No comments:

Post a Comment