version 3.3

EnvironmentRenderer::SkyDome Class Reference

Usage: the sky must be rendered as first shape per frame, otherwise it may overwrite anything rendered before. More...

#include <vrs/environment/skydome.h>

Inheritance diagram for EnvironmentRenderer::SkyDome:

VRS::Shape VRS::RenderObj VRS::SharedObj VRS::Visitable

List of all members.

Public Member Functions

 SkyDome (const VRS::Vector &sunDir=VRS::Vector(0.0, 1.0, 0.0), const VRS::Color &sunColor=VRS::Color(1.0, 1.0, 1.0), bool perFragment=true)
 'sunDir' is the direction where the sun is seen.
virtual VRS::Bounds boundingBox () const
 the sky's boundingbox is always degenerated to the origin
VRS::Vector getSunDirection () const
 points towards the sun. the vector is normalized and therefor must not be the origin
void setSunDirection (const VRS::Vector &dir)
void setSunDirection (double longitude, double latitude, int year, int month, int day, int hour=12, int minute=0, int second=0)
void addCloudLayer (VRS::SO< CloudLayer > layer)
 adds a cloud layer
CloudLayerremoveCloudLayer (unsigned int index)
 removes a particular cloud layer or the cloud layer at the given index.
bool removeCloudLayer (VRS::SO< CloudLayer > layer)
void clearCloudLayers ()
 removes all cloudlayers from the sky
void setRenderClouds (bool yesNo)
 enable/disable rendering of clouds or query rendering-state
bool renderClouds () const
CloudLayergetCloudLayer (unsigned int index) const
 returns a cloud layer at the given index (NULL if the index is greater or equal to the number of layers).
VRS::SO< VRS::Iterator
< VRS::SO< CloudLayer > > > 
getCloudLayers () const
 returns all cloud layers
bool getPerFragment () const
 de-/activate per-fragment calculations for the atmosphere
void setPerFragment (bool perFragment)
VRS::Color getSunLightColor () const
 the color of emitted sunlight.
void setSunLightColor (const VRS::Color &c)
VRS::Color getSunLightColorGroundLevel () const
 when passing through the atmosphere, sunlight undergoes absorbtion and outscattering, which is handled together as extinction.
VRS::Vector getSkyColor (const VRS::Vector &direction) const
 calculatets the sky's color in the given direction.
double getPlanetRadius () const
 atmospheric parameters of the simulated planet.
void setPlanetRadius (double radius)
double getAtmosphereThickness () const
void setAtmosphereThickness (double thickness)
VRS::VertexData< 2, unsigned int > getAtmosphereDetail () const
 the sky consists of a sphere for the atmosphere with the given AtmosphereDetail and a hemisphere with the given CloudDetail for cloud rendering.
void setAtmosphereDetail (unsigned int slices, unsigned int stacks)
VRS::VertexData< 2, unsigned int > getCloudDetail () const
void setCloudDetail (unsigned int slices, unsigned int stacks)
VRS::VertexData< 3, unsigned int > getWavelengths () const
 the wavelengths affect the way light is scattered by the atmosphere.
void setWavelengths (unsigned int red, unsigned int green, unsigned int blue)
float getRayleighCoefficient () const
 rayleigh scattering coefficient (default: 1/33) rayleigh scattering causes the the inscattering of blue light and outscattering of red and green light at noon and the inscattering of red and green light and outscattering of blue light in the morning and evening respectively.
