# Perlin / Simplex noise questions

This topic is 3032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I have been looking into Perlin noise and simplex noise recently and in all of my researching I see that the way that you compute these is by creating a grid of random values(squares/cubes/hypercubes for original perlin or triangles/tetrahedrons/?? for simplex). After that you cycle through all of the pixels in the image and determine which block they are in. From there various tutorials talk about how you have to compute the dot product based on the gradient vector of the corner for all of the corners to get the final value. So I thought about this for a little while and is it not just:
m = maximum distance from one corner to the other
d = actual distance
v = value of the corner point
y = end result

y = v0(d0 / m) + v1(d1 / m) + v2(d2 / m) + v3(d3 / m)

And saying that is it not the same as the square-diamond method, minus anything past the values of the corner values?

Please tell me that I am misinterpreting how to generate this noise, the method just seems too simple =/. ...Or maybe I am just being dumb and I need to read up more on vectors. If I am completely wrong about this feel free to flame me about the availability of Google.

Thanks,
Chris

##### Share on other sites
Yes you have different size grids with different random values. For each pixel you check in each grid what the value is. There is a persistence value (explained in the first link in google for perlin noise) which applies a weight and determines how much each octave affects the final value. To find the value for a single octave for a pixel you simply find the cell it exists in and interpolate the 4 corner values. I recommend cosine interpolation.

Perlin Noise. Right click and view source. I wrote it sequentially and it's a very simple version that's tileable using the wraparound method (setting the edges equal to the opposite corners). Normally you'll see it written so that it can be ran in a fragment shader.

Remember though that basic perlin noise is just the start. If you apply thresholds to the values or smoothing you can create cool values (thresholds are for clouds, flooring low values, I believe or stepped terrain by applying integer division like value / 5 * 5). Also the octaves you choose greatly affect the final result. (I mean different size grids effect the final result. You don't have to use 64x64,32x32,16x16 and such. You can use 64x64, 64x64, 32x32 and since the persistence value falls off you can get interesting effects).

##### Share on other sites

So basically you were saying that I am correct in my pseudo-math =)

And about tiling the noise based on the the script that you have it does not seem to be graphically sound to tile perlin noise with extremes eg the noticeable repetition of patterns if black blobs. I am guessing this can be rectified by rather than using the full -1 to 1 range to just using -.7 to .7 to attempt to effeminate problem spots, correct?

Thanks,
Chris

##### Share on other sites
Hi, Chris, not exactly sure about your terminology (maximum distance means grid/lattice spacing?) - that isn't exactly equivalent to linear interpolation, if that's what you mean. For your first term, a circle of value v0 would be produced around point0 at a distance of 1; for 2D linear interpolation, a line of value v0 would be produced, since it's a linear function, and there's no way two intersecting planes produce a circle (in rectilinear space). Additionally, calculating distance is a more expensive operation. Still, noise can be produced a number of ways.

##### Share on other sites
Sorry if I was not clear. What I mean by max distance is the farthest anyone point would have influence. So in the case of a square grid that had a spacing of 10 units; the most distant point would be sqrt(10^2+10^2) units away based on the Pythagorean theorem.

So a point at (2,2) with v0 = (0,0), v1 = (10,0), v2 = (0,10), v3 = (10,10) would be:

v0 = 12
v1 = 54
v2 = 98
v3 = 200
MAX = sqrt(10^2+10^2)
dist0 = MAX - sqrt(2^2+2^2)
dist1 = MAX - sqrt(2^2+8^2)
dist2 = MAX - sqrt(8^2+2^2)
dist3 = MAX - sqrt(8^2+8^2)

value = v0(dist0 /MAX) + v1(dist1 /MAX) + v2(dist2 /MAX) + v3(dist /MAX)
110.3 = 12(11.2 / 14.1) + 54(5.8 / 14.1) + 98(5.8 / 14.1) + 200(2.7 / 14.1)

Wow as I run some real numbers I realize that I made some major mistakes xD. Becuase of this I am right now writing a mini script to play with to see what works. Will post on progress

So simplified all I am doing is saying based on how far it is form a point is it 23% of this and 43% of this and another 10% of this...

EDIT ran some tests and it seems as though this method does not work =/. Thanks for the help anyways.
Chris

[Edited by - Chris_0076 on August 28, 2010 1:57:38 AM]

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013558
×