vkmEngine 1.0.0
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 and Mie
14// layers, in metres. The one statement of it: the GPU sky bake (`shaders/ibl/sky`,
15// geometry via `GLBackend::shaderConstants`) and `sunTransmittance` on the CPU both
16// read it, so sky and sunlight agree.
17
18constexpr float PLANET_RADIUS = 6371000.0f;
19constexpr float TOP_RADIUS = 6471000.0f;
20constexpr float EYE_ALTITUDE = 1000.0f;
21
23inline const glm::vec3 RAYLEIGH_SCATTERING = {5.802e-6f, 13.558e-6f, 33.1e-6f};
24constexpr float RAYLEIGH_SCALE_HEIGHT = 8000.0f;
25
26constexpr float MIE_SCATTERING = 21.0e-6f;
27constexpr float MIE_EXTINCTION = 1.1f;
28constexpr float MIE_SCALE_HEIGHT = 1200.0f;
29
38 glm::vec3 mieScattering;
39 glm::vec3 mieExtinction;
40};
41
48Coefficients coefficients(const SkySettings& sky);
49
58glm::vec3 sunTransmittance(const SkySettings& sky);
59
66glm::vec3 sunlight(const SkySettings& sky);
67
68} // namespace Vkm::Engine::Atmosphere
The air's coefficients under an authored sky, per metre at sea level.
Definition atmosphere.h:36
glm::vec3 rayleighScattering
Also its extinction: Rayleigh absorbs nothing.
Definition atmosphere.h:37
glm::vec3 mieExtinction
Scattering plus absorption.
Definition atmosphere.h:39
Sky and image-based lighting: what the world is lit by and set against.
Definition environment.h:15