void setRayleighCoefficient (float coeff)
float getExcentricity () const
 mie scattering parameters
  • excentricity (in [0;1[ ): higher values cause stronger inscattering at small angles around the sun (small sun with fast decay of intensity), small values cause a larger sun with softer color gradients (default: 0.95)
  • mieCoefficient (must be greater or equal to 0): (default: 1e-7)

void setExcentricity (float excentricity)
float getMieCoefficient () const
void setMieCoefficient (float coeff)
float getInscatteringScale () const
 scale to adjust the amout of inscattering, as mere inscattering-results are too dark (default: 20.0)
void setInscatteringScale (float scale)
bool needsUpdateAtmosphere () const
bool needsUpdateClouds () const
 VRS_TYPEINFO (SkyDome, VRS::Shape)
 VRS_SERIALIZABLE (SkyDome)

Static Public Member Functions

static VRS::Vector calculateSunDirection (double longitude, double latitude, int year, int month, int day, int hour=12, int minute=0, int second=0)
 calculate sun direction from geographic coordinates, date and time.
static double calculateAtmosphereThickness (double planetRadius, double atmosphereThickness, const VRS::Vector &direction)
 the value is calculated by determining the distance from the top of the inner sphere (radius: planetRadius) to the point on the outer sphere (radius: planetRadius + atmThickness) which is hit by a ray cast from the first point into the given direction


Detailed Description

Usage: the sky must be rendered as first shape per frame, otherwise it may overwrite anything rendered before.

if you can assure this, simply add a SkyDome to your scene, if not, use the SkyTechnique. The Technique will render the sky in BACKGROUND-pass, so nothing should be overwritten.


Constructor & Destructor Documentation

EnvironmentRenderer::SkyDome::SkyDome ( const VRS::Vector sunDir = VRS::Vector(0.0, 1.0, 0.0),
const VRS::Color sunColor = VRS::Color(1.0, 1.0, 1.0),
bool  perFragment = true 
)

'sunDir' is the direction where the sun is seen.

must not be NULL 'sunlightColor' is the color of the sun's emitted light. e.g. this could be used to simulate a red gigant 'perFragment' enables per-fragment calculation for the atmospheric scattering. per-fragment-calculatios just needs a low tesselated sky-sphere to even create better results than a highly tesselated per-vertex-sky. however, as the scattering-equations are evaluated per fragment, this will decrease performance.


Member Function Documentation

virtual VRS::Bounds EnvironmentRenderer::SkyDome::boundingBox (  )  const [virtual]

the sky's boundingbox is always degenerated to the origin

Implements VRS::Shape.

VRS::Vector EnvironmentRenderer::SkyDome::getSunDirection (  )  const

points towards the sun. the vector is normalized and therefor must not be the origin

void EnvironmentRenderer::SkyDome::setSunDirection ( const VRS::Vector dir  ) 

static VRS::Vector EnvironmentRenderer::SkyDome::calculateSunDirection ( double  longitude,
double  latitude,
int  year,
int  month,
int  day,
int  hour = 12,
int  minute = 0,
int  second = 0 
) [static]

calculate sun direction from geographic coordinates, date and time.

'longitude': positive if east of Greenwich, negative if west of Greenwich 'latitude': positive if north of equator, negative if south of equator the date must be given in coordinated universal time (UTC) (aka Greenwich Mean Time, GMT) which can be calculated from your local time by subtracting your time zone's offset from UTC (in hours, for CET it is UTC+1). Subtract another hour, if daylight saving time is in effect (UTC+2 for CEST).

void EnvironmentRenderer::SkyDome::setSunDirection ( double  longitude,
double  latitude,
int  year,
int  month,
int  day,
int  hour = 12,
int  minute = 0,
int  second = 0 
)

void EnvironmentRenderer::SkyDome::addCloudLayer ( VRS::SO< CloudLayer layer  ) 

adds a cloud layer

CloudLayer* EnvironmentRenderer::SkyDome::removeCloudLayer ( unsigned int  index  ) 

removes a particular cloud layer or the cloud layer at the given index.

the index-version returns the cloud layer that was removed or NULL, if the index was larger or equal to the number of cloud layers. the second version returns true, if the layer could be removed

bool EnvironmentRenderer::SkyDome::removeCloudLayer ( VRS::SO< CloudLayer layer  ) 

void EnvironmentRenderer::SkyDome::clearCloudLayers (  ) 

removes all cloudlayers from the sky

void EnvironmentRenderer::SkyDome::setRenderClouds ( bool  yesNo  ) 

enable/disable rendering of clouds or query rendering-state

bool EnvironmentRenderer::SkyDome::renderClouds (  )  const

CloudLayer* EnvironmentRenderer::SkyDome::getCloudLayer ( unsigned int  index  )  const

returns a cloud layer at the given index (NULL if the index is greater or equal to the number of layers).

VRS::SO<VRS::Iterator<VRS::SO<CloudLayer> > > EnvironmentRenderer::SkyDome::getCloudLayers (  )  const

returns all cloud layers

bool EnvironmentRenderer::SkyDome::getPerFragment (  )  const

de-/activate per-fragment calculations for the atmosphere

void EnvironmentRenderer::SkyDome::setPerFragment ( bool  perFragment  ) 

VRS::Color EnvironmentRenderer::SkyDome::getSunLightColor (  )  const

the color of emitted sunlight.

for our sun, it is (almost) white (1, 1, 1). The sun's yellow tint mainly comes from stronger extinction of short-wavelength-light (blue). Change the default (white) if you want to simulate a red giant e.g.

void EnvironmentRenderer::SkyDome::setSunLightColor ( const VRS::Color c  ) 

VRS::Color EnvironmentRenderer::SkyDome::getSunLightColorGroundLevel (  )  const

when passing through the atmosphere, sunlight undergoes absorbtion and outscattering, which is handled together as extinction.

The ground-level color can be used for lighting the terrain.

VRS::Vector EnvironmentRenderer::SkyDome::getSkyColor ( const VRS::Vector direction  )  const

calculatets the sky's color in the given direction.

to change the appearance (sun direction, etc. change the SkyDome-values)

double EnvironmentRenderer::SkyDome::getPlanetRadius (  )  const

atmospheric parameters of the simulated planet.

atmospheric scattering depends on the 'amount' of air the sunlight travels through, until it reaches the eye. the amount is the integral of the atmosphere's density along the travelled path. actually, the required calculations are very complex and not real-time-capable. so we make the following assumption: the continuous atmosphere is fit into a sphere with constant density (and the radius 'planetRadius + atmThickness') values are meant to be entered in kilometers (assuming 1 unit in world-space is equivalent to 1 meter). the initial value for radius is 6366 and 15 for thickness

void EnvironmentRenderer::SkyDome::setPlanetRadius ( double  radius  ) 

double EnvironmentRenderer::SkyDome::getAtmosphereThickness (  )  const

void EnvironmentRenderer::SkyDome::setAtmosphereThickness ( double  thickness  ) 

VRS::VertexData<2, unsigned int> EnvironmentRenderer::SkyDome::getAtmosphereDetail (  )  const

the sky consists of a sphere for the atmosphere with the given AtmosphereDetail and a hemisphere with the given CloudDetail for cloud rendering.

void EnvironmentRenderer::SkyDome::setAtmosphereDetail ( unsigned int  slices,
unsigned int  stacks 
)

VRS::VertexData<2, unsigned int> EnvironmentRenderer::SkyDome::getCloudDetail (  )  const

void EnvironmentRenderer::SkyDome::setCloudDetail ( unsigned int  slices,
unsigned int  stacks 
)

VRS::VertexData<3, unsigned int> EnvironmentRenderer::SkyDome::getWavelengths (  )  const

the wavelengths affect the way light is scattered by the atmosphere.

the initial values are 650nm, 600nm and 470nm for red, green and blue. these values were chosen because they result in a realistic blue sky at noon. feel free to experiment with these values. increasing the value will cause a stronger outscattering (i.e. darkening) of the particular color at noon and stronger inscattering (i.e. brightening) at sunrise/sunset.

void EnvironmentRenderer::SkyDome::setWavelengths ( unsigned int  red,
unsigned int  green,
unsigned int  blue 
)

float EnvironmentRenderer::SkyDome::getRayleighCoefficient (  )  const

rayleigh scattering coefficient (default: 1/33) rayleigh scattering causes the the inscattering of blue light and outscattering of red and green light at noon and the inscattering of red and green light and outscattering of blue light in the morning and evening respectively.

void EnvironmentRenderer::SkyDome::setRayleighCoefficient ( float  coeff  ) 

float EnvironmentRenderer::SkyDome::getExcentricity (  )  const

mie scattering parameters

  • excentricity (in [0;1[ ): higher values cause stronger inscattering at small angles around the sun (small sun with fast decay of intensity), small values cause a larger sun with softer color gradients (default: 0.95)
  • mieCoefficient (must be greater or equal to 0): (default: 1e-7)

void EnvironmentRenderer::SkyDome::setExcentricity ( float  excentricity  ) 

float EnvironmentRenderer::SkyDome::getMieCoefficient (  )  const

void EnvironmentRenderer::SkyDome::setMieCoefficient ( float  coeff  ) 

float EnvironmentRenderer::SkyDome::getInscatteringScale (  )  const

scale to adjust the amout of inscattering, as mere inscattering-results are too dark (default: 20.0)

void EnvironmentRenderer::SkyDome::setInscatteringScale ( float  scale  ) 

static double EnvironmentRenderer::SkyDome::calculateAtmosphereThickness ( double  planetRadius,
double  atmosphereThickness,
const VRS::Vector direction 
) [static]

the value is calculated by determining the distance from the top of the inner sphere (radius: planetRadius) to the point on the outer sphere (radius: planetRadius + atmThickness) which is hit by a ray cast from the first point into the given direction

bool EnvironmentRenderer::SkyDome::needsUpdateAtmosphere (  )  const

bool EnvironmentRenderer::SkyDome::needsUpdateClouds (  )  const

EnvironmentRenderer::SkyDome::VRS_TYPEINFO ( SkyDome  ,
VRS::Shape   
)

EnvironmentRenderer::SkyDome::VRS_SERIALIZABLE ( SkyDome   ) 


The documentation for this class was generated from the following file:

Generated on Sun May 19 06:00:31 2013 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact