00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _STELTONEREPRODUCER_HPP_
00020 #define _STELTONEREPRODUCER_HPP_
00021
00049 class StelToneReproducer
00050 {
00051 public:
00053 StelToneReproducer();
00054
00056 virtual ~StelToneReproducer();
00057
00061 void setDisplayAdaptationLuminance(float displayAdaptationLuminance);
00062
00069 void setWorldAdaptationLuminance(float worldAdaptationLuminance);
00071 float getWorldAdaptationLuminance() const {return Lwa;}
00072
00076 void setInputScale(float scale=1.f);
00078 float getInputScale() const {return inputScale;}
00079
00083 void setMaxDisplayLuminance(float maxdL)
00084 {oneOverMaxdL = 1.f/maxdL; lnOneOverMaxdL=std::log(oneOverMaxdL); term2TimesOneOverMaxdLpOneOverGamma = std::pow(term2*oneOverMaxdL, oneOverGamma);}
00085
00088 float getDisplayGamma() const {return 1.f/oneOverGamma;}
00089
00092 void setDisplayGamma(float gamma)
00093 {oneOverGamma = 1.f/gamma; term2TimesOneOverMaxdLpOneOverGamma = std::pow(term2*oneOverMaxdL, oneOverGamma);}
00094
00098 float adaptLuminance(float worldLuminance) const
00099 {
00100 return std::pow((float)(inputScale*worldLuminance*M_PI*0.0001f),alphaWaOverAlphaDa) * term2;
00101 }
00102
00106 float reverseAdaptLuminance(float displayLuminance) const
00107 {
00108 return std::pow((float)(displayLuminance/term2),1.f/alphaWaOverAlphaDa)/(inputScale*M_PI*0.0001f);
00109 }
00110
00114 float adaptLuminanceScaled(float worldLuminance) const
00115 {
00116 return adaptLuminance(worldLuminance)*oneOverMaxdL;
00117 }
00118
00122 float reverseAdaptLuminanceScaled(float displayLuminance) const
00123 {
00124 return reverseAdaptLuminance(displayLuminance/oneOverMaxdL);
00125 }
00126
00131 float adaptLuminanceScaledLn(float lnWorldLuminance, float pFact=0.5f) const
00132 {
00133 const float lnPix0p0001 = -8.0656104861f;
00134 return std::exp(((lnInputScale+lnWorldLuminance+lnPix0p0001)*alphaWaOverAlphaDa+lnTerm2+lnOneOverMaxdL)*pFact);
00135 }
00136
00140 void xyYToRGB(float* xyY) const;
00141
00142 void getShadersParams(float& a, float& b, float & c) const
00143 {
00144 a=alphaWaOverAlphaDa;
00145 b=oneOverGamma;
00146 c=term2TimesOneOverMaxdLpOneOverGamma;
00147 }
00148 private:
00149
00150 float inputScale;
00151 float lnInputScale;
00152
00153 float Lda;
00154 float Lwa;
00155 float oneOverMaxdL;
00156 float lnOneOverMaxdL;
00157 float oneOverGamma;
00158
00159
00160 float alphaDa;
00161 float betaDa;
00162 float alphaWa;
00163 float betaWa;
00164 float alphaWaOverAlphaDa;
00165 float term2;
00166 float lnTerm2;
00167
00168 float term2TimesOneOverMaxdLpOneOverGamma;
00169 };
00170
00171 #endif // _STELTONEREPRODUCER_HPP_
00172