vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
atmosphere.h
1#pragma once
2
3#include <glm/glm.hpp>
4
5namespace Vkm::Engine {
6
7struct SkySettings;
8
9} // namespace Vkm::Engine
10
11namespace Vkm::Engine::Atmosphere {
12
13// The procedural sky's atmosphere: an Earth-like planet under Rayleigh, Mie and ozone
14// layers, in metres. The one statement of it: the backend writes it into every shader's
15// prelude, so sky and sunlight agree.
16
17constexpr float PLANET_RADIUS = 6371000.0f;
18constexpr float TOP_RADIUS = 6471000.0f;
19constexpr float EYE_ALTITUDE = 1000.0f;
20
22inline const glm::vec3 RAYLEIGH_SCATTERING = {5.802e-6f, 13.558e-6f, 33.1e-6f};
23constexpr float RAYLEIGH_SCALE_HEIGHT = 8000.0f;
24
25constexpr float MIE_SCATTERING = 21.0e-6f;
26constexpr float MIE_EXTINCTION = 1.1f;
27constexpr float MIE_SCALE_HEIGHT = 1200.0f;
28
31inline const glm::vec3 OZONE_ABSORPTION = {0.650e-6f, 1.881e-6f, 0.085e-6f};
32constexpr float OZONE_ALTITUDE = 25000.0f;
33constexpr float OZONE_HALF_WIDTH = 15000.0f;
34
36constexpr float GROUND_ALBEDO = 0.3f;
37
40constexpr int TRANSMITTANCE_STEPS = 256;
41
50 glm::vec3 mieScattering;
51 glm::vec3 mieExtinction;
52
53 bool operator==(const Coefficients& other) const {
55 && mieScattering == other.mieScattering
56 && mieExtinction == other.mieExtinction;
57 }
58};
59
66Coefficients coefficients(const SkySettings& sky);
67
76glm::vec3 sunTransmittance(const SkySettings& sky);
77
87glm::vec3 solarIlluminance(const SkySettings& sky);
88
95glm::vec3 sunlight(const SkySettings& sky);
96
97} // namespace Vkm::Engine::Atmosphere
The air's coefficients under an authored sky, per metre at sea level.
Definition atmosphere.h:48
glm::vec3 rayleighScattering
Also its extinction: Rayleigh absorbs nothing.
Definition atmosphere.h:49
glm::vec3 mieExtinction
Scattering plus absorption.
Definition atmosphere.h:51
Sky and image-based lighting: what the world is lit by and set against.
Definition environment.h:16