Specific cloud noise

This commit is contained in:
Maximilian Giller 2023-01-24 06:44:20 +01:00
parent 3b644c8d29
commit 1dd7d845d9
5 changed files with 52 additions and 5 deletions

View file

@ -0,0 +1,32 @@
#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, 12);
// Some perlin noises
PerlinNoise perlinNoise1(size, 10);
// 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 worley1 = worleyNoise1.getNoise(x, y, z);
float worley3 = worleyNoise3.getNoise(x, y, z);
float perlin1 = perlinNoise1.getNoise(x, y, z);
float noise = worley1 * 0.6f + worley3 * 0.2f + perlin1 * 0.2;
setNoise(x, y, z, noise);
}
}
}
}

14
common/noise/cloudnoise.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef CG1_TRACER_CLOUDNOISE_H
#define CG1_TRACER_CLOUDNOISE_H
#include "noise.h"
class cloudnoise : public Noise
{
public:
cloudnoise(int size);
};
#endif //CG1_TRACER_CLOUDNOISE_H

View file

@ -20,6 +20,7 @@
#include "shader/cloudshader.h"
#include "common/noise/perlinnoise.h"
#include "shader/noiseshader.h"
#include "common/noise/cloudnoise.h"
int main()
{
@ -37,6 +38,9 @@ int main()
busShader);
// Add floor
// auto noise = std::make_shared<cloudnoise>(32);
// noise->invert = true;
// auto noiseShader = std::make_shared<NoiseShader>(noise, 0.2f);
auto noiseShader = std::make_shared<NoiseShader>(std::make_shared<PerlinNoise>(256, 10), 0.02f);
// auto floorShader = std::make_shared<SimpleShadowShader>(Color(0.9f, 0.9f, 0.9f));
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, 0.0f), Vector3d(0.0f, 1.0f, 0.0f),

View file

@ -1,4 +1,5 @@
#include "cloudshader.h"
#include "common/noise/cloudnoise.h"
Color CloudShader::shade(const Scene &scene, const Ray &ray) const
@ -82,10 +83,7 @@ bool CloudShader::isTransparent() const
}
CloudShader::CloudShader(const CloudSettings &settings) : settings(settings),
cloudNoise(WorleyNoise(
NOISE_SIZE,
NOISE_POINTS)
)
cloudNoise(cloudnoise(NOISE_SIZE))
{
cloudNoise.invert = true;
}

View file

@ -7,7 +7,6 @@
#include "common/noise/worleynoise.h"
int const NOISE_SIZE = 32;
int const NOISE_POINTS = 5;
struct CloudSettings
{