18
$\begingroup$

I have been reading about the mathematics behind Perlin noise, a gradient noise function often used in computer graphics, from Ken Perlin's presentation and Matt Zucker's FAQ.

I understand that each grid point, $X$, has a pseudo-random gradient associated with it, $g(X)$ - just a vector of unit length that appears random. When finding the noise value at a point $P$, for each grid point surrounding it, $Q$, the dot product $g(Q) \cdot (P-Q)$ is found. Then these dot products are interpolated to find the noise value at point $P$.

The thing I don't understand, however, is why we use gradients. There is another type of noise function called value noise in which each grid point has a scalar value rather than a gradient. I've seen articles that say gradient noise produces higher quality noise but they don't explain why. I can't seem to visualise how this dot product makes the noise any better quality. What does "quality" even mean here? Why did Ken Perlin decide to use gradients?

$\endgroup$
8
  • $\begingroup$ A very interesting question. Surely the "true" answer depends on something in human visual function, not merely information-theoretic per se... as in JPEG, for example. I am very much interested in good answers to this question. $\endgroup$ Aug 18, 2012 at 22:37
  • 2
    $\begingroup$ "Quality" here mainly refers to the visual aesthetics of the result seen as a texture. You can quantify it a little in terms of the Fourier spectrum (for example, Wikipedia says gradient noise has more energy in higher frequencies), but I think most people just mean "it looks better". $\endgroup$
    – user856
    Aug 18, 2012 at 22:39
  • $\begingroup$ So now my question is "Why do gradients make noise look better?" $\endgroup$ Aug 18, 2012 at 22:45
  • 1
    $\begingroup$ I also really can't understand this. Presumably it could be analysed by looking at spectrograms. The "gradient thing" seems like it might be a convenient hack to get smoothness of (the first, at least) derivative, as suggested in another answer. Cubic interpolation could also do this, I believe, but instead of 2^d sample points, would need 3^d sample points in d dimensions. When 4d noise is used, this gets expensive: 81 sample points to compute each noise query (though each of the samples is cheaper). $\endgroup$
    – Benjohn
    Dec 29, 2017 at 7:47
  • 1
    $\begingroup$ Perlin noise also uses a "smoothing", "easing", or "fading" function to help obscure the underlying linear interpolation used between points. $\endgroup$
    – Benjohn
    Dec 29, 2017 at 7:50

4 Answers 4

8
$\begingroup$

This is just my guess.

In short: Gradient noise leads in general to more visual appealing textures because it cuts low frequencies and emphasizes frequencies around and above the grid spacing.

Let's compare a naive value noise procedure with a naive gradient one, for a grayscale image.

Value noise: we paint the points in the grid with random values (white noise) and fill the surrounding pixels by linear interpolation. This will look ugly because (among other things) some of the random grid points will happen to have similar values, and then there will be large spots with nearly uniform color (low frequency). [*] Specifically, the pixel values in the neighborhood of a grid point will be all similar - and so we depend on the other grid points being distinct to have high frequencies... and this will be at most (with luck) of the order of the grid separation.

Gradient noise: we compute a random (uniform, white noise) gradient in each grid point, and compute the values by interpolating the dot products of the gradient with the distances. Consider again what happens in the neighborhoood of a grid point, specifically over a small circumference, disregarding the effect of other distant grid points. It's seen that the computed image value (as a dot product) in this small neighborhood will visit -smoothly but fully- the white-black range. Then, we can expect that the image values will never have uniform spots, i.e., we won't practically have frequencies below that of the grid spacing.

[*] A similar problem arises in halftoning/dithering: it's visually unpleasant to use binary white noise because of the low frequency component; a nicer dithering algorithm, as Floyd-Steinberg, produces instead high frequency ("blue noise").

$\endgroup$
1
3
$\begingroup$

The answer is easy and mathematical. Mathematical quality.

With value noise the function has no zero at the point of the value - the lattice point.

If you see the value at the point as gradient, you got a zero of the function there and the gradient defines the tangent in that point.

The advantage is a smooth transition as the first derivative matches the left and the right side of the gradient, leading to a smooth seemingly transition.

With Perlins original polynomial of the 3rd degree, however, the second derivation was not zero, meaning it had a curvature at the lattice point.

Later he introduced the improved Perlin with the polynomial of the 5th degree, with also the second derivative being zero.

With this, the transition over a lattice point is absolutely linear no matter how far you "zoom" in and is always smooth.

$\endgroup$
1
  • 5
    $\begingroup$ But isn't it possible to get the same level of smoothness with value noise by just using cubic interpolation? The fact that the lattice points must yield a value of exactly zero actually seem to be a strong limitation. $\endgroup$
    – bluenote10
    Jul 20, 2015 at 10:12
2
$\begingroup$

A layman's answer, from experience in the Libnoise anyways, is that Value noise is not as curved as gradient noise... gradient noise assimilates blobs abit closer to round blob structures, whereas value noise seems to produce many straight edge capsule shaped blobs, and if you do mountains with it in 3d and 2d equation source, you will find many most mountains have some kind of capsule shape or a straight edge on one of their sides. i think if its less quality looking value noise must be abit faster.

In my experience, gradient noise is not perfectly smooth over transitions, at least it isnt a perfectly smooth rounded noise function... i wrote code that measures the smoothness of perlin noise and i found that all the libnoise functions i was using, were equally full of digital noise ( although i didnt know how to tweak the quality settings, was just using default libnoise value and gradient noise).

$\endgroup$
4
  • $\begingroup$ This post was edited but in such a way that it said things which ufomorace might not have actually wanted to say. The edited paragraph was as follows. "In my experience, gradient noise is not perfectly smooth over transitions, at least it isnt a perfectly smooth rounded noise function like a sinus curve is perfect, it is more like a slightly pixelated sinus... con.t $\endgroup$
    – user1729
    Sep 23, 2013 at 12:55
  • $\begingroup$ "i wrote code that measures the smoothness of perlin noise to apply shadowing to Perlin mountains and i found that all the libnoise functions i was using, were equally full of digital noise, resulting in increasing shadow artefacts when multiple Perlin noise was multiplied/added together. ( although i didnt know how to tweak the quality settings, was just using default libnoise value and gradient noise)." $\endgroup$
    – user1729
    Sep 23, 2013 at 12:56
  • $\begingroup$ sorry I did not realise I wasn't logged in, I indeed was the one that edited, I wished to qualify that any number of sinuses added together still produces a perfectly smooth curve, however large numbers of simplex and Perlin noise added together, resulted in a curve which was not smooth enough for accurate shadow calculation based on the actual curve tangents. $\endgroup$ Sep 23, 2013 at 13:20
  • $\begingroup$ Ah! That changes things! If you edit it when you are not logged in (or have lop rep. as you do) then your edits get vetted. If you are editing your own posts then they do not. So you should edit your own post while you are logged in, and then you can say whatever you want! $\endgroup$
    – user1729
    Sep 23, 2013 at 13:36
0
$\begingroup$

I think this may be to do with the relationship between the X and Y components of the gradients at each grid point.

Since, as you say, Perlin noise uses pseudo-random unit vectors at each grid point, the X and Y components of the unit vector are always related in the form y = sqrt(1-x^2).

Or to think of it another way, for a unit vector of angle $\theta$ to the horizontal x and y are related by x=cos($\theta$), y=sin($\theta$).

I would assume this would give the resulting interpolated surface different properties (more natural?) than one generated using random value noise.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.