2023-01-24 05:22:40 +01:00
|
|
|
#ifndef CG1_TRACER_CLOUDSHADER_H
|
|
|
|
#define CG1_TRACER_CLOUDSHADER_H
|
|
|
|
|
|
|
|
#include "scene/scene.h"
|
|
|
|
#include "shader.h"
|
|
|
|
#include "primitive/primitive.h"
|
|
|
|
#include "common/noise/worleynoise.h"
|
|
|
|
|
2023-01-24 07:52:55 +01:00
|
|
|
int const NOISE_SIZE = 128;
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
struct CloudSettings
|
|
|
|
{
|
|
|
|
int densitySamples = 100;
|
2023-01-24 08:35:10 +01:00
|
|
|
float scale = 10;
|
2023-01-24 05:22:40 +01:00
|
|
|
float densityTreshold = 0.55f;
|
|
|
|
float densityIntensity = 2.5f;
|
|
|
|
float densityAbsorption = 1;
|
2023-01-24 08:39:13 +01:00
|
|
|
Color cloudColor = Color(1, 1, 1);
|
2023-01-24 05:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CloudShader : public Shader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CloudShader(CloudSettings const &settings = CloudSettings());
|
|
|
|
|
|
|
|
// Shader functions
|
|
|
|
Color shade(Scene const &scene, Ray const &ray) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CloudSettings settings;
|
|
|
|
|
|
|
|
|
|
|
|
bool isTransparent() const;
|
|
|
|
|
2023-01-24 06:26:24 +01:00
|
|
|
Noise cloudNoise;
|
2023-01-24 05:22:40 +01:00
|
|
|
|
|
|
|
float getCloudDensity(Vector3d point) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //CG1_TRACER_CLOUDSHADER_H
|