Stellarium  1.0
Public Slots | Signals | Public Member Functions | Properties
StelToneReproducer Class Reference

Converts tones in function of the eye adaptation to luminance. More...

#include <StelToneReproducer.hpp>

Public Slots

void setDisplayAdaptationLuminance (float Lda)
 Set the eye adaptation luminance for the display (and precompute what can be) Usual luminance range is 1-100 cd/m^2 for a CRT screen. More...
 
float getDisplayAdaptationLuminance () const
 
void setWorldAdaptationLuminance (float worldAdaptationLuminance)
 Set the eye adaptation luminance for the world (and precompute what can be) More...
 
float getWorldAdaptationLuminance () const
 Get the eye adaptation luminance for the world.
 
void setInputScale (float scale=1.f)
 Set the global scale applied to input luminances, i.e before the adaptation It is the parameter to modify to simulate aperture*exposition time. More...
 
float getInputScale () const
 Get the global scale applied to input luminances, i.e before the adaptation.
 
void setMaxDisplayLuminance (float maxdL)
 Set the maximum luminance of the display (CRT, screen etc..) This value is used to scale the RGB range. More...
 
float getMaxDisplayLuminance () const
 Get the previously set maximum luminance of the display (CRT, screen etc..) This value is used to scale the RGB range. More...
 
float getDisplayGamma () const
 Get the display gamma. More...
 
void setDisplayGamma (float gamma)
 Set the display gamma. More...
 
bool getFlagUseTmGamma () const
 
void setFlagUseTmGamma (bool b)
 
void setFlagSRGB (bool val)
 Set whether to use an sRGB (default, true) or AdobeRGB color conversion matrix for the sky colors. More...
 
bool getFlagSRGB () const
 

Signals

void worldAdaptationLuminanceChanged (double)
 
void displayAdaptationLuminanceChanged (double)
 
void maxDisplayLuminanceChanged (double)
 
void inputScaleChanged (double)
 
void displayGammaChanged (double)
 
void flagUseTmGammaChanged (bool)
 
void flagSRGBChanged (bool val)
 

Public Member Functions

 StelToneReproducer ()
 Constructor.
 
virtual ~StelToneReproducer () Q_DECL_OVERRIDE
 Desctructor.
 
float adaptLuminance (float worldLuminance) const
 Return adapted luminance from world to display. More...
 
float reverseAdaptLuminance (float displayLuminance) const
 Return adapted luminance from display to world. More...
 
float adaptLuminanceScaled (float worldLuminance) const
 Return adapted luminance from world to display with 1 corresponding to full display white. More...
 
float reverseAdaptLuminanceScaled (float displayLuminance) const
 Return adapted luminance from display to world with 1 corresponding to full display white. More...
 
float adaptLuminanceScaledLn (float lnWorldLuminance, float pFact=0.5f) const
 Return adapted ln(luminance) from world to display with 1 corresponding to full display white. More...
 
void xyYToRGB (float *xyY) const
 Convert from xyY color system to RGB. More...
 
void getShadersParams (float &a, float &b, float &c, float &d, bool &useGamma, bool &sRGB) const
 

Properties

double worldAdaptationLuminance
 
double displayAdaptationLuminance
 
double maxDisplayLuminance
 
double inputScale
 
double displayGamma
 
bool flagUseTmGamma
 
bool flagSRGB
 

Detailed Description

The aim is to get on the screen something which is perceptualy accurate, ie. to compress high dynamic range luminance to CRT display range. The class perform mainly a fast implementation of the algorithm from the paper [1], with more accurate values from [2]. The blue shift formula is taken from [3] and combined with the Scotopic vision formula from [4].

Important : you may call setDisplayAdaptationLuminance() and setWorldAdaptationLuminance() before any call to xyYToRGB() or adaptLuminance otherwise the default values will be used. (they are appropriate for a daylight sky luminance)

The user can configure properties of the screen and environmant in the TonemappingDialog: displayAdaptationLuminance, maxDisplayLuminance and displayGamma. The latter is not fixed to the sRGB value of 2.2 but should probably also not deviate too much.

REFERENCES : Thanks to all the authors of the following papers I used for providing their work freely online.

[1] "Tone Reproduction for Realistic Images", Tumblin and Rushmeier, IEEE Computer Graphics & Application, November 1993

[2] "Tone Reproduction and Physically Based Spectral Rendering", Devlin, Chalmers, Wilkie and Purgathofer in EUROGRAPHICS 2002

