The amortized 2D noise class.
More...
#include <InfiniteAmortizedNoise2D.h>
|
| | CInfiniteAmortizedNoise2D (const unsigned n, const unsigned int s) |
| | Constructor. More...
|
| |
|
| ~CInfiniteAmortizedNoise2D () |
| | Destructor.
|
| |
| float | generate (int x, int y, const int m0, const int m1, const int n, float **cell) |
| | Generate a cell of 2D amortized noise. More...
|
| |
|
| virtual unsigned int | h (const unsigned int x, const unsigned int y) |
| | 2D hash function. More...
|
| |
| void | FillUp (float *t, const float s, const int n) |
| | Fill amortized noise table bottom up. More...
|
| |
| void | FillDn (float *t, const float s, const int n) |
| | Fill amortized noise table top down. More...
|
| |
| virtual void | initEdgeTables (const int x, const int y, const int n) |
| | Initialize the amortized noise tables. More...
|
| |
| void | initSplineTable (const int n) |
| | Initialize the spline table. More...
|
| |
| float | getNoise (const int i, const int j) |
| | Get one point of amortized noise. More...
|
| |
| void | getNoise (const int n, const int i0, const int j0, float **cell) |
| | Get 1 octave of amortized noise into cell. More...
|
| |
| void | addNoise (const int n, const int i0, const int j0, const float scale, float **cell) |
| | Add 1 octave of amortized noise into cell. More...
|
| |
|
|
float * | uax |
| | X coordinate of u used to compute a.
|
| |
|
float * | vax |
| | X coordinate of v used to compute a.
|
| |
|
float * | ubx |
| | X coordinate of u used to compute b.
|
| |
|
float * | vbx |
| | X coordinate of v used to compute b.
|
| |
|
float * | uay |
| | Y coordinate of u used to compute a.
|
| |
|
float * | vay |
| | Y coordinate of v used to compute a.
|
| |
|
float * | uby |
| | Y coordinate of u used to compute b.
|
| |
|
float * | vby |
| | Y coordinate of v used to compute b.
|
| |
|
float * | spline |
| | Spline table.
|
| |
|
unsigned int | seed |
| | Hash seed.
|
| |
The 2D amortized noise class implements the 2D infinite amortized noise algorithm.
◆ CInfiniteAmortizedNoise2D()
| CInfiniteAmortizedNoise2D::CInfiniteAmortizedNoise2D |
( |
const unsigned |
n, |
|
|
const unsigned int |
s |
|
) |
| |
Constructor.
- Parameters
-
| n | Cell size. |
| s | Hash function seed. |
◆ addNoise()
| void CInfiniteAmortizedNoise2D::addNoise |
( |
const int |
n, |
|
|
const int |
i0, |
|
|
const int |
j0, |
|
|
const float |
scale, |
|
|
float ** |
cell |
|
) |
| |
|
protected |
Add a single octave of noise into a subcell. This differs from CInfiniteAmortizedNoise2D::getNoise in that it adds the noise to the cell instead of copying it there.
- Parameters
-
| n | Granularity. |
| i0 | x offset of this subcell in cell. |
| j0 | y offset of this subcell in cell. |
| scale | Noise is to be rescaled by this factor. |
| cell | Noise cell. |
◆ FillDn()
| void CInfiniteAmortizedNoise2D::FillDn |
( |
float * |
t, |
|
|
const float |
s, |
|
|
const int |
n |
|
) |
| |
|
protected |
Fill amortized noise table top down.
- Parameters
-
| t | Amortized noise table. |
| s | Initial value. |
| n | Granularity. |
◆ FillUp()
| void CInfiniteAmortizedNoise2D::FillUp |
( |
float * |
t, |
|
|
const float |
s, |
|
|
const int |
n |
|
) |
| |
|
protected |
Fill amortized noise table bottom up.
- Parameters
-
| t | Amortized noise table. |
| s | Initial value. |
| n | Granularity. |
◆ generate()
| float CInfiniteAmortizedNoise2D::generate |
( |
int |
x, |
|
|
int |
y, |
|
|
const int |
m0, |
|
|
const int |
m1, |
|
|
const int |
n, |
|
|
float ** |
cell |
|
) |
| |
Generate a cell of 1/f amortized noise with persistence 0.5 and lacunarity 2.0.
- Parameters
-
| x | x coordinate of top left corner of cell. |
| y | y coordinate of top left corner of cell. |
| m0 | First octave. |
| m1 | Last octave. |
| n | Granularity. |
| cell | Cell to put generated noise into. |
- Returns
- Multiply noise by this to get into the range -1..1
◆ getNoise() [1/2]
| float CInfiniteAmortizedNoise2D::getNoise |
( |
const int |
i, |
|
|
const int |
j |
|
) |
| |
|
protected |
Compute a single point of a single octave of Perlin noise. This is similar to Perlin's noise2 function except that it substitutes table lookups for floating pointmultiplication as described in the paper "Amortized Noise".
- Parameters
-
| i | x coordinate of point. |
| j | y coordinate of point. |
- Returns
- Noise value at (x, y).
◆ getNoise() [2/2]
| void CInfiniteAmortizedNoise2D::getNoise |
( |
const int |
n, |
|
|
const int |
i0, |
|
|
const int |
j0, |
|
|
float ** |
cell |
|
) |
| |
|
protected |
Get a single octave of noise into a subcell. This differs from CInfiniteAmortizedNoise2D::addNoise in that it copies the noise to the cell instead of adding it in.
- Parameters
-
| n | Granularity. |
| i0 | x offset of this subcell in cell. |
| j0 | y offset of this subcell in cell. |
| cell | Noise cell. |
◆ h()
| unsigned int CInfiniteAmortizedNoise2D::h |
( |
const unsigned int |
x, |
|
|
const unsigned int |
y |
|
) |
| |
|
protectedvirtual |
A 2D hash function. Hash two dimensions into a single unsigned int using MurmurHash.
- Parameters
-
| x | X coordinate of value to be hashed. |
| y | Y coordinate of value to be hashed. |
- Returns
- Hash of (x, y).
◆ initEdgeTables()
| void CInfiniteAmortizedNoise2D::initEdgeTables |
( |
const int |
x0, |
|
|
const int |
y0, |
|
|
const int |
n |
|
) |
| |
|
protectedvirtual |
Initialize the amortized noise tables.
- Parameters
-
| x0 | x coordinate of top left corner of cell. |
| y0 | y coordinate of top left corner of cell. |
| n | Granularity. |
Reimplemented in CTerrainGenerator.
◆ initSplineTable()
| void CInfiniteAmortizedNoise2D::initSplineTable |
( |
const int |
n | ) |
|
|
protected |
Initialize the spline table as described in the paper "Amortized Noise".
- Parameters
-
The documentation for this class was generated from the following files: