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. BaseSkyRenderer and BaseAtmosphericsRenderer. 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 SetStartDate(int y, int m, int d)¶
Set the date for time=0.
-
virtual float GetHorizonElevation(float h_km) const override¶
The elevation of the horizon at this altitude.
-
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:
LatitudeRadians
LongitudeRadians
LatitudeDegrees
LongitudeDegrees
MaxStarMagnitude
MinimumStarPixelSize
MaxDistanceKm
MaxAltitudeKm
atmosphereThicknessKm
planetRadiusKm
MaxSunRadiance
BrightnessPower
OzoneStrength
Emissivity
MoonAlbedo
TimezoneHours
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:
StoreAsColours
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 const float &GetTime() const override¶
Get the current UTC time, in days relative to the start of the start date.
-
virtual void SetTime(const float &d) override¶
Set the current UTC time, in days relative to the start of the start date.
-
virtual vec3 GetDirectionToLight(float alt_km) const override¶
Get the direction to the current strongest light source - could be the sun or the moon.
-
virtual vec3 GetDirectionToLight(double time, float alt_km) const override¶
Get the direction to the current strongest light source - could be the sun or the moon.
-
virtual vec3 GetDirectionToSun() const override¶
Get the current direction to the sun.
-
virtual vec3 GetDirectionToSun(double time) const override¶
Get the direction to the Sun at the given time.
-
virtual vec3 GetDirectionToMoon(uid u, double time) const override¶
Get the direction to the Moon at the given time.
-
vec3 GetGeocentricDirectionToMoon(uid u) const¶
Direction in Earth-centred equatorial co-ordinates, where Z=Earth’s North axis, X is 90 deg East and Y is 180 degrees.
-
vec3 GetDirectionToSun(int keyframe) const¶
Get the direction the sun represented as a vector.
-
virtual float4 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 float4 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 float4 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()¶
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.
-
inline virtual const LightingState &GetLightingState() const override¶
Get the per-frame cached lighting state.
-
virtual float GetTemperatureKelvins(float h_km) const override¶
Return the temperature at the stated altitude in kelvins (subtract 273.15 to get celsius).
-
virtual BaseKeyframe *InsertKeyframe(float t) 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.
-
inline SkyKeyframe *GetInterpolatedKeyframe()¶
Get the current interpolated keyframe, which holds the values interpolated from the two surrounding keyframes at any given time.
-
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(crossplatform::TextOutput &output, bool include_keyframes) const override¶
Save this keyframer’s values to textual output.
-
virtual void LoadFromText(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 daytime, float complete)¶
Get the GPU sky parameters corresponding to the given keyframe at the stated 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 unsigned GetSubdivisionChecksum() const override¶
This is a checksum that only changes if an in-use subdivision has modified (cycling does not change it).
Public Static Functions
-
static void DaytimeToClockTime(float &t, int &d, int &h, int &m, int &s, int &ms)¶
Convert a floating-point daytime into hour, minute, second and milliseconds.
-
void GetStartDate(int &y, int &m, int &d) const¶