载入中...
搜索中...
未找到
SkyOpticalCycle.h
浏览该文件的文档.
1#pragma once
2#include <algorithm>
5namespace eve::graphics::detail {
8 const float day = std::clamp((sunY + .03604f) / (.03604f + .06319f), 0.f, 1.f);
9 const float night = (1 - day) * (1 - day), dusk = std::clamp(1 - sunY / .3f, 0.f, 1.f);
10 const float twilight = std::clamp((.025f - sunY) / .05f, 0.f, 1.f);
11 std::array<float, 3> absorption{};
12 for (size_t i = 0; i < 3; ++i) {
13 p.rayleigh[i] =
14 ((d.rayDay[i] * (1 - dusk) + d.rayDusk[i] * dusk) * (1 - night) + d.rayNight[i] * night) * d.rayDay[3];
15 absorption[i] = d.absorptionDay[i] * (1 - twilight) + d.absorptionNight[i] * twilight;
16 }
17 const float extremes = *std::min_element(absorption.begin(), absorption.end()) +
18 *std::max_element(absorption.begin(), absorption.end());
19 const float scale = d.absorptionDay[3] * (1 - twilight) + d.absorptionNight[3] * twilight;
20 // Hue +180 degrees in HSV, preserving saturation/value, equals max+min-RGB.
21 for (size_t i = 0; i < 3; ++i) p.ozoneAbsorption[i] = (extremes - absorption[i]) * scale;
22 return p;
23}
24inline constexpr unsigned OpticalLayers = 81;
25inline constexpr float OpticalMinimum = -.08f, OpticalMaximum = .32f;
26} // namespace eve::graphics::detail
glm::vec4 p[6]
std::array< float, 3 > scale
float d
constexpr float OpticalMinimum
constexpr unsigned OpticalLayers
SkyAtmosphereParameters opticalSample(SkyAtmosphereParameters p, const SkyDaylightLayer &d, float sunY)
Pure clear/manual optical projection. Inputs are validated authored values and sun Y in [-1,...
constexpr float OpticalMaximum
Spherical atmospheric coefficients in inverse kilometres and kilometre heights.
Immutable clear-sky daylight material controls, copied during sky preparation.