2023-01-24 06:44:20 +01:00
|
|
|
#include "cloudnoise.h"
|
|
|
|
#include "worleynoise.h"
|
|
|
|
#include "perlinnoise.h"
|
|
|
|
|
2023-01-24 07:52:55 +01:00
|
|
|
CloudNoise::CloudNoise(int size) : Noise(size)
|
2023-01-24 06:44:20 +01:00
|
|
|
{
|
|
|
|
// Some worley noises
|
|
|
|
WorleyNoise worleyNoise1(size, 3);
|
2023-01-24 11:18:03 +01:00
|
|
|
WorleyNoise worleyNoise3(size, 15);
|
2023-01-24 06:44:20 +01:00
|
|
|
|
|
|
|
// Some perlin noises
|
2023-01-24 08:35:10 +01:00
|
|
|
PerlinNoise perlinNoise1(size, 3);
|
|
|
|
PerlinNoise perlinNoise2(size, 15);
|
2023-01-24 06:44:20 +01:00
|
|
|
|
|
|
|
// Generate the noise
|
|
|
|
for (int x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
for (int y = 0; y < size; y++)
|
|
|
|
{
|
|
|
|
for (int z = 0; z < size; z++)
|
|
|
|
{
|
2023-01-24 07:52:55 +01:00
|
|
|
float sx = x / (float) size;
|
|
|
|
float sy = y / (float) size;
|
|
|
|
float sz = z / (float) size;
|
2023-01-24 06:44:20 +01:00
|
|
|
|
2023-01-24 07:52:55 +01:00
|
|
|
float worley1 = worleyNoise1.getNoise(sx, sy, sz);
|
|
|
|
float worley3 = worleyNoise3.getNoise(sx, sy, sz);
|
|
|
|
|
|
|
|
float perlin1 = perlinNoise1.getNoise(sx, sy, sz);
|
2023-01-24 08:35:10 +01:00
|
|
|
float perlin2 = perlinNoise2.getNoise(sx, sy, sz);
|
2023-01-24 06:44:20 +01:00
|
|
|
|
2023-01-24 08:35:10 +01:00
|
|
|
float noise = worley1 * 0.4f + worley3 * 0.12f + perlin1 * 0.36f + perlin2 * 0.12;
|
2023-01-24 06:44:20 +01:00
|
|
|
|
|
|
|
setNoise(x, y, z, noise);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|