All working on Ozone land.....

This commit is contained in:
Jonathas Costa
2019-03-25 15:13:06 -04:00
parent a4df107b7d
commit 47b84d297b
5 changed files with 31 additions and 28 deletions
@@ -20,7 +20,7 @@ local Atmosphere = {
Coefficients = {
-- Wavelengths are given in 10^-9m
Wavelengths = { 680, 550, 440 },
-- Reflection coefficients are given in km^-1
-- Coefficients are given in 1/cm
Scattering = { 5.8E-3, 13.5E-3, 33.1E-3 },
-- In Rayleigh scattering, the coefficients of absorption and scattering are the same.
},
@@ -29,8 +29,9 @@ local Atmosphere = {
},
Ozone = {
Coefficients = {
-- Extinction coefficients
Extinction = {3.426, 8.298, 0.356}
-- Absorption coefficients (in 1/cm)
--Extinction = {2.44E-4, 5.91E-4, 24.25E-4}
Extinction = {2.055E-3, 4.979E-3, 0.2136E-3}
},
H_O = 8.0,
},
@@ -237,9 +237,9 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
, _rayleighScatteringCoeffZP(RayleighScatteringCoeffZInfo, 1.0f, 0.01f, 100.0f)
, _ozoneEnabledP(OzoneLayerInfo, true)
, _ozoneHeightScaleP(OzoneHeightScaleInfo, 8.0f, 0.1f, 20.0f)
, _ozoneCoeffXP(OzoneLayerCoeffXInfo, 3.426f, 0.01f, 100.0f)
, _ozoneCoeffYP(OzoneLayerCoeffYInfo, 8.298f, 0.01f, 100.0f)
, _ozoneCoeffZP(OzoneLayerCoeffZInfo, 0.356f, 0.01f, 100.0f)
, _ozoneCoeffXP(OzoneLayerCoeffXInfo, 2.44f, 0.01f, 100.0f)
, _ozoneCoeffYP(OzoneLayerCoeffYInfo, 5.91f, 0.01f, 100.0f)
, _ozoneCoeffZP(OzoneLayerCoeffZInfo, 24.25f, 0.01f, 100.0f)
, _mieHeightScaleP(MieHeightScaleInfo, 1.2f, 0.1f, 20.0f)
, _mieScatteringCoeffXP(MieScatteringCoeffXInfo, 4.0f, 0.01f, 1000.0f)
, _mieScatteringCoeffYP(MieScatteringCoeffYInfo, 4.0f, 0.01f, 1000.0f)
@@ -579,6 +579,8 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_rayleighHeightScaleP.onChange(updateAtmosphere);
addProperty(_rayleighHeightScaleP);
// We multiply the scattering coefficients by 1000.0 to have a good
// display value in the GUI.
_rayleighScatteringCoeffXP = _rayleighScatteringCoeff.x * 1000.0f;
_rayleighScatteringCoeffXP.onChange(updateAtmosphere);
addProperty(_rayleighScatteringCoeffXP);
@@ -599,16 +601,17 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_ozoneHeightScaleP.onChange(updateAtmosphere);
addProperty(_ozoneHeightScaleP);
_ozoneCoeffXP = _ozoneExtinctionCoeff.x;
// We multiply the absorption coefficients by 1000.0 to have a good
// display value in the GUI.
_ozoneCoeffXP = _ozoneExtinctionCoeff.x * 1000.0f;
_ozoneCoeffXP.onChange(updateAtmosphere);
addProperty(_ozoneCoeffXP);
_ozoneCoeffYP = _ozoneExtinctionCoeff.y;
_ozoneCoeffYP = _ozoneExtinctionCoeff.y * 1000.0f;
_ozoneCoeffYP.onChange(updateAtmosphere);
addProperty(_ozoneCoeffYP);
_ozoneCoeffZP = _ozoneExtinctionCoeff.z;
_ozoneCoeffZP = _ozoneExtinctionCoeff.z * 1000.0f;
_ozoneCoeffZP.onChange(updateAtmosphere);
addProperty(_ozoneCoeffZP);
@@ -616,6 +619,8 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_mieHeightScaleP.onChange(updateAtmosphere);
addProperty(_mieHeightScaleP);
// We multiply the scattering coefficients by 1000.0 to have a good
// display value in the GUI.
_mieScatteringCoeffXP = _mieScatteringCoeff.x * 1000.0f;
_mieScatteringCoeffXP.onChange(updateAtmosphere);
addProperty(_mieScatteringCoeffXP);
@@ -650,6 +655,8 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
if (_shadowEnabled) {
addProperty(_hardShadowsEnabledP);
}
updateAtmosphereParameters();
}
}
}
@@ -759,9 +766,9 @@ void RenderableAtmosphere::updateAtmosphereParameters() {
);
_ozoneLayerEnabled = _ozoneEnabledP;
_ozoneHeightScale = _ozoneHeightScaleP;
_ozoneExtinctionCoeff = glm::vec3(_ozoneCoeffXP.value() * 0.00001f,
_ozoneCoeffYP.value() * 0.00001f,
_ozoneCoeffZP.value() * 0.00001f);
_ozoneExtinctionCoeff = glm::vec3(_ozoneCoeffXP.value() * 0.001f,
_ozoneCoeffYP.value() * 0.001f,
_ozoneCoeffZP.value() * 0.001f);
_mieHeightScale = _mieHeightScaleP;
_mieScatteringCoeff = glm::vec3(
@@ -65,7 +65,7 @@ uniform float AverageGroundReflectance;
uniform float groundRadianceEmittion;
uniform float HR;
uniform vec3 betaRayleigh;
uniform float HO;
//uniform float HO;
uniform vec3 betaOzoneExtinction;
uniform float HM;
uniform vec3 betaMieScattering;
@@ -122,9 +122,10 @@ float opticalDepth(const float localH, const float r, const float mu, const floa
vec3 analyticTransmittance(const float r, const float mu, const float d) {
if (ozoneLayerEnabled) {
return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) -
betaOzoneExtinction * opticalDepth(HO, r, mu, d) -
betaMieExtinction * opticalDepth(HM, r, mu, d));
return exp(
-(betaRayleigh + betaOzoneExtinction) * opticalDepth(HR, r, mu, d) -
betaMieExtinction * opticalDepth(HM, r, mu, d)
);
} else {
return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) -
betaMieExtinction * opticalDepth(HM, r, mu, d));
@@ -65,13 +65,8 @@ void integrand(const float r, const float mu, const float muSun, const float nu,
// at x (r) to y (ri).
vec3 transmittanceY = transmittance(r, mu, y) * transmittanceLUT(ri, muSun_i);
// exp(-h/H)*T(x,v)
if (ozoneLayerEnabled) {
S_R = (exp(-(ri - Rg) / HO) + exp( -(ri - Rg) / HR )) * transmittanceY;
S_M = exp( -(ri - Rg) / HM ) * transmittanceY;
} else {
S_R = exp( -(ri - Rg) / HR ) * transmittanceY;
S_M = exp( -(ri - Rg) / HM ) * transmittanceY;
}
S_R = exp( -(ri - Rg) / HR ) * transmittanceY;
S_M = exp( -(ri - Rg) / HM ) * transmittanceY;
// The L0 (sun radiance) is added in real-time.
}
}
@@ -79,12 +79,11 @@ void main(void) {
vec3 opDepth = vec3(0.0);
if (ozoneLayerEnabled) {
opDepth = (betaOzoneExtinction * opticalDepth(r, muSun, HO)) +
(betaMieExtinction * opticalDepth(r, muSun, HM)) +
(betaRayleigh * opticalDepth(r, muSun, HR));
opDepth = (betaMieExtinction * opticalDepth(r, muSun, HM)) +
((betaRayleigh + betaOzoneExtinction) * opticalDepth(r, muSun, HR));
} else {
opDepth = betaMieExtinction * opticalDepth(r, muSun, HM) +
betaRayleigh * opticalDepth(r, muSun, HR);
betaRayleigh * opticalDepth(r, muSun, HR);
}
renderTableColor = vec4( exp( -opDepth ), 1.0f );