[3] "Night Rendering", H. Wann Jensen, S. Premoze, P. Shirley, W.B. Thompson, J.A. Ferwerda, M.M. Stark

[4] "A Visibility Matching Tone Reproduction Operator for High Dynamic Range Scenes", G.W. Larson, H. Rushmeier, C. Piatko

Member Function Documentation

◆ adaptLuminance()

float StelToneReproducer::adaptLuminance ( float  worldLuminance) const
inline
Parameters
worldLuminancethe world luminance to convert in cd/m^2
Returns
the converted display luminance in cd/m^2

◆ adaptLuminanceScaled()

float StelToneReproducer::adaptLuminanceScaled ( float  worldLuminance) const
inline
Parameters
worldLuminancethe world luminance to convert in cd/m^2
Returns
the converted display luminance with 1 corresponding to full display white. The value can be more than 1 when saturated.

◆ adaptLuminanceScaledLn()

float StelToneReproducer::adaptLuminanceScaledLn ( float  lnWorldLuminance,
float  pFact = 0.5f 
) const
inline
Parameters
lnWorldLuminancethe world luminance to convert in ln(cd/m^2)
pFactthe power at which the result should be set. The default is 0.5 and therefore return the square root of the adapted luminance
Returns
the converted display set at the pFact power. Luminance with 1 corresponding to full display white. The value can be more than 1 when saturated.

◆ getDisplayGamma

float StelToneReproducer::getDisplayGamma ( ) const
inlineslot
Returns
the display gamma. Default value is 2.2222 for a CRT, and sRGB LCD (and similar modern) panels try to reproduce that.

◆ getMaxDisplayLuminance

float StelToneReproducer::getMaxDisplayLuminance ( ) const
inlineslot
Returns
the maximum display lumiance in cd/m^2. Typical default values for CRT is 120 cd/m^2, LCD panels often have more, which may have been adjusted previously by setMaxDisplayLuminance().

◆ reverseAdaptLuminance()

float StelToneReproducer::reverseAdaptLuminance ( float  displayLuminance) const
inline
Parameters
displayLuminancethe display luminance to convert in cd/m^2
Returns
the converted world luminance in cd/m^2

◆ reverseAdaptLuminanceScaled()

float StelToneReproducer::reverseAdaptLuminanceScaled ( float  displayLuminance) const
inline
Parameters
displayLuminancethe display luminance with 1 corresponding to full display white. The value can be more than 1 when saturated.
Returns
the converted world luminance in cd/m^2

◆ setDisplayAdaptationLuminance

void StelToneReproducer::setDisplayAdaptationLuminance ( float  Lda)
slot
Parameters
displayAdaptationLuminancethe new display luminance in cd/m^2. The initial default value is 50 cd/m^2

◆ setDisplayGamma

void StelToneReproducer::setDisplayGamma ( float  gamma)
slot
Parameters
gammathe gamma. Initial default value is 2.2222 for a CRT, and sRGB LCD (and similar modern) panels try to reproduce that.

◆ setFlagSRGB

void StelToneReproducer::setFlagSRGB ( bool  val)
slot

The actual matrix is in the xyYtoRGB.glsl shader program.

◆ setInputScale

void StelToneReproducer::setInputScale ( float  scale = 1.f)
slot
Parameters
scalethe global input scale

◆ setMaxDisplayLuminance

void StelToneReproducer::setMaxDisplayLuminance ( float  maxdL)
slot
Parameters
maxdLthe maximum luminance in cd/m^2. Initial default value is 100 cd/m^2. Higher values indicate "This display can faithfully reproduce brighter lights, therefore the sky will usually appear darker".

◆ setWorldAdaptationLuminance

void StelToneReproducer::setWorldAdaptationLuminance ( float  worldAdaptationLuminance)
slot
Parameters
worldAdaptationLuminancethe new world luminance in cd/m^2. The initial default value is 40000 cd/m^2 for Skylight Star Light : 0.001 cd/m^2 Moon Light : 0.1 cd/m^2 Indoor Lighting : 100 cd/m^2 Sun Light : 100000 cd/m^2

◆ xyYToRGB()

void StelToneReproducer::xyYToRGB ( float *  xyY) const

The first two components x and y indicate the "color", the Y is luminance in cd/m^2.

Parameters
xyYan array of 3 floats which are replaced by the converted RGB values