Sky Interface

class SiderealSkyInterface

An abstract interface class for a sky that is calculated using sidereal data.

Subclassed by simul::sky::SiderealSky

Public Functions

virtual const float *SiderealToEarthMatrix(double epoch_time, double latitude, double longitude) const = 0

Get a 4x4 transformation matrix to transform sidereal coordinates into azimuth and elevation.

virtual void GetSunPosition(float &azimuth, float &elevation, double epoch_time, double latitude, double longitude) const = 0
virtual void GetMoonPosition(float &azimuth, float &elevation, double epoch_time, double latitude, double longitude, const Orbit &orbit) const = 0
virtual double GetDawn(double epoch_time, double latitude, double longitude) const = 0
virtual double GetSunset(double epoch_time, double latitude, double longitude) const = 0
virtual double GetMoonRise(double d2000, double latitude, double longitude, simul::sky::Orbit moonOrbit) const = 0
virtual double GetMoonSet(double d2000, double latitude, double longitude, simul::sky::Orbit moonOrbit) const = 0
class OpticalLengthInterface

An abstract interface class for skies that can calculate optical lengths.

Subclassed by simul::sky::Sky

Public Functions

virtual float GetOpticalLength(float Elevation, float h_km, float distance_to_edge) const = 0
virtual float GetOpticalLength(float Elevation, float h_km) const = 0

Get the effective optical length (equivalent length at sea level density) of a ray cast from altitude h_km at angle Elevation above the horizon.

virtual float GetHazeFactorOpticalLength(float Elevation, float h_km, HazeStruct hazeStruct) const = 0

Get the effective optical length of haze of a ray cast from altitude h_km at angle Elevation above the horizon.

virtual float GetOzoneOpticalLength(float Elevation, float h_km) const = 0

Get the effective optical length of ozone of a ray cast from altitude h_km at angle Elevation above the horizon.

class BaseSkyInterface

An abstract interface class for skies.

Subclassed by simul::sky::SkyKeyframer

class AtmosphericScatteringInterface

An abstract interface class for skies.

Subclassed by simul::sky::Sky

General <br>

virtual vec3 GetLocalDirectionToSun(double epoch_time, double latitudeRadians, double longitudeRadians) const = 0

Get the direction to the sun.

virtual float GetMoonIrradianceFactor(const Moon &m, const vec3 &dir_to_moon, const vec3 &dir_to_sun) const = 0

Get the moonlight irradiance in space.

virtual vec3 GetLocalMoonIrradianceFactor(const Moon &m, float altitude_km, const vec3 &dir_to_moon, const vec3 &dir_to_sun, HazeStruct hazeStruct) const = 0

Get the moonlight that reaches the altitude altitude_km.

virtual vec3 GetLocalSunIrradiance(float altitude_km, const vec3 &sun_irradiance, const vec3 &dir_to_sun, HazeStruct hazeStruct) const = 0

Get the sunlight that reaches the altitude altitude_km.

virtual unsigned GetAtmosphericPropertiesChecksum() const = 0
virtual unsigned GetAtmosphericStateChecksum() const = 0
virtual vec4 GetColourLossFactor(const vec3 &view_pos_km, const vec3 &pos_km, HazeStruct hazeStruct, bool earth_test = false, int steps = 0) const = 0

Get the loss factor of an object at position pos_km seen from view_pos_km.

When an object has initial colour c, multiply each member of c by the corresponding member of the loss factor to get the colour as seen by the viewer.

virtual EarthShadow GetEarthShadow(float h_km, const vec3 &lightDir) const = 0

The Earth’s shadow, as seen from the given altitude.

virtual vec4 GetIsotropicColourLossFactor(float alt_km, float elevation, float min_dist_km, float max_dist_km, HazeStruct hazeStruct, bool earth_test = false, int steps = 0, bool blackbody = false, float emissivity = 0.f) const = 0

Get the loss factor of an object at position pos_km seen from view_pos_km. When an object has initial colour c, multiply each member of c by the corresponding member of the loss factor to get the colour as seen by the viewer.

virtual vec4 GetAnisotropicInscatterFactor(bool include_sunlight, float alt_km, float elevation, float min_dist_km, float max_dist_km, const vec3 &sun_irradiance, vec3 moon_albedo, const vec4 &starlight, const vec3 &dir_to_sun, const std::map<uid, vec3> &moonDirections, HazeStruct hazeStruct, vec4 wavelengthsNm, const OvercastStruct &overcast, bool earth_test, int steps) const = 0

Get the inscatter factor in the xyz - the 3-element factor which is multiplied by the 3-element factor Beta to get the inscattered colour. In the w element is the haze factor. This excludes skylight and starlight, which are not considered to be strongly anisotropic. See GetIsotropicInscatter().

virtual vec4 GetIsotropicInscatter(float alt_km, float elevation, float min_dist_km, float max_dist_km, const vec3 &sun_irradiance, vec3 moon_albedo, const vec4 &starlight, const vec3 &dir_to_sun, const std::map<uid, vec3> &moonDirections, HazeStruct hazeStruct, vec4 wavelengthsNm, const OvercastStruct &overcast, bool earth_test = false, int steps = 0) const = 0

Get the approximate isotropic inscatter, i.e. the inscatter without a dependence on the angle to the strongest light source. In particular, this includes skylight and starlight.

virtual vec4 GetBlackbodyInscatter(float alt_km, float elevation, float min_dist_km, float max_dist_km, const vec3 &sun_irradiance, vec3 moon_albedo, const vec4 &starlight, const vec3 &dir_to_sun, const std::map<uid, vec3> &moonDirections, HazeStruct hazeStruct, vec4 wavelengthsNm, bool earth_test = false, int steps = 0, float emissivity = 0.f) const = 0

Get the radiance due to blackbody radiation.

virtual vec4 GetInscatterAngularMultiplier(float cosine, float mie_factor, HazeStruct hazeStruct) const = 0

Get the multiplier for an inscatter factor that gives the total inscatter, where cosine is the cosine between the angle to the sun and the ray direction, mie_factor is the proportional haze factor (stored int the w element of the inscatter factor) and alt_km is the viewing altitude in km.

virtual float GetVisibilityDistance(float view_alt_km, HazeStruct hazeStruct) = 0

From the altitude specified, the distance in km to 10% visibility (mainly a factor of fog/haze).

virtual float GetHazeForVisibilityDistance(float view_alt_km, float horiz_dist_km, HazeStruct hazeStruct) = 0

Get the haze that will produce the required visibility distance in the horizontal direction.

virtual float GetOzoneAtAltitude(float alt_km) const = 0

Get the amount of ozone present at altitude alt_km. This is a dimensionless number.

virtual float GetHazeFactorAtAltitude(float alt_km, HazeStruct hazeStruct) const = 0

Get the amount of haze present at altitude alt_km compared to the amount at sea level. This value is independent of the overall Haze multiplier ( see GetHaze() ).

virtual float GetOvercastAtAltitude(const OvercastStruct &overcast, float alt_km) const = 0

Get the strength of the overcast effect at a given altitude, determined by Overcast, OvercastBaseKm, and OvercastRangeKm.

virtual vec4 GetSunlightFactor(float alt_km, const vec3 &DirectionToLight, HazeStruct hazeStruct) const = 0

Return the colour of sunlight passing through the stated altitude as a multiplier of the sun radiance in space.

virtual float GetDistanceToSpace(float Elevation, float h_km) const = 0

Considering the atmosphere as a shell of thickness GetAtmosphereThickness(), from altitude h_km, this function returns how far a ray cast at angle Elevation above the horizon would travel to reach the outer radius of the shell.

virtual float GetDistanceToEarth(float Elevation, float h_km) const = 0

From the specified altitude h_km, and in the direction of Elevation, how far is it in Km to the surface?

struct HazeStruct

A data structure to contain haze properties in the atmosphere at any given moment.

Public Functions

inline HazeStruct()
inline HazeStruct(float h, float b, float s, float e, const vec4 &m, const vec4 &r, const vec4 &o, float oz, float t_k)

Public Members

float haze
float haze_base_height_km
float haze_scale_height_km
float eccentricity
vec4 mie
vec4 rayleigh
vec4 BaseOzone
float OzoneStrength
float SeaLevelTemperatureK
struct OvercastStruct

Public Functions

inline OvercastStruct()
inline OvercastStruct(float o, float ob, float os)

Public Members

float overcast
float overcast_base_km
float overcast_scale_km
struct LightingState

Public Functions

inline LightingState()
inline void Reset()

Public Members

vec3 DirectionToSun
std::map<uid, vec3> MoonDirections
double longitudeRadians = 0.0
double latitudeRadians = 0.0
double headingRadians = 0.0
struct EarthShadow

Properties of the Earth’s shadow on the atmosphere and other objects.

Public Members

bool enable

If true, the Earth’s shadow should be visible above the horizon.

vec3 normal

normal is the direction normal to the sunlight direction

float radius_on_cylinder

radius_on_cylinder is the distance from the Earth’s centre to the viewpoint on the plane of the cylinder

float illumination_altitude

What altitude (in km) is the lowest that sunlight reaches, directly above/below the viewer.

float planet_radius

In km.

float terminator_distance_km

The shortest distance from the viewer TO the terminator, which will be in the direction TO the sun.

struct Orbit

Variables to adjust the orbit of a Moon. Values here are default values for Earth’s Moon. See Moon Docs for more information.

Public Members

double LongitudeOfAscendingNode = 125.1228

The points in which the moon crosses the plane of the equator.

double LongitudeOfAscendingNodeRate = -0.0529538083

The amount the ascending node increases each day.

double Inclination = 5.1454

This controls the tilt angle of the orbit.

double ArgumentOfPericentre = 318.0634

This is the closest point of the moon to the Earths surface.

double ArgumentOfPericentreRate = 0.1643573223

The amount the argument of pericentre increases each day.

double MeanDistance = 60.2666

The average distance the moon is from the centre of the earth.

double Eccentricity = 0.054900

This controls how elliptical the orbit of the moon will be around the earth.

double MeanAnomaly = 115.3654

This controls the position that the moon will be around its orbit at midnight of each day.

double MeanAnomalyRate = 13.0649929509

This controls how much the mean anomaly changes each day.

struct Moon

trueSKY supports multiple moons, each with their own orbit, size and texture.

Public Members

Orbit orbit

Orbit of the Moon.

float radiusArcMinutes = 15.88f

Radius of the moon in arc minutes. https://nssdc.gsfc.nasa.gov/planetary/factsheet/moonfact.html.

std::string textureFilename

Filename of moon texture, including file extension.

vec3 colour = {1.0f, 1.0f, 1.0f}

Colour of moon and produced lighting.

float albedo = 0.136f

Amount of light reflected by the moon.