-
-
Notifications
You must be signed in to change notification settings - Fork 116
Getting started using FastNoise2
There are 2 ways to use FastNoise2, creating a node tree structure in code or importing a serialised node tree created using the NoiseTool.
This is creating a Simplex Fractal FBm with 5 octaves from code
auto fnSimplex = FastNoise::New<FastNoise::Simplex>();
auto fnFractal = FastNoise::New<FastNoise::FractalFBm>();
fnFractal->SetSource( fnSimplex );
fnFractal->SetOctaveCount( 5 );
...
Here is the same Simplex Fractal FBm with 5 octaves but using serialised data from the NoiseTool
FastNoise::SmartNode<> fnGenerator = FastNoise::NewFromEncodedNodeTree( "DQAFAAAAAAAAQAgAAAAAAD8AAAAAAA==" );
...
This is the node graph for the above from the NoiseTool (right clicking a node title will give the option to Copy Encoded Node Tree
)
After setup of a FastNoise2 node from the previous steps here is an example of using it to generate a 16x16x16 volume of noise
...
// Create an array of floats to store the noise output in
std::vector<float> noiseOutput(16 * 16 * 16);
// Generate a 16 x 16 x 16 area of noise
fnGenerator->GenUniformGrid3D(noiseOutput.data(), 0, 0, 0, 16, 16, 16, 0.2f, 1337);
int index = 0;
for (int z = 0; z < 16; z++)
{
for (int y = 0; y < 16; y++)
{
for (int x = 0; x < 16; x++)
{
ProcessVoxelData(x, y, z, noiseOutput[index++]);
}
}
}
Make sure you call the Gen
function on the root node in your node tree.
For example if you have a fractal node with a simplex source node (as in the above code) you want to call the Gen
function on the fractal node. Calling it on the simplex node would result simplex noise output with no fractal.