C# Class CellNoiseDemo.CellNoise

Show file Open project: freethenation/CellNoiseDemo

Public Methods

Method Description
CellNoiseFunc ( this input, int seed, Func distanceFunc, float &distanceArray, float>.Func combineDistancesFunc ) : System.Vector4

Generates Cell Noise

ChebyshevDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float
EuclidianDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float
ManhattanDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float

Private Methods

Method Description
hash ( uint i, uint j, uint k ) : uint

Hashes three integers into a single integer using FNV hash. FNV hash: http://isthe.com/chongo/tech/comp/fnv/#FNV-source

insert ( float arr, float value ) : void

Inserts value into array using insertion sort. If the value is greater than the largest value in the array it will not be added to the array.

lcgRandom ( uint lastValue ) : uint

LCG Random Number Generator. LCG: http://en.wikipedia.org/wiki/Linear_congruential_generator

probLookup ( uint value ) : uint

Given a uniformly distributed random number this function returns the number of feature points in a given cube.

Method Details

CellNoiseFunc() public static method

Generates Cell Noise
public static CellNoiseFunc ( this input, int seed, Func distanceFunc, float &distanceArray, float>.Func combineDistancesFunc ) : System.Vector4
input this The location at which the cell noise function should be evaluated at.
seed int The seed for the noise function
distanceFunc Func The function used to calculate the distance between two points. Several of these are defined as statics on the WorleyNoise class.
distanceArray float An array which will store the distances computed by the Worley noise function. /// The length of the array determines how many distances will be computed.
combineDistancesFunc float>.Func The function used to color the location. The color takes the populated distanceArray /// param and returns a float which is the greyscale value outputed by the worley noise function.
return System.Vector4

ChebyshevDistanceFunc() public static method

public static ChebyshevDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float
p1 System.Vector3
p2 System.Vector3
return float

EuclidianDistanceFunc() public static method

public static EuclidianDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float
p1 System.Vector3
p2 System.Vector3
return float

ManhattanDistanceFunc() public static method

public static ManhattanDistanceFunc ( System.Vector3 p1, System.Vector3 p2 ) : float
p1 System.Vector3
p2 System.Vector3
return float