summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-14 00:11:19 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-14 00:11:19 +0100
commit79e4a8c28ad29b028ddb907a6ea01f4ef71e822a (patch)
tree5addab6a1cad0d8545d5fbe6cfb3907c264591a3
parent057dda6afe59791f4a6fcf4c5ca8387b8aeda6a8 (diff)
Fix up atmospheric helpers and transport shader for adv atmo path.
Basic hook-up of sky settings to llatmosphere model. Moved mie aniso to be a top-level setting instead of a per-mie-layer setting.
-rw-r--r--indra/llinventory/llsettingsbase.cpp6
-rw-r--r--indra/llinventory/llsettingssky.cpp52
-rw-r--r--indra/llinventory/llsettingssky.h43
-rw-r--r--indra/llrender/llatmosphere.cpp505
-rw-r--r--indra/llrender/llatmosphere.h48
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl62
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/skyF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/transportF.glsl25
-rw-r--r--indra/newview/llenvironment.cpp59
-rw-r--r--indra/newview/llenvironment.h3
-rw-r--r--indra/newview/llviewershadermgr.cpp2
12 files changed, 523 insertions, 292 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index abe1a1a04a..b763a06ab4 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -207,6 +207,11 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
LLQuaternion q = slerp(mix, LLQuaternion(value), LLQuaternion(other_value));
newvalue = q.getValue();
}
+ else if (value[0].type() == LLSD::TypeMap)
+ {
+ // TODO
+ // determine if lerping between maps is both feasible and reasonable
+ }
else
{ // TODO: We could expand this to inspect the type and do a deep lerp based on type.
// for now assume a heterogeneous array of reals.
@@ -214,7 +219,6 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
for (size_t i = 0; i < len; ++i)
{
-
newvalue[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix);
}
}
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 37da95b95e..491381213f 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -200,10 +200,7 @@ LLSettingsSky::validation_list_t mieValidationList()
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f)))));
mieValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM, true, LLSD::TypeReal,
- boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
-
- mieValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR, true, LLSD::TypeReal,
- boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
}
return mieValidation;
}
@@ -511,6 +508,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
validation.push_back(Validator(SETTING_SUN_ARC_RADIANS, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.1f)))));
+ validation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR, true, LLSD::TypeReal,
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
+
validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers));
validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers));
validation.push_back(Validator(SETTING_MIE_CONFIG, true, LLSD::TypeArray, &validateMieLayers));
@@ -522,11 +522,13 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
LLSD LLSettingsSky::rayleighConfigDefault()
{
LLSD dflt_rayleigh;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
- dflt_rayleigh[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ LLSD dflt_rayleigh_layer;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ dflt_rayleigh.append(dflt_rayleigh_layer);
return dflt_rayleigh;
}
@@ -556,12 +558,13 @@ LLSD LLSettingsSky::absorptionConfigDefault()
LLSD LLSettingsSky::mieConfigDefault()
{
LLSD dflt_mie;
- dflt_mie[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
- dflt_mie[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
- dflt_mie[SETTING_MIE_ANISOTROPY_FACTOR] = 0.9f;
+ LLSD dflt_mie_layer;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ dflt_mie.append(dflt_mie_layer);
return dflt_mie;
}
@@ -600,16 +603,15 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_TYPE] = "sky";
// defaults are for earth...
- dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f;
- dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f;
- dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f;
- dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f;
-
- // These are technically capable of handling multiple layers of density config
- // and so are expected to be an array, but we make an array of size 1 w/ each default density config
- dfltsetting[SETTING_RAYLEIGH_CONFIG].append(rayleighConfigDefault());
- dfltsetting[SETTING_MIE_CONFIG].append(mieConfigDefault());
- dfltsetting[SETTING_ABSORPTION_CONFIG].append(absorptionConfigDefault());
+ dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f;
+ dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f;
+ dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f;
+ dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f;
+ dfltsetting[SETTING_MIE_ANISOTROPY_FACTOR] = 0.8f;
+
+ dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault();
+ dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault();
+ dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault();
return dfltsetting;
}
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index 70d7a1c54f..4fb8c101ee 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -66,6 +66,7 @@ public:
static const std::string SETTING_SKY_BOTTOM_RADIUS;
static const std::string SETTING_SKY_TOP_RADIUS;
static const std::string SETTING_SUN_ARC_RADIANS;
+ static const std::string SETTING_MIE_ANISOTROPY_FACTOR;
static const std::string SETTING_RAYLEIGH_CONFIG;
static const std::string SETTING_MIE_CONFIG;
@@ -77,7 +78,7 @@ public:
static const std::string SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR;
static const std::string SETTING_DENSITY_PROFILE_LINEAR_TERM;
static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM;
- static const std::string SETTING_MIE_ANISOTROPY_FACTOR;
+
static const std::string SETTING_LEGACY_HAZE;
@@ -100,6 +101,46 @@ public:
static LLSD defaults();
+ F32 getPlanetRadius() const
+ {
+ return mSettings[SETTING_PLANET_RADIUS].asReal();
+ }
+
+ F32 getSkyBottomRadius() const
+ {
+ return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal();
+ }
+
+ F32 getSkyTopRadius() const
+ {
+ return mSettings[SETTING_SKY_TOP_RADIUS].asReal();
+ }
+
+ F32 getSunArcRadians() const
+ {
+ return mSettings[SETTING_SUN_ARC_RADIANS].asReal();
+ }
+
+ F32 getMieAnisotropy() const
+ {
+ return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal();
+ }
+
+ LLSD getRayleighConfigs() const
+ {
+ return mSettings[SETTING_RAYLEIGH_CONFIG];
+ }
+
+ LLSD getMieConfigs() const
+ {
+ return mSettings[SETTING_MIE_CONFIG];
+ }
+
+ LLSD getAbsorptionConfigs() const
+ {
+ return mSettings[SETTING_ABSORPTION_CONFIG];
+ }
+
LLUUID getBloomTextureId() const
{
return mSettings[SETTING_BLOOM_TEXTUREID].asUUID();
diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp
index 6ce5292839..6a4745eb95 100644
--- a/indra/llrender/llatmosphere.cpp
+++ b/indra/llrender/llatmosphere.cpp
@@ -1,221 +1,292 @@
-/**
- * @file llatmosphere.cpp
- * @brief LLAtmosphere integration impl
- *
- * $LicenseInfo:firstyear=2018&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2018, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llatmosphere.h"
-#include "llfasttimer.h"
-#include "llsys.h"
-#include "llglheaders.h"
-#include "llrender.h"
-#include "llshadermgr.h"
-#include "llglslshader.h"
-
-LLAtmosphere* gAtmosphere = nullptr;
-
-void LLAtmosphere::initClass()
-{
- if (!gAtmosphere)
- {
- gAtmosphere = new LLAtmosphere;
- }
-}
-
-void LLAtmosphere::cleanupClass()
+/**
+ * @file llatmosphere.cpp
+ * @brief LLAtmosphere integration impl
+ *
+ * $LicenseInfo:firstyear=2018&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2018, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "llatmosphere.h"
+#include "llfasttimer.h"
+#include "llsys.h"
+#include "llglheaders.h"
+#include "llrender.h"
+#include "llshadermgr.h"
+#include "llglslshader.h"
+
+LLAtmosphere* gAtmosphere = nullptr;
+
+// Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column
+// (see http://rredc.nrel.gov/solar/spectra/am1.5/ASTMG173/ASTMG173.html),
+// summed and averaged in each bin (e.g. the value for 360nm is the average
+// of the ASTM G-173 values for all wavelengths between 360 and 370nm).
+// Values in W.m^-2.
+const int kLambdaMin = 360;
+const int kLambdaMax = 830;
+const double kSolarIrradiance[48] = {
+ 1.11776, 1.14259, 1.01249, 1.14716, 1.72765, 1.73054, 1.6887, 1.61253,
+ 1.91198, 2.03474, 2.02042, 2.02212, 1.93377, 1.95809, 1.91686, 1.8298,
+ 1.8685, 1.8931, 1.85149, 1.8504, 1.8341, 1.8345, 1.8147, 1.78158, 1.7533,
+ 1.6965, 1.68194, 1.64654, 1.6048, 1.52143, 1.55622, 1.5113, 1.474, 1.4482,
+ 1.41018, 1.36775, 1.34188, 1.31429, 1.28303, 1.26758, 1.2367, 1.2082,
+ 1.18737, 1.14683, 1.12362, 1.1058, 1.07124, 1.04992
+};
+
+// Values from http://www.iup.uni-bremen.de/gruppen/molspec/databases/
+// referencespectra/o3spectra2011/index.html for 233K, summed and averaged in
+// each bin (e.g. the value for 360nm is the average of the original values
+// for all wavelengths between 360 and 370nm). Values in m^2.
+const double kOzoneCrossSection[48] = {
+ 1.18e-27, 2.182e-28, 2.818e-28, 6.636e-28, 1.527e-27, 2.763e-27, 5.52e-27,
+ 8.451e-27, 1.582e-26, 2.316e-26, 3.669e-26, 4.924e-26, 7.752e-26, 9.016e-26,
+ 1.48e-25, 1.602e-25, 2.139e-25, 2.755e-25, 3.091e-25, 3.5e-25, 4.266e-25,
+ 4.672e-25, 4.398e-25, 4.701e-25, 5.019e-25, 4.305e-25, 3.74e-25, 3.215e-25,
+ 2.662e-25, 2.238e-25, 1.852e-25, 1.473e-25, 1.209e-25, 9.423e-26, 7.455e-26,
+ 6.566e-26, 5.105e-26, 4.15e-26, 4.228e-26, 3.237e-26, 2.451e-26, 2.801e-26,
+ 2.534e-26, 1.624e-26, 1.465e-26, 2.078e-26, 1.383e-26, 7.105e-27
+};
+
+// From https://en.wikipedia.org/wiki/Dobson_unit, in molecules.m^-2.
+const double kDobsonUnit = 2.687e20;
+// Maximum number density of ozone molecules, in m^-3 (computed so at to get
+// 300 Dobson units of ozone - for this we divide 300 DU by the integral of
+// the ozone density profile defined below, which is equal to 15km).
+const double kMaxOzoneNumberDensity = 300.0 * kDobsonUnit / 15000.0;
+const double kSunAngularRadius = 0.00935 / 2.0;
+const double kBottomRadius = 6360000.0;
+const double kTopRadius = 6420000.0;
+const double kRayleigh = 1.24062e-6;
+const double kRayleighScaleHeight = 8000.0;
+const double kMieScaleHeight = 1200.0;
+const double kMieAngstromAlpha = 0.0;
+const double kMieAngstromBeta = 5.328e-3;
+const double kMieSingleScatteringAlbedo = 0.9;
+const double kMiePhaseFunctionG = 0.8;
+const double max_sun_zenith_angle = F_PI * 2.0 / 3.0;
+
+AtmosphericModelSettings::AtmosphericModelSettings()
+ : m_skyBottomRadius(6360.0f)
+ , m_skyTopRadius(6420.0f)
+ , m_sunArcRadians(0.00045f)
+ , m_mieAnisotropy(0.8f)
+{
+ atmosphere::DensityProfileLayer rayleigh_density(0.0, 1.0, -1.0 / kRayleighScaleHeight, 0.0, 0.0);
+ atmosphere::DensityProfileLayer mie_density(0.0, 1.0, -1.0 / kMieScaleHeight, 0.0, 0.0);
+
+ m_rayleighProfile.push_back(rayleigh_density);
+ m_mieProfile.push_back(mie_density);
+
+ // Density profile increasing linearly from 0 to 1 between 10 and 25km, and
+ // decreasing linearly from 1 to 0 between 25 and 40km. This is an approximate
+ // profile from http://www.kln.ac.lk/science/Chemistry/Teaching_Resources/
+ // Documents/Introduction%20to%20atmospheric%20chemistry.pdf (page 10).
+ m_absorptionProfile.push_back(atmosphere::DensityProfileLayer(25000.0, 0.0, 0.0, 1.0 / 15000.0, -2.0 / 3.0));
+ m_absorptionProfile.push_back(atmosphere::DensityProfileLayer(0.0, 0.0, 0.0, -1.0 / 15000.0, 8.0 / 3.0));
+}
+
+AtmosphericModelSettings::AtmosphericModelSettings(
+ DensityProfile& rayleighProfile,
+ DensityProfile& mieProfile,
+ DensityProfile& absorptionProfile)
+: m_skyBottomRadius(6360.0f)
+, m_skyTopRadius(6420.0f)
+, m_rayleighProfile(rayleighProfile)
+, m_mieProfile(mieProfile)
+, m_absorptionProfile(absorptionProfile)
+, m_sunArcRadians(0.00045f)
+, m_mieAnisotropy(0.8f)
{
- if(gAtmosphere)
- {
- delete gAtmosphere;
- }
- gAtmosphere = NULL;
}
-LLAtmosphere::LLAtmosphere()
+AtmosphericModelSettings::AtmosphericModelSettings(
+ F32 skyBottomRadius,
+ F32 skyTopRadius,
+ DensityProfile& rayleighProfile,
+ DensityProfile& mieProfile,
+ DensityProfile& absorptionProfile,
+ F32 sunArcRadians,
+ F32 mieAniso)
+: m_skyBottomRadius(skyBottomRadius)
+, m_skyTopRadius(skyTopRadius)
+, m_rayleighProfile(rayleighProfile)
+, m_mieProfile(mieProfile)
+, m_absorptionProfile(absorptionProfile)
+, m_sunArcRadians(sunArcRadians)
+, m_mieAnisotropy(mieAniso)
{
- // Init libatmosphere model
- m_config.num_scattering_orders = 4;
-
- // Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column
- // (see http://rredc.nrel.gov/solar/spectra/am1.5/ASTMG173/ASTMG173.html),
- // summed and averaged in each bin (e.g. the value for 360nm is the average
- // of the ASTM G-173 values for all wavelengths between 360 and 370nm).
- // Values in W.m^-2.
- const int kLambdaMin = 360;
- const int kLambdaMax = 830;
- const double kSolarIrradiance[48] = {
- 1.11776, 1.14259, 1.01249, 1.14716, 1.72765, 1.73054, 1.6887, 1.61253,
- 1.91198, 2.03474, 2.02042, 2.02212, 1.93377, 1.95809, 1.91686, 1.8298,
- 1.8685, 1.8931, 1.85149, 1.8504, 1.8341, 1.8345, 1.8147, 1.78158, 1.7533,
- 1.6965, 1.68194, 1.64654, 1.6048, 1.52143, 1.55622, 1.5113, 1.474, 1.4482,
- 1.41018, 1.36775, 1.34188, 1.31429, 1.28303, 1.26758, 1.2367, 1.2082,
- 1.18737, 1.14683, 1.12362, 1.1058, 1.07124, 1.04992
- };
-
- // Values from http://www.iup.uni-bremen.de/gruppen/molspec/databases/
- // referencespectra/o3spectra2011/index.html for 233K, summed and averaged in
- // each bin (e.g. the value for 360nm is the average of the original values
- // for all wavelengths between 360 and 370nm). Values in m^2.
- const double kOzoneCrossSection[48] = {
- 1.18e-27, 2.182e-28, 2.818e-28, 6.636e-28, 1.527e-27, 2.763e-27, 5.52e-27,
- 8.451e-27, 1.582e-26, 2.316e-26, 3.669e-26, 4.924e-26, 7.752e-26, 9.016e-26,
- 1.48e-25, 1.602e-25, 2.139e-25, 2.755e-25, 3.091e-25, 3.5e-25, 4.266e-25,
- 4.672e-25, 4.398e-25, 4.701e-25, 5.019e-25, 4.305e-25, 3.74e-25, 3.215e-25,
- 2.662e-25, 2.238e-25, 1.852e-25, 1.473e-25, 1.209e-25, 9.423e-26, 7.455e-26,
- 6.566e-26, 5.105e-26, 4.15e-26, 4.228e-26, 3.237e-26, 2.451e-26, 2.801e-26,
- 2.534e-26, 1.624e-26, 1.465e-26, 2.078e-26, 1.383e-26, 7.105e-27
- };
-
- // From https://en.wikipedia.org/wiki/Dobson_unit, in molecules.m^-2.
- const double kDobsonUnit = 2.687e20;
-
- // Maximum number density of ozone molecules, in m^-3 (computed so at to get
- // 300 Dobson units of ozone - for this we divide 300 DU by the integral of
- // the ozone density profile defined below, which is equal to 15km).
- const double kMaxOzoneNumberDensity = 300.0 * kDobsonUnit / 15000.0;
-
- const double kSunAngularRadius = 0.00935 / 2.0;
- const double kBottomRadius = 6360000.0;
- const double kTopRadius = 6420000.0;
- const double kRayleigh = 1.24062e-6;
- const double kRayleighScaleHeight = 8000.0;
- const double kMieScaleHeight = 1200.0;
- const double kMieAngstromAlpha = 0.0;
- const double kMieAngstromBeta = 5.328e-3;
- const double kMieSingleScatteringAlbedo = 0.9;
- const double kMiePhaseFunctionG = 0.8;
- const double max_sun_zenith_angle = F_PI * 2.0 / 3.0;
-
- atmosphere::DensityProfileLayer rayleigh_density(0.0, 1.0, -1.0 / kRayleighScaleHeight, 0.0, 0.0);
- atmosphere::DensityProfileLayer mie_density(0.0, 1.0, -1.0 / kMieScaleHeight, 0.0, 0.0);
-
- // Density profile increasing linearly from 0 to 1 between 10 and 25km, and
- // decreasing linearly from 1 to 0 between 25 and 40km. This is an approximate
- // profile from http://www.kln.ac.lk/science/Chemistry/Teaching_Resources/
- // Documents/Introduction%20to%20atmospheric%20chemistry.pdf (page 10).
- std::vector<atmosphere::DensityProfileLayer> ozone_density;
- ozone_density.push_back(atmosphere::DensityProfileLayer(25000.0, 0.0, 0.0, 1.0 / 15000.0, -2.0 / 3.0));
- ozone_density.push_back(atmosphere::DensityProfileLayer(0.0, 0.0, 0.0, -1.0 / 15000.0, 8.0 / 3.0));
-
- std::vector<double> wavelengths;
- std::vector<double> solar_irradiance;
- std::vector<double> rayleigh_scattering;
- std::vector<double> mie_scattering;
- std::vector<double> mie_extinction;
- std::vector<double> absorption_extinction;
- std::vector<double> ground_albedo;
-
- for (int l = kLambdaMin; l <= kLambdaMax; l += 10)
- {
- double lambda = static_cast<double>(l) * 1e-3; // micro-meters
- double mie = kMieAngstromBeta / kMieScaleHeight * pow(lambda, -kMieAngstromAlpha);
- wavelengths.push_back(l);
- solar_irradiance.push_back(kSolarIrradiance[(l - kLambdaMin) / 10]);
- rayleigh_scattering.push_back(kRayleigh * pow(lambda, -4));
- mie_scattering.push_back(mie * kMieSingleScatteringAlbedo);
- mie_extinction.push_back(mie);
- absorption_extinction.push_back(kMaxOzoneNumberDensity * kOzoneCrossSection[(l - kLambdaMin) / 10]);
- ground_albedo.push_back(0.1f);
- }
-
- m_model = new atmosphere::Model(
- wavelengths,
- solar_irradiance,
- kSunAngularRadius,
- kBottomRadius,
- kTopRadius,
- {rayleigh_density},
- rayleigh_scattering,
- {mie_density},
- mie_scattering,
- mie_extinction,
- kMiePhaseFunctionG,
- ozone_density,
- absorption_extinction,
- ground_albedo,
- max_sun_zenith_angle,
- 1000.0,
- 15,
- false,
- true);
-
- m_model->Init(m_config, m_textures);
-
- m_transmittance = new LLGLTexture;
- m_scattering = new LLGLTexture;
- m_mie_scattering = new LLGLTexture;
-
- m_transmittance->generateGLTexture();
- m_transmittance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
- m_transmittance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
- m_transmittance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
- m_transmittance->setTexName(m_textures.transmittance_texture);
- m_transmittance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE);
-
- m_scattering->generateGLTexture();
- m_scattering->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
- m_scattering->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
- m_scattering->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
- m_scattering->setTexName(m_textures.transmittance_texture);
- m_scattering->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
-
- m_mie_scattering->generateGLTexture();
- m_mie_scattering->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
- m_mie_scattering->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
- m_mie_scattering->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
- m_mie_scattering->setTexName(m_textures.transmittance_texture);
- m_mie_scattering->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
-};
-
-LLAtmosphere::~LLAtmosphere()
-{
- // Cease referencing textures from atmosphere::model from our LLGLTextures wrappers for same.
- m_transmittance->setTexName(0);
- m_scattering->setTexName(0);
- m_mie_scattering->setTexName(0);
-
- delete m_model;
- m_model = nullptr;
-}
-
-LLGLTexture* LLAtmosphere::getTransmittance() const
-{
- return m_transmittance;
-}
-
-LLGLTexture* LLAtmosphere::getScattering() const
-{
- return m_scattering;
-}
-
-LLGLTexture* LLAtmosphere::getMieScattering() const
-{
- return m_mie_scattering;
-}
-
-GLhandleARB LLAtmosphere::getAtmosphericShaderForLink() const
-{
- return m_model ? m_model->GetShader() : 0;
-}
+}
+
+void LLAtmosphere::initClass()
+{
+ if (!gAtmosphere)
+ {
+ gAtmosphere = new LLAtmosphere;
+ }
+}
+
+void LLAtmosphere::cleanupClass()
+{
+ if(gAtmosphere)
+ {
+ delete gAtmosphere;
+ }
+ gAtmosphere = NULL;
+}
+
+LLAtmosphere::LLAtmosphere()
+{
+ for (int l = kLambdaMin; l <= kLambdaMax; l += 10)
+ {
+ double lambda = static_cast<double>(l) * 1e-3; // micro-meters
+ double mie = kMieAngstromBeta / kMieScaleHeight * pow(lambda, -kMieAngstromAlpha);
+ m_wavelengths.push_back(l);
+ m_solar_irradiance.push_back(kSolarIrradiance[(l - kLambdaMin) / 10]);
+ m_rayleigh_scattering.push_back(kRayleigh * pow(lambda, -4));
+ m_mie_scattering.push_back(mie * kMieSingleScatteringAlbedo);
+ m_mie_extinction.push_back(mie);
+ m_absorption_extinction.push_back(kMaxOzoneNumberDensity * kOzoneCrossSection[(l - kLambdaMin) / 10]);
+ m_ground_albedo.push_back(0.6f);
+ }
+
+ AtmosphericModelSettings defaults;
+ configureAtmosphericModel(defaults);
+}
+
+LLAtmosphere::~LLAtmosphere()
+{
+ // Cease referencing textures from atmosphere::model from our LLGLTextures wrappers for same.
+ if (m_transmittance)
+ {
+ m_transmittance->setTexName(0);
+ }
+
+ if (m_scattering)
+ {
+ m_scattering->setTexName(0);
+ }
+
+ if (m_mie_scatter_texture)
+ {
+ m_mie_scatter_texture->setTexName(0);
+ }
+
+ delete m_model;
+ m_model = nullptr;
+}
+
+bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings)
+{
+// Advanced Atmospherics TODO
+// Make this store a hash of the precomputed data
+// and avoid redundant calcs for identical settings
+
+ if (m_model)
+ {
+ delete m_model;
+ }
+ m_model = nullptr;
+ getTransmittance()->setTexName(0);
+ getScattering()->setTexName(0);
+ getMieScattering()->setTexName(0);
+
+ // Init libatmosphere model
+ m_config.num_scattering_orders = 4;
+
+ m_model = new atmosphere::Model(
+ m_wavelengths,
+ m_solar_irradiance,
+ settings.m_sunArcRadians,
+ settings.m_skyBottomRadius * 1000.0f,
+ settings.m_skyTopRadius * 1000.0f,
+ settings.m_rayleighProfile,
+ m_rayleigh_scattering,
+ settings.m_mieProfile,
+ m_mie_scattering,
+ m_mie_extinction,
+ settings.m_mieAnisotropy,
+ settings.m_absorptionProfile,
+ m_absorption_extinction,
+ m_ground_albedo,
+ max_sun_zenith_angle,
+ 1000.0,
+ 15,
+ false,
+ true);
+
+ if (m_model)
+ {
+ m_model->Init(m_config, m_textures);
+ getTransmittance()->setTexName(m_textures.transmittance_texture);
+ getScattering()->setTexName(m_textures.transmittance_texture);
+ getMieScattering()->setTexName(m_textures.transmittance_texture);
+ }
+
+ return m_model != nullptr;
+}
+
+LLGLTexture* LLAtmosphere::getTransmittance()
+{
+ if (!m_transmittance)
+ {
+ m_transmittance = new LLGLTexture;
+ m_transmittance->generateGLTexture();
+ m_transmittance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
+ m_transmittance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+ m_transmittance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
+ m_transmittance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE);
+ }
+ return m_transmittance;
+}
+
+LLGLTexture* LLAtmosphere::getScattering()
+{
+ if (!m_scattering)
+ {
+ m_scattering = new LLGLTexture;
+ m_scattering->generateGLTexture();
+ m_scattering->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
+ m_scattering->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+ m_scattering->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
+ m_scattering->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
+ }
+ return m_scattering;
+}
+
+LLGLTexture* LLAtmosphere::getMieScattering()
+{
+ if (!m_mie_scatter_texture)
+ {
+ m_mie_scatter_texture = new LLGLTexture;
+ m_mie_scatter_texture->generateGLTexture();
+ m_mie_scatter_texture->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
+ m_mie_scatter_texture->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+ m_mie_scatter_texture->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
+ m_mie_scatter_texture->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
+ }
+ return m_mie_scatter_texture;
+}
+
+GLhandleARB LLAtmosphere::getAtmosphericShaderForLink() const
+{
+ return m_model ? m_model->GetShader() : 0;
+}
diff --git a/indra/llrender/llatmosphere.h b/indra/llrender/llatmosphere.h
index 6a9d1a4438..53dc1dd354 100644
--- a/indra/llrender/llatmosphere.h
+++ b/indra/llrender/llatmosphere.h
@@ -31,6 +31,36 @@
#include "llgltexture.h"
#include "libatmosphere/model.h"
+typedef std::vector<atmosphere::DensityProfileLayer> DensityProfile;
+
+class AtmosphericModelSettings
+{
+public:
+ AtmosphericModelSettings();
+
+ AtmosphericModelSettings(
+ DensityProfile& rayleighProfile,
+ DensityProfile& mieProfile,
+ DensityProfile& absorptionProfile);
+
+ AtmosphericModelSettings(
+ F32 skyBottomRadius,
+ F32 skyTopRadius,
+ DensityProfile& rayleighProfile,
+ DensityProfile& mieProfile,
+ DensityProfile& absorptionProfile,
+ F32 sunArcRadians,
+ F32 mieAniso);
+
+ F32 m_skyBottomRadius;
+ F32 m_skyTopRadius;
+ DensityProfile m_rayleighProfile;
+ DensityProfile m_mieProfile;
+ DensityProfile m_absorptionProfile;
+ F32 m_sunArcRadians;
+ F32 m_mieAnisotropy;
+};
+
class LLAtmosphere
{
public:
@@ -46,12 +76,14 @@ public:
return *this;
}
- LLGLTexture* getTransmittance() const;
- LLGLTexture* getScattering() const;
- LLGLTexture* getMieScattering() const;
+ LLGLTexture* getTransmittance();
+ LLGLTexture* getScattering();
+ LLGLTexture* getMieScattering();
GLhandleARB getAtmosphericShaderForLink() const;
+ bool configureAtmosphericModel(AtmosphericModelSettings& settings);
+
protected:
LLAtmosphere(const LLAtmosphere& rhs)
{
@@ -64,7 +96,15 @@ protected:
LLPointer<LLGLTexture> m_transmittance;
LLPointer<LLGLTexture> m_scattering;
- LLPointer<LLGLTexture> m_mie_scattering;
+ LLPointer<LLGLTexture> m_mie_scatter_texture;
+
+ std::vector<double> m_wavelengths;
+ std::vector<double> m_solar_irradiance;
+ std::vector<double> m_rayleigh_scattering;
+ std::vector<double> m_mie_scattering;
+ std::vector<double> m_mie_extinction;
+ std::vector<double> m_absorption_extinction;
+ std::vector<double> m_ground_albedo;
};
extern LLAtmosphere* gAtmosphere;
diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
index db8ec71b35..fee1a7f311 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
@@ -22,9 +22,12 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+
+vec3 getAdditiveColor();
+vec3 getAtmosAttenuation();
uniform sampler2D cloudMap;
+uniform vec4 gamma;
uniform vec4 cloud_pos_density1;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
@@ -41,26 +44,29 @@ uniform vec4 glow;
uniform float scene_light_strength;
uniform mat3 ssao_effect_mat;
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-void setPositionEye(vec3);
-vec3 getPositionEye();
-vec3 getSunlitColor();
-vec3 getAmblitColor();
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-void setPositionEye(vec3 v);
-void setSunlitColor(vec3 v);
-void setAmblitColor(vec3 v);
-void setAdditiveColor(vec3 v);
-void setAtmosAttenuation(vec3 v);
+vec3 scaleFragSoftClip(vec3 light)
+{
+ //soft clip effect:
+ light = 1. - clamp(light, vec3(0.), vec3(1.));
+ light = 1. - pow(light, gamma.xxx);
+ return light;
+}
-void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
+vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten)
+{
+ light *= atten.r;
+ light += additive;
+ return (2.0 * light);
+}
+
+vec3 atmosLighting(vec3 light)
+{
+ return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation());
+}
+
+void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) {
vec3 P = inPositionEye;
- setPositionEye(P);
vec3 tmpLightnorm = lightnorm.xyz;
@@ -98,7 +104,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
temp1 = exp(-temp1 * temp2.z * distance_multiplier);
//final atmosphere attenuation factor
- setAtmosAttenuation(temp1.rgb);
+ atten = temp1.rgb;
//compute haze glow
//(can use temp2.x as temp because we haven't used it yet)
@@ -129,20 +135,14 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
//haze color
- setAdditiveColor(
+ additive =
vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
- + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
- + tmpAmbient)));
+ + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
+ + tmpAmbient));
//brightness of surface both sunlight and ambient
- setSunlitColor(vec3(sunlight * .5));
- setAmblitColor(vec3(tmpAmbient * .25));
- setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
+ sunlit = vec3(sunlight * .5);
+ amblit = vec3(tmpAmbient * .25);
+ additive *= vec3(1.0 - temp1);
}
-vec3 atmosLighting(vec3 light)
-{
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor();
- return (2.0 * light);
-}
diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
index c064023858..3270c243a4 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
@@ -49,7 +49,7 @@ uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
-void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
+void calcAtmospherics(vec3 inPositionEye) {
vec3 P = inPositionEye;
setPositionEye(P);
@@ -118,7 +118,7 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
* vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
* tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
*/
- tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
+ //tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
//haze color
setAdditiveColor(
diff --git a/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
index c71eaf4b13..08b6ec3f97 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
@@ -49,16 +49,16 @@ void main()
{
vec3 view_direction = normalize(view_dir);
- vec3 camPos = cameraPosLocal;
+ vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f);
vec3 transmittance;
vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance);
- radiance *= transmittance;
+ //radiance *= transmittance;
// If the view ray intersects the Sun, add the Sun radiance.
if (dot(view_direction, sun_direction) >= sun_size.y)
{
- radiance = radiance + transmittance * GetSolarLuminance();
+ radiance = radiance + (transmittance * GetSolarLuminance());
}
vec3 color = vec3(1.0) - exp(-radiance);
diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
index 8a8e4cb0f6..82e1d7fe35 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
@@ -33,21 +33,30 @@ vec3 getAtmosAttenuation();
uniform sampler2D cloudMap;
uniform vec4 cloud_pos_density1;
-vec3 atmosTransport(vec3 light) {
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor() * 2.0;
+vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive) {
+ light *= atten.r;
+ light += additive * 2.0;
return light;
}
-vec3 fullbrightAtmosTransport(vec3 light) {
+vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
float brightness = dot(light.rgb, vec3(0.33333));
-
- return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness);
+ return mix(atmosFragTransport(light.rgb, atten, additive), light.rgb + additive.rgb, brightness * brightness);
}
-vec3 fullbrightShinyAtmosTransport(vec3 light) {
+vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
float brightness = dot(light.rgb, vec3(0.33333));
+ return mix(atmosFragTransport(light.rgb, atten, additive), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
+}
- return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness);
+vec3 atmosTransport(vec3 light) {
+ return atmosFragTransport(light, getAtmosAttenuation(), getAdditiveColor());
}
+vec3 fullbrightAtmosTransport(vec3 light) {
+ return fullbrightFragAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+}
+
+vec3 fullbrightShinyAtmosTransport(vec3 light) {
+ return fullbrightFragShinyAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+}
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index b03367c4dd..a795628e8f 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -54,6 +54,8 @@
#include <boost/make_shared.hpp>
+#include "llatmosphere.h"
+
//define EXPORT_PRESETS 1
//=========================================================================
namespace
@@ -135,6 +137,55 @@ bool LLEnvironment::canEdit() const
return true;
}
+void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky)
+{
+ settingsOut.m_skyBottomRadius = psky->getSkyBottomRadius();
+ settingsOut.m_skyTopRadius = psky->getSkyTopRadius();
+ settingsOut.m_sunArcRadians = psky->getSunArcRadians();
+ settingsOut.m_mieAnisotropy = psky->getMieAnisotropy();
+
+ LLSD rayleigh = psky->getRayleighConfigs();
+ settingsOut.m_rayleighProfile.clear();
+ for (LLSD::array_iterator itf = rayleigh.beginArray(); itf != rayleigh.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_rayleighProfile.push_back(layer);
+ }
+
+ LLSD mie = psky->getMieConfigs();
+ settingsOut.m_mieProfile.clear();
+ for (LLSD::array_iterator itf = mie.beginArray(); itf != mie.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_mieProfile.push_back(layer);
+ }
+
+ LLSD absorption = psky->getAbsorptionConfigs();
+ settingsOut.m_absorptionProfile.clear();
+ for (LLSD::array_iterator itf = absorption.beginArray(); itf != absorption.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_absorptionProfile.push_back(layer);
+ }
+}
LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb)
{
@@ -1326,6 +1377,7 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Sec
}
+
void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky)
{
if (mType == TYPE_CYCLED)
@@ -1335,6 +1387,13 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky)
mSky = psky;
mBlenderSky.reset();
+
+ if (gAtmosphere)
+ {
+ AtmosphericModelSettings settings;
+ LLEnvironment::getAtmosphericModelSettings(settings, psky);
+ gAtmosphere->configureAtmosphericModel(settings);
+ }
}
void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater)
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index a7159ca84d..55ade803ac 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -41,6 +41,7 @@
//-------------------------------------------------------------------------
class LLViewerCamera;
class LLGLSLShader;
+class AtmosphericModelSettings;
//-------------------------------------------------------------------------
class LLEnvironment : public LLSingleton<LLEnvironment>
@@ -137,6 +138,8 @@ public:
LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); }
LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); }
+ static void getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky);
+
void update(const LLViewerCamera * cam);
void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 54f48baa97..4db039ace3 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1319,6 +1319,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedAlphaProgram.mFeatures.encodesNormal = true;
gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasTransport = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));