## What to do when Perlin Noise becomes zero?

### What to do when Perlin Noise becomes zero?

Hi!

I have just recently played around a little bit with Perlin's noise function
and I was puzzled by it.

I have implemented a 2D version of it and afterwards I tried to use it to
add turbulence to a bitmap picture. At my very first attempt I discovered
that the resulting picture didn't have any turbulence in it. After having
investigated the problem a bit I discovered that when I passed integer
values (the coordinates of my pixels) to the noise function I always got 0
back, so it was pretty obvious why I couldn't see any turbulence. Obviously
one cannot have a noise function which does not make any noise, so what

For those technical interrested the zero-value explanation goes as follows:

1) All the computed ease-curve interpolation values will be zero, because
there is no difference between the point of interest and the lowest closest
grid point in the lattice.

2) This means that the dot product of the lowest corner gradient and the
difference vector from this corner is always picked when we do the linear
interpolation.

3) However since the difference vector is zero the dot product also becomes
zero and that is why the return value is zero.

I have currently solved the problem by rescaling my pixel-coordinates into
another parameter-range before looking up my turbulence value. This means I
have turned integer values into "floating"-values, however this does not
seem to be a feasible solution, because the turbulence suddenly depends both
on the number of octaves and the value-range Im scaling with.

Could anybody please tell me if Im doing something wrong or how I should fix
the problem?

Kenny

### What to do when Perlin Noise becomes zero?

Hi Kenny,

far as I know in most cases Perlin Noise is implemented on
"floating-point kernel" and in my implementation, result is 8-bit  depth
grayscale image. I can send you code snippet (CPP)  if you want.

In folowing article Perlin Noise is used to get output on 8-bit image with
predefined
palette using MMX instructions:

http://www.cloudnet.com/~anthony/Mathematics/Perlin_noise/proctex.htm

However if you want to "turbulate" your BITMAP, I think you'll find interesting

http://www.best.com/~beale/gimp/warp.html

Hope this helps,
Sinisa Petric
http://www.sigmapi-design.com

### What to do when Perlin Noise becomes zero?

> I have currently solved the problem by rescaling my pixel-coordinates into
> another parameter-range before looking up my turbulence value. This means I
> have turned integer values into "floating"-values, however this does not
> seem to be a feasible solution, because the turbulence suddenly depends both
> on the number of octaves and the value-range Im scaling with.

> Could anybody please tell me if Im doing something wrong or how I should fix
> the problem?

The basic Perlin noise function is gradient noise. It is defined as
0 at all integer lattice points. The rescaling that you are doing is
the way I always handle this problem. The size of the turbulence
elements are defined as the amount of the scaling. Also consider
adding a random offset (some x,y values that are constant across the
whole image but different for each image) to each image to the noise
coordinates to avoid having the noise look the same for all images.
As far as the number of octaves goes, consider using log2(n)-2 where
n is the image size and log2 is the base 2 logarithm ( log(n)/log(2.0)
in C ). This value should give you a number of octaves that is limited
by the resolution of the screen. Of course, you'll then need to handle
fractional octaves, but that's not too hard.
If you haven't seen it yet, try to find a copy of Texturing and
Modeling (A procedural approach) by Ebert, Musgrave, Peachey, Perlin,
and Worley [ISBN 0-120-228730-4]. This book has a great deal of
information on noise functions and basic rendering.
Joe Slayton

### What to do when Perlin Noise becomes zero?

By the way I have been told that the book you mention sugest a combination
of gradient noise and value noise to avoid the lattice problem.

Regards

Kenny

> > I have currently solved the problem by rescaling my pixel-coordinates
into
> > another parameter-range before looking up my turbulence value. This
means I
> > have turned integer values into "floating"-values, however this does not
> > seem to be a feasible solution, because the turbulence suddenly depends
both
> > on the number of octaves and the value-range Im scaling with.

> > Could anybody please tell me if Im doing something wrong or how I should
fix
> > the problem?

>   The basic Perlin noise function is gradient noise. It is defined as
> 0 at all integer lattice points. The rescaling that you are doing is
> the way I always handle this problem. The size of the turbulence
> elements are defined as the amount of the scaling. Also consider
> adding a random offset (some x,y values that are constant across the
> whole image but different for each image) to each image to the noise
> coordinates to avoid having the noise look the same for all images.
>   As far as the number of octaves goes, consider using log2(n)-2 where
> n is the image size and log2 is the base 2 logarithm ( log(n)/log(2.0)
> in C ). This value should give you a number of octaves that is limited
> by the resolution of the screen. Of course, you'll then need to handle
> fractional octaves, but that's not too hard.
>   If you haven't seen it yet, try to find a copy of Texturing and
> Modeling (A procedural approach) by Ebert, Musgrave, Peachey, Perlin,
> and Worley [ISBN 0-120-228730-4]. This book has a great deal of
> information on noise functions and basic rendering.
>   Joe Slayton

We're pleased to announce the availability
of a Perlin Noise plug-in for the Leveller
heightfield editor. Although Lars Hamre had
developed one last year, it was only compatible
with old versions of Leveller. Fortunately,
he had forwarded his work to us, so we
upgraded it to make a new plug-in, which
includes some new features as well.

Daylon Graphics Ltd.
http://www.daylongraphics.com/
"heightfield editing perfected"