Sky Keyframer¶
-
class SkyKeyframer : public simul::sky::BaseKeyframer, public simul::sky::BaseSkyInterface
A class that maintains sky properties and interpolates them based on keyframe values.
An instance of the SkyKeyframer is kept as a member of the Environment instance. The SkyKeyframer interpolates the sky values, and passes the keyframe and interpolation data to external renderers, e.g. SkyRenderer and AtmosphericsRenderer. The generated tables are calculated for multiple altitudes - specified with SetNumAltitudes. The SunIrradiance value determines the colour and strength of sunlight, and is expressed in physical units. The apparent size of the sun is set using SetSunRadiusArcMinutes.
Public Functions
-
void GetStartDate(int &y, int &m, int &d) const¶
What date is referred to as time zero.
-
void GetCurrentDate(int &y, int &m, int &d) const¶
Get the current date of the simulation.
-
void SetStartDate(int y, int m, int d)¶
Set the date for time=0.
-
float GetPlanetRadiusKm() const¶
Get the radius of the planet.
-
virtual float GetHorizonElevation(float h_km) const override¶
The elevation of the horizon at this altitude.
-
virtual float GetTemperatureKelvins(float h_km) const override¶
Return the temperature at the stated altitude in kelvins (subtract 273.15 to get celsius).
-
void CalcSunIrradianceAtEarth()¶
Calculate SunIrradiance using the solar irradiance tables outside Earth’s atmosphere, based on ColourWavelengthsNm.
-
void OverrideSunDirection(float az, float el)¶
Set the current direction of the sun by it’s Azimuth and Elevation.
-
void OverrideMoonDirection(float az, float el)¶
Set the current direction of the moon by it’s Azimuth and Elevation.
-
virtual bool HasFloat(const char *name) const override¶
Return true if the keyframer has the floating point value with the given, case-insensitive, name; return false otherwise.
These are the properties the SkyKeyframer has:
MaxStarMagnitude
MinimumStarPixelSize
MaxDistanceKm
MaxAltitudeKm
atmosphereThicknessKm
planetRadiusKm
MaxSunRadiance
BrightnessPower
OzoneStrength
Emissivity
MoonAlbedo
SunRadiusArcMinutes
MoonRadiusArcMinutes
sunazimuth
sunelevation
moonazimuth
moonelevation
sunazimuthdegrees
sunelevationdegrees
moonazimuthdegrees
moonelevationdegrees
sunirradiance
colourwavelengthsnm
-
virtual float GetFloat(const char *name, const base::Variant *params = NULL) const override¶
Get a float with the given, case-insensitive, name.
-
virtual float GetDefaultFloat(const char *name) const override¶
Return the default float value with the given, case-insensitive, name.
-
virtual void SetFloat(const char *name, float val) override¶
Set a float with the given, case-insensitive, name.
-
virtual bool HasInt(const char *name) const override¶
Return true if the keyframer has an integer or true/false value with the given, case-insensitive, name; return false otherwise.
These are the properties the SkyKeyframer has:
CustomSkyColours
AutoMie
numColourAltitudes
numColourElevations
numColourDistances
AutomaticSunPosition
-
virtual int GetInt(const char *name, const base::Variant *params = NULL) const override¶
Get an int with the given, case-insensitive, name.
-
virtual int GetDefaultInt(const char *name) const override¶
Return the default int value with the given, case-insensitive, name.
-
virtual void SetInt(const char *name, int val) override¶
Set an int with the given, case-insensitive, name.
-
virtual void Set(const char *name, const base::Variant *params) override¶
Set a value with the given enum.
-
virtual void SortKeyframes() override¶
Make sure the keyframes are in ascending order of time.
-
virtual vec3 GetLocalDirectionToLight(float alt_km) const override¶
Get the direction to the current strongest light source - could be the sun or the moon.
-
virtual vec3 GetLocalDirectionToSun() const override
Get the current direction to the sun.
-
virtual vec3 GetLocalDirectionToSun(double time, double latitudeRadians, double longitudeRadians, double headingRadians) const override
Get the direction to the Sun at the given time.
-
virtual vec3 GetLocalDirectionToMoon(uid u = 0) const override
Get the current direction to the Moon.
-
virtual vec3 GetLocalDirectionToMoon(uid u, double time, double latitudeRadians, double longitudeRadians, double headingRadians) const override
Get the direction to the Moon at the given time.
-
vec3 GetEquatorialDirectionToLight(double t, float alt_km) const¶
Direction in Earth-centred equatorial co-ordinates, where Z=Earth’s North axis, X is 90 deg East and Y is 180 degrees.
-
virtual vec4 GetLocalIrradiance(float altitude_km) const override¶
Get the sunlight that reaches the altitude altitude_km.
-
virtual vec3 GetLocalSunIrradiance(double t, float altitude_km) const override
Get the sunlight that reaches the altitude altitude_km.
-
virtual vec4 GetMieRayleighRatio() const override¶
Get the ratio of Mie to Rayleigh scattering at unit air and haze density. A useful helper function as some shaders use this ratio.
-
virtual vec3 GetSunlightTableTransformKm() const override¶
Get the transform vector to convert an altitude in km into a 1D texture coordinate for the sunlight table. x = multiplier, y=offset, so texcoord u=t.x*zkm+t.y;.
-
virtual vec4 GetInscatterAngularMultiplier(float cosine, float mie_factor, float alt_km = 0) const override¶
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) override¶
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) override¶
Get the haze that will produce the required visibility distance in the horizontal direction.
-
virtual void Update(double latitudeRadians, double longitudeRadians, double headingRadians)¶
Per-frame update call, this function updates the interpolation and the tables.
-
virtual EarthShadow GetEarthShadow(float h_km, const vec3 &lightDir) const override¶
The Earth’s shadow, as seen from the given altitude.
-
float GetAltitudeTexCoord(float h_km) const¶
Returns the texture coordinate for the given altitude - constant per-frame.
-
void SetUniformKeyframes(int Steps, float range = 1.f)¶
Create a number of evenly spaced keyframes.
-
virtual const LightingState &GetLightingState() const override¶
Get the per-frame cached lighting state.
-
virtual BaseKeyframe *InsertKeyframe(float t, bool insertFromFile = false) override
Insert a keyframe at the given time and return a pointer to it.
-
void DeleteKeyframe(int i)
Delete a skykeyframe with the given ID.
-
SkyKeyframe *GetNextModifiableKeyframe()¶
The next keyframe not partially built or being used. This keyframe’s properties can be modified without any pause or rebuild.
-
SkyKeyframe *GetInterpolatedKeyframe()¶
Get the current interpolated keyframe, which holds the values interpolated from the two surrounding keyframes at any given time.
-
virtual BaseKeyframe *GetKeyframe(int index) override
Get a pointer to the i’th keyframe.
-
virtual const BaseKeyframe *GetKeyframe(int i) const override
Get a pointer to the i’th keyframe.
-
virtual void Save(Output &os) const override¶
Stream/save to the std::osteam os.
-
virtual void Load(Input &is) override¶
Stream/load from the std::isteam is.
-
virtual void SaveToText(platform::crossplatform::TextOutput &output, bool include_keyframes) const override¶
Save this keyframer’s values to textual output.
-
virtual void LoadFromText(platform::crossplatform::TextInput &input) override¶
Load from a textual input.
-
void GetGpuSkyParameters(GpuSkyParameters &p, GpuSkyAtmosphereParameters &a, GpuSkyInfraredParameters &ir, int index)¶
Get the GPU sky parameters corresponding to the given subdivision triplet index, and factor in eclipses and brightness power modifiers.
-
void GetGpuSkyParameters(GpuSkyParameters &p, GpuSkyAtmosphereParameters &a, GpuSkyInfraredParameters &ir, const SkyKeyframe *K, float complete, int index = 2)¶
Get the GPU sky parameters corresponding to the given keyframe at the stated time.
-
virtual unsigned int GetSubdivisionChecksum() const override¶
This is a checksum that only changes if an in-use subdivision has modified (cycling does not change it).
-
void GetStartDate(int &y, int &m, int &d) const¶