cloudy-raytracer/common/noise/cloudnoise.cpp

36 lines
962 B
C++

#include "cloudnoise.h"
#include "worleynoise.h"
#include "perlinnoise.h"
CloudNoise::CloudNoise(int size) : Noise(size)
{
// Some worley noises
WorleyNoise worleyNoise1(size, 3);
WorleyNoise worleyNoise3(size, 8);
// Some perlin noises
PerlinNoise perlinNoise1(size, 15);
// Generate the noise
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size; y++)
{
for (int z = 0; z < size; z++)
{
float sx = x / (float) size;
float sy = y / (float) size;
float sz = z / (float) size;
float worley1 = worleyNoise1.getNoise(sx, sy, sz);
float worley3 = worleyNoise3.getNoise(sx, sy, sz);
float perlin1 = perlinNoise1.getNoise(sx, sy, sz);
float noise = worley1 * 0.6f + worley3 * 0.2f + perlin1 * 0.2;
setNoise(x, y, z, noise);
}
}
}
}