Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | List of all members
G3D::Noise Class Reference


3D fixed point Perlin noise generator. More...

Public Member Functions

 Noise ()
 Not threadsafe. More...
 
int sample (int x, int y, int z)
 Returns numbers between -2^16 and 2^16. More...
 
float sampleFloat (int x, int y, int z, int numOctaves=1)
 Returns numbers on the range [-1, 1] for a single octave of noise. More...
 
uint8 sampleUint8 (int x, int y, int z)
 Returns numbers on the range [0, 255]. More...
 

Static Public Member Functions

static Noisecommon ()
 

Detailed Description


3D fixed point Perlin noise generator.

Ported from Ken Perlin's Java INoise implementation.

Referenced Code: Copyright 2002 Ken Perlin
Referenced Code: http://mrl.nyu.edu/~perlin/noise/

Example:

GImage im(256, 256, 1);
for (int y = 0; y < im.height(); ++y) {
for (int x = 0; x < im.width(); ++x) {
im.pixel1(x, y) = Color1unorm8(n.sampleUint8(x << 12, y << 12, 0));
}
}
im.save("noise.png");
See also
G3D::Random

Constructor & Destructor Documentation

◆ Noise()

G3D::Noise::Noise ( )
inline

Not threadsafe.

Member Function Documentation

◆ common()

static Noise& G3D::Noise::common ( )
static

◆ sample()

int G3D::Noise::sample ( int  x,
int  y,
int  z 
)
inline

Returns numbers between -2^16 and 2^16.

Arguments should be on the order of 2^16

Threadsafe.

Referenced by sampleUint8().

◆ sampleFloat()

float G3D::Noise::sampleFloat ( int  x,
int  y,
int  z,
int  numOctaves = 1 
)

Returns numbers on the range [-1, 1] for a single octave of noise.

Each octave adds 0.5 of the range of the previous one. An infinite number of octaves is bounded by [-2, 2].

Unique values occur at coordinates that are multiples of 2^16 for the lowest frequency octave. Between those the noise smoothly varies.

Threadsafe.

◆ sampleUint8()

uint8 G3D::Noise::sampleUint8 ( int  x,
int  y,
int  z 
)
inline

Returns numbers on the range [0, 255].

Arguments should be on the order of 2^16

Threadsafe.


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15