Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Sky.hpp
1#pragma once
2
3#include "scene/Object.hpp"
4#include "resources/ResourcesManager.hpp"
5#include "system/Codable.hpp"
6#include "Common.hpp"
7
14class Sky final : public Object {
15
16public:
20 explicit Sky(Storage options);
21
26 void update(double fullTime, double frameTime) override;
27
39 bool decode(const KeyValues & params, Storage options) override;
40
44 KeyValues encode() const override;
45
49 const glm::vec3 & direction() const { return _sunDirection; }
50
54 glm::vec3 sunColor = glm::vec3(1.474f, 1.8504f, 1.91198f);
55 glm::vec3 kRayleigh = glm::vec3(5.5e-6f, 13.0e-6f, 22.4e-6f);
56 float groundRadius = 6371e3f;
57 float topRadius = 6471e3f;
58 float sunIntensity = 20.0f;
59 float kMie = 21e-6f;
60 float heightRayleigh = 8000.0f;
61 float heightMie = 1200.0f;
62 float gMie = 0.758f;
63 float sunRadius = 0.04675f;
64 float sunRadiusCos = 0.998f;
65 };
66
67private:
68 Animated<glm::vec3> _sunDirection { glm::vec3(0.0f, 1.0f, 0.0f) };
69};
Wraps an animated property so that the initial value is preserved.
Definition: Animated.hpp:11
Represent a 3D textured object.
Definition: Object.hpp:16
Represent a background environment with atmospheric scattering. The sun direction can be animated.
Definition: Sky.hpp:14
bool decode(const KeyValues &params, Storage options) override
Definition: Sky.cpp:7
KeyValues encode() const override
Definition: Sky.cpp:23
void update(double fullTime, double frameTime) override
Definition: Sky.cpp:30
Animated< glm::vec3 > _sunDirection
The sun direction.
Definition: Sky.hpp:68
const glm::vec3 & direction() const
Definition: Sky.hpp:49
Storage
Storage and loading options.
Definition: ResourcesManager.hpp:14
Represent a key-values tuple.
Definition: Config.hpp:9
Atmosphere parameters. Default values correspond to Earth-like atmosphere.
Definition: Sky.hpp:53
float sunRadius
Sun angular radius.
Definition: Sky.hpp:63
float heightMie
Mie characteristic height.
Definition: Sky.hpp:61
glm::vec3 sunColor
Sun direct color.
Definition: Sky.hpp:54
float gMie
Mie g constant.
Definition: Sky.hpp:62
float sunIntensity
Sun intensity.
Definition: Sky.hpp:58
float topRadius
Radius of the atmosphere.
Definition: Sky.hpp:57
float groundRadius
Radius of the planet.
Definition: Sky.hpp:56
float heightRayleigh
Mie characteristic height.
Definition: Sky.hpp:60
glm::vec3 kRayleigh
Rayleigh coefficients.
Definition: Sky.hpp:55
float sunRadiusCos
Cosine of the sun angular radius.
Definition: Sky.hpp:64
float kMie
Mie coefficients.
Definition: Sky.hpp:59