FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SkyModel.h
1#pragma once
2
3#include <array>
4#include <vector>
5
23namespace visual::sky
24{
25
27using Rgb = std::array<double, 3>;
29using Vec3 = std::array<double, 3>;
30
33{
34 double groundRadius = 6360e3;
35 double topRadius = 6460e3;
36 Rgb rayleighScattering = {5.802e-6, 13.558e-6, 33.1e-6};
37 double rayleighHeight = 8000.0;
38 double mieExtinction = 1.2e-4;
39 double mieAlbedo = 0.9;
40 double mieHeight = 1200.0;
41 double mieG = 0.8;
42 Rgb ozoneAbsorption = {0.650e-6, 1.881e-6, 0.085e-6};
43 double ozoneCentre = 25e3;
44 double ozoneHalfWidth = 15e3;
45 double groundAlbedo = 0.06;
46 double sunAngularRadius = 0.004675;
47};
48
55
57double RayleighPhase(double cosTheta);
58
60double CornetteShanksPhase(double g, double cosTheta);
61
63double HenyeyGreensteinPhase(double g, double cosTheta);
64
70{
71public:
76 SkyModel(const Atmosphere& atmosphere, const Vec3& sunDirection, double cameraAltitude = 10.0);
77
85 Rgb Radiance(const Vec3& direction, int steps = 32) const;
86
89 Rgb SunIrradiance(double altitude) const;
90
92 Rgb SunIrradiance() const { return SunIrradiance(m_altitude); }
93
96
101 Rgb SkyIrradiance(int samples = 24) const;
102
108 Rgb Transmittance(double r, double mu) const;
109
111 const Atmosphere& Air() const { return m_air; }
112
114 const Vec3& SunDirection() const { return m_sun; }
115
117 double Altitude() const { return m_altitude; }
118
120 Rgb MeanExtinctionBelow(double h) const;
121
122private:
123 struct Medium
124 {
125 Rgb rayleigh; // scattering
126 Rgb mie; // scattering
127 Rgb extinction;
128 };
129 Medium Sample(double altitude) const;
130 Rgb MultipleScattering(double altitude, double muSun) const;
131 void BuildTransmittance();
132 void BuildMultipleScattering();
133
134 Atmosphere m_air;
135 Vec3 m_sun;
136 double m_altitude;
137 std::vector<Rgb> m_transmittance; // kTransMu x kTransR
138 std::vector<Rgb> m_multiple; // kMsMu x kMsH
139};
140
141} // namespace visual::sky
Definition SkyModel.h:70
Rgb Radiance(const Vec3 &direction, int steps=32) const
Rgb Transmittance(double r, double mu) const
Rgb SunDiscRadiance() const
Mean radiance of the sun's disc at the eye [1/sr]: SunIrradiance() / (pi radius^2).
Rgb SunIrradiance(double altitude) const
const Atmosphere & Air() const
Definition SkyModel.h:111
double Altitude() const
Definition SkyModel.h:117
Rgb SkyIrradiance(int samples=24) const
Rgb SunIrradiance() const
Direct sun irradiance at the eye (see SunIrradiance(double)).
Definition SkyModel.h:92
const Vec3 & SunDirection() const
Definition SkyModel.h:114
SkyModel(const Atmosphere &atmosphere, const Vec3 &sunDirection, double cameraAltitude=10.0)
Rgb MeanExtinctionBelow(double h) const
Definition CloudLayer.h:24
Atmosphere AtmosphereForVisibility(double visibility)
double RayleighPhase(double cosTheta)
Rayleigh phase function [1/sr] of the cosine of the scattering angle.
std::array< double, 3 > Vec3
A direction or position, NED unless stated.
Definition SkyModel.h:29
std::array< double, 3 > Rgb
Red, green, blue.
Definition SkyModel.h:27
double CornetteShanksPhase(double g, double cosTheta)
Cornette-Shanks phase function [1/sr] with asymmetry g.
double HenyeyGreensteinPhase(double g, double cosTheta)
Henyey-Greenstein phase function [1/sr] with asymmetry g.
Optical properties of the atmosphere (Hillaire 2020, Earth values; lengths in m, coefficients in 1/m)...
Definition SkyModel.h:33
Rgb rayleighScattering
At sea level.
Definition SkyModel.h:36
double mieHeight
Scale height of the aerosols (marine boundary layer).
Definition SkyModel.h:40
double rayleighHeight
Scale height of the molecules.
Definition SkyModel.h:37
double topRadius
Radius of the top of the atmosphere.
Definition SkyModel.h:35
double groundRadius
Radius of the sea surface.
Definition SkyModel.h:34
double sunAngularRadius
[rad].
Definition SkyModel.h:46
double ozoneCentre
Altitude of the ozone peak.
Definition SkyModel.h:43
double groundAlbedo
Diffuse albedo of the sea for the multiple scattering.
Definition SkyModel.h:45
double mieAlbedo
Single-scattering albedo of the aerosols.
Definition SkyModel.h:39
Rgb ozoneAbsorption
At the peak of the ozone layer.
Definition SkyModel.h:42
double ozoneHalfWidth
Half width of the (tent-shaped) ozone layer.
Definition SkyModel.h:44
double mieExtinction
Aerosol extinction at sea level (grey).
Definition SkyModel.h:38
double mieG
Asymmetry of the aerosol phase function.
Definition SkyModel.h:41