summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2017-09-21 15:58:13 -0700
committerRider Linden <rider@lindenlab.com>2017-09-21 15:58:13 -0700
commit150fba7c5cd24ad9ab343e762bfd15032e6a9462 (patch)
tree54a8d169470368e460e4bfb7ecf3805b6d120033
parentd4d0520f38f59c4f60da098da9c2217ca6e45d65 (diff)
Still not working. Black Sky.
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp10
-rw-r--r--indra/newview/llenvironment.cpp271
-rw-r--r--indra/newview/llenvironment.h81
-rw-r--r--indra/newview/llsettingsbase.h5
-rw-r--r--indra/newview/llsettingssky.cpp69
-rw-r--r--indra/newview/llsettingssky.h15
-rw-r--r--indra/newview/llvosky.cpp50
-rw-r--r--indra/newview/llwlparammanager.cpp3
-rw-r--r--indra/newview/llwlparamset.cpp20
9 files changed, 468 insertions, 56 deletions
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index 309f535c39..e10bc10bc2 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -42,6 +42,8 @@
#include "llface.h"
#include "llrender.h"
+#include "llenvironment.h"
+
LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL;
LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL;
@@ -190,14 +192,14 @@ void LLDrawPoolWLSky::renderStars(void) const
// *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid
// clamping and allow the star_alpha param to brighten the stars.
- bool error;
LLColor4 star_alpha(LLColor4::black);
- star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f;
+ // *LAPRAS
+ star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 2.f;
// If start_brightness is not set, exit
- if( error )
+ if( star_alpha.mV[3] < 0.001 )
{
- LL_WARNS() << "star_brightness missing in mCurParams" << LL_ENDL;
+ LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL;
return;
}
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
new file mode 100644
index 0000000000..dec2930970
--- /dev/null
+++ b/indra/newview/llenvironment.cpp
@@ -0,0 +1,271 @@
+/**
+ * @file llenvmanager.cpp
+ * @brief Implementation of classes managing WindLight and water settings.
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, 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 "llviewerprecompiledheaders.h"
+
+#include "llenvironment.h"
+
+#include "llagent.h"
+#include "lldaycyclemanager.h"
+#include "llviewercontrol.h" // for gSavedSettings
+#include "llviewerregion.h"
+#include "llwaterparammanager.h"
+#include "llwlhandlers.h"
+#include "llwlparammanager.h"
+#include "lltrans.h"
+#include "lltrace.h"
+#include "llfasttimer.h"
+#include "llviewercamera.h"
+#include "pipeline.h"
+
+//=========================================================================
+const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg
+
+namespace
+{
+ LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick");
+ LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters");
+}
+
+//-------------------------------------------------------------------------
+LLEnvironment::LLEnvironment():
+ mCurrentSky(),
+ mSkysById(),
+ mSkysByName()
+{
+ LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky();
+ addSky(p_default_sky);
+ mCurrentSky = p_default_sky;
+}
+
+LLEnvironment::~LLEnvironment()
+{
+}
+
+//-------------------------------------------------------------------------
+void LLEnvironment::update(const LLViewerCamera * cam)
+{
+ LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE);
+
+ // update clouds, sun, and general
+ updateCloudScroll();
+ mCurrentSky->update();
+
+// // update only if running
+// if (mAnimator.getIsRunning())
+// {
+// mAnimator.update(mCurParams);
+// }
+
+ LLVector3 lightdir = mCurrentSky->getLightDirection();
+ // update the shaders and the menu
+
+ F32 camYaw = cam->getYaw();
+
+ stop_glerror();
+
+ // *TODO: potential optimization - this block may only need to be
+ // executed some of the time. For example for water shaders only.
+ {
+ LLVector3 lightNorm3(mCurrentSky->getLightDirection());
+
+ lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f));
+ mRotatedLight = LLVector4(lightNorm3, 0.f);
+
+ LLViewerShaderMgr::shader_iter shaders_iter, end_shaders;
+ end_shaders = LLViewerShaderMgr::instance()->endShaders();
+ for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
+ {
+ if ((shaders_iter->mProgramObject != 0)
+ && (gPipeline.canUseWindLightShaders()
+ || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER))
+ {
+ shaders_iter->mUniformsDirty = TRUE;
+ }
+ }
+ }
+}
+
+void LLEnvironment::updateCloudScroll()
+{
+ // This is a function of the environment rather than the sky, since it should
+ // persist through sky transitions.
+ static LLTimer s_cloud_timer;
+
+ F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64();
+
+ LLVector2 cloud_delta = static_cast<F32>(delta_t) * (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
+
+ mCloudScroll += cloud_delta;
+
+}
+
+void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting)
+{
+ LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE);
+
+ //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL;
+ LLSettingsBase::parammapping_t params = psetting->getParameterMap();
+ for (LLSettingsBase::parammapping_t::iterator it = params.begin(); it != params.end(); ++it)
+ {
+ if (!psetting->mSettings.has((*it).first))
+ continue;
+
+ LLSD value = psetting->mSettings[(*it).first];
+ LLSD::Type setting_type = value.type();
+
+ stop_glerror();
+ switch (setting_type)
+ {
+ case LLSD::TypeInteger:
+ shader->uniform1i((*it).second, value.asInteger());
+ //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
+ break;
+ case LLSD::TypeReal:
+ shader->uniform1f((*it).second, value.asReal());
+ //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
+ break;
+
+ case LLSD::TypeBoolean:
+ shader->uniform1i((*it).second, value.asBoolean() ? 1 : 0);
+ //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
+ break;
+
+ case LLSD::TypeArray:
+ {
+ LLVector4 vect4(value);
+ //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL;
+ shader->uniform4fv((*it).second, 4, vect4.mV);
+
+ break;
+ }
+
+ // case LLSD::TypeMap:
+ // case LLSD::TypeString:
+ // case LLSD::TypeUUID:
+ // case LLSD::TypeURI:
+ // case LLSD::TypeBinary:
+ // case LLSD::TypeDate:
+ default:
+ break;
+ }
+ stop_glerror();
+ }
+ //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL;
+
+// psetting->applySpecial(shader);
+
+ if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender)
+ {
+ shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2);
+ }
+ else
+ {
+ shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0);
+ }
+
+}
+
+void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)
+{
+
+ if (gPipeline.canUseWindLightShaders())
+ {
+ updateGLVariablesForSettings(shader, mCurrentSky);
+ }
+
+ if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
+ {
+ stop_glerror();
+ shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLight.mV);
+ shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+ stop_glerror();
+ }
+ else if (shader->mShaderGroup == LLGLSLShader::SG_SKY)
+ {
+ stop_glerror();
+ shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mCurrentSky->getLightDirectionClamped().mV);
+ stop_glerror();
+ }
+
+ shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->getSceneLightStrength());
+
+ {
+ LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0);
+// val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset;
+// val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset;
+// val.mV[2] = (F32)i->second[2].asReal();
+// val.mV[3] = (F32)i->second[3].asReal();
+
+ stop_glerror();
+ shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV);
+ stop_glerror();
+ }
+
+
+}
+//--------------------------------------------------------------------------
+
+void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)
+{
+ std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString();
+
+ std::pair<NamedSkyMap_t::iterator, bool> result;
+ result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky));
+
+ if (!result.second)
+ (*(result.first)).second = sky;
+}
+
+void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky)
+{
+ // std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString();
+ //
+ // std::pair<NamedSkyMap_t::iterator, bool> result;
+ // result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky));
+ //
+ // if (!result.second)
+ // (*(result.first)).second = sky;
+}
+
+void LLEnvironment::removeSky(const std::string &name)
+{
+ NamedSkyMap_t::iterator it = mSkysByName.find(name);
+ if (it != mSkysByName.end())
+ mSkysByName.erase(it);
+}
+
+void LLEnvironment::removeSky(const LLUUID &id)
+{
+
+}
+
+void LLEnvironment::clearAllSkys()
+{
+ mSkysByName.clear();
+ mSkysById.clear();
+}
+
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
new file mode 100644
index 0000000000..bbb5f45ad9
--- /dev/null
+++ b/indra/newview/llenvironment.h
@@ -0,0 +1,81 @@
+/**
+ * @file llenvmanager.h
+ * @brief Declaration of classes managing WindLight and water settings.
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, 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$
+ */
+
+#ifndef LL_ENVIRONMENT_H
+#define LL_ENVIRONMENT_H
+
+#include "llmemory.h"
+#include "llsd.h"
+
+#include "llsettingssky.h"
+
+class LLViewerCamera;
+class LLGLSLShader;
+
+//-------------------------------------------------------------------------
+class LLEnvironment : public LLSingleton<LLEnvironment>
+{
+ LLSINGLETON(LLEnvironment);
+ LOG_CLASS(LLEnvironment);
+
+public:
+ virtual ~LLEnvironment();
+
+ LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; }
+
+ void update(const LLViewerCamera * cam);
+
+ LLVector4 getRotatedLightDir() const { return mRotatedLight; }
+
+ void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
+ void updateShaderUniforms(LLGLSLShader *shader);
+
+ void addSky(const LLSettingsSky::ptr_t &sky);
+private:
+ static const F32 SUN_DELTA_YAW;
+
+ typedef std::map<std::string, LLSettingsSky::ptr_t> NamedSkyMap_t;
+ typedef std::map<LLUUID, LLSettingsSky::ptr_t> AssetSkyMap_t;
+
+ LLVector4 mRotatedLight;
+ LLVector2 mCloudScroll;
+
+ LLSettingsSky::ptr_t mCurrentSky;
+
+ NamedSkyMap_t mSkysByName;
+ AssetSkyMap_t mSkysById;
+
+ void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
+ void removeSky(const std::string &name);
+ void removeSky(const LLUUID &id);
+ void clearAllSkys();
+
+ void updateCloudScroll();
+};
+
+
+#endif // LL_ENVIRONMENT_H
+
diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h
index 01a19c8734..cd5098cbb6 100644
--- a/indra/newview/llsettingsbase.h
+++ b/indra/newview/llsettingsbase.h
@@ -45,6 +45,8 @@ class LLSettingsBase: private boost::noncopyable
friend class LLEnvironment;
public:
+ typedef std::map<std::string, S32> parammapping_t;
+
typedef boost::shared_ptr<LLSettingsBase> ptr_t;
virtual ~LLSettingsBase() { };
@@ -122,6 +124,7 @@ protected:
typedef std::set<std::string> stringset_t;
+
// combining settings objects. Customize for specific setting types
virtual void lerpSettings(const LLSettingsBase &other, F32 mix);
@@ -141,6 +144,8 @@ protected:
// Apply any settings that need special handling.
virtual void applySpecial(void *) { };
+ virtual parammapping_t getParameterMap() const { return parammapping_t(); }
+
LLSD mSettings;
private:
diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp
index 364c211344..26ed719b3b 100644
--- a/indra/newview/llsettingssky.cpp
+++ b/indra/newview/llsettingssky.cpp
@@ -117,17 +117,17 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam
if (oldsettings.has(SETTING_AMBIENT))
{
- newsettings[SETTING_AMBIENT] = LLColor3(oldsettings[SETTING_AMBIENT]).getValue();
+ newsettings[SETTING_AMBIENT] = LLColor4(oldsettings[SETTING_AMBIENT]).getValue();
}
if (oldsettings.has(SETTING_BLUE_DENSITY))
{
- newsettings[SETTING_BLUE_DENSITY] = LLColor3(oldsettings[SETTING_BLUE_DENSITY]).getValue();
+ newsettings[SETTING_BLUE_DENSITY] = LLColor4(oldsettings[SETTING_BLUE_DENSITY]).getValue();
}
if (oldsettings.has(SETTING_BLUE_HORIZON))
{
- newsettings[SETTING_BLUE_HORIZON] = LLColor3(oldsettings[SETTING_BLUE_HORIZON]).getValue();
+ newsettings[SETTING_BLUE_HORIZON] = LLColor4(oldsettings[SETTING_BLUE_HORIZON]).getValue();
}
if (oldsettings.has(SETTING_CLOUD_COLOR))
@@ -188,12 +188,12 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam
if (oldsettings.has(SETTING_GLOW))
{
- newsettings[SETTING_GLOW] = LLColor3(oldsettings[SETTING_GLOW]).getValue();
+ newsettings[SETTING_GLOW] = LLColor4(oldsettings[SETTING_GLOW]).getValue();
}
if (oldsettings.has(SETTING_GAMMA))
{
- newsettings[SETTING_GAMMA] = LLSD::Real(oldsettings[SETTING_GAMMA][0].asReal());
+ newsettings[SETTING_GAMMA] = LLVector4(oldsettings[SETTING_GAMMA]).getValue();
}
if (oldsettings.has(SETTING_CLOUD_SCROLL_RATE))
@@ -283,21 +283,21 @@ LLSD LLSettingsSky::defaults()
LLQuaternion moonquat = ~sunquat;
// Magic constants copied form dfltsetting.xml
- dfltsetting[SETTING_AMBIENT] = LLColor3::white.getValue();
- dfltsetting[SETTING_BLUE_DENSITY] = LLColor3(0.2447, 0.4487, 0.7599).getValue();
- dfltsetting[SETTING_BLUE_HORIZON] = LLColor3(0.4954, 0.4954, 0.6399).getValue();
- dfltsetting[SETTING_CLOUD_COLOR] = LLColor3(0.4099, 0.4099, 0.4099).getValue();
- dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor3(1.0000, 0.5260, 1.0000).getValue();
- dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor3(1.0000, 0.5260, 1.0000).getValue();
+ dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue();
+ dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 1.0).getValue();
+ dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 1.0).getValue();
+ dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 1.0).getValue();
+ dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).getValue();
+ dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).getValue();
dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199);
dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109);
- dfltsetting[SETTING_CLOUD_SHADOW] = LLColor3(0.2699, 0.0000, 0.0000).getValue();
+ dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699);
dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001);
dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000);
- dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(1.0);
- dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(0.0);
- dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0000);
- dfltsetting[SETTING_GLOW] = LLColor3(5.000, 0.0010, -0.4799).getValue(); // *RIDER: This is really weird for a color... TODO: check if right.
+ dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f);
+ dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f);
+ dfltsetting[SETTING_GAMMA] = LLVector4(1.0, 0.0, 0.0, 1.0).getValue();
+ dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); // *RIDER: This is really weird for a color... TODO: check if right.
dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999);
dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899);
dfltsetting[SETTING_LIGHT_NORMAL] = LLVector4(0.0000, 0.9126, -0.4086, 0.0000).getValue();
@@ -305,7 +305,7 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue();
dfltsetting[SETTING_NAME] = std::string("_default_");
dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000);
- dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor3(0.7342, 0.7815, 0.8999).getValue();
+ dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 1.0).getValue();
dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue();
dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null;
@@ -468,10 +468,37 @@ void LLSettingsSky::calculateLightSettings()
mTotalAmbient.setAlpha(1);
mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f;
- mFadeColor.setAlpha(0);
+ mFadeColor.setAlpha(1);
}
+LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const
+{
+ static parammapping_t param_map;
+
+ if (param_map.empty())
+ {
+ param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT;
+ param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY;
+ param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON;
+ param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR;
+ param_map[SETTING_CLOUD_POS_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1;
+ param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2;
+ param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE;
+ param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW;
+ param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER;
+ param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER;
+ param_map[SETTING_GAMMA] = LLShaderMgr::GAMMA;
+ param_map[SETTING_GLOW] = LLShaderMgr::GLOW;
+ param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY;
+ param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON;
+ param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y;
+ param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR;
+ }
+
+ return param_map;
+}
+
LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const
{
@@ -480,14 +507,14 @@ LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const
if (skip_apply_set.empty())
{
- skip_apply_set.insert(SETTING_GAMMA);
skip_apply_set.insert(SETTING_MOON_ROTATION);
skip_apply_set.insert(SETTING_SUN_ROTATION);
skip_apply_set.insert(SETTING_NAME);
skip_apply_set.insert(SETTING_STAR_BRIGHTNESS);
skip_apply_set.insert(SETTING_CLOUD_SCROLL_RATE);
skip_apply_set.insert(SETTING_LIGHT_NORMAL);
- skip_apply_set.insert(SETTING_CLOUD_POS_DENSITY1);
+ skip_apply_set.insert(SETTING_DOME_OFFSET);
+ skip_apply_set.insert(SETTING_DOME_RADIUS);
}
return skip_apply_set;
@@ -505,6 +532,8 @@ void LLSettingsSky::applySpecial(void *ptarget)
shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength);
shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0);
+
+
}
//-------------------------------------------------------------------------
diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h
index 5b8691fa8b..2fb9ff3887 100644
--- a/indra/newview/llsettingssky.h
+++ b/indra/newview/llsettingssky.h
@@ -161,12 +161,12 @@ public:
F32 getGama() const
{
- return mSettings[SETTING_GAMMA].asReal();
+ return mSettings[SETTING_GAMMA][0].asReal();
}
LLColor3 getGlow() const
{
- return mSettings[SETTING_GLOW].asReal();
+ return LLColor3(mSettings[SETTING_GLOW]);
}
F32 getHazeDensity() const
@@ -179,6 +179,11 @@ public:
return mSettings[SETTING_HAZE_HORIZON].asReal();
}
+ LLVector3 getLightNormal() const
+ {
+ return LLVector3(mSettings[SETTING_LIGHT_NORMAL]);
+ }
+
F32 getMaxY() const
{
return mSettings[SETTING_MAX_Y].asReal();
@@ -289,6 +294,8 @@ protected:
virtual void updateSettings();
+ virtual parammapping_t getParameterMap() const;
+
virtual stringset_t getSkipApplyKeys() const;
virtual void applySpecial(void *);
@@ -309,6 +316,10 @@ private:
LLColor4 mTotalAmbient;
LLColor4 mFadeColor;
+
+ typedef std::map<std::string, S32> mapNameToUniformId_t;
+
+ static mapNameToUniformId_t sNameToUniformMapping;
};
#endif
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 03dfdf92fa..ce956b7fda 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -52,6 +52,9 @@
#include "llwaterparammanager.h"
#include "v3colorutil.h"
+#include "llsettingssky.h"
+#include "llenvironment.h"
+
#undef min
#undef max
@@ -327,8 +330,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
mWorldScale(1.f),
mBumpSunDir(0.f, 0.f, 1.f)
{
- bool error = false;
-
/// WL PARAMS
dome_radius = 1.f;
dome_offset_ratio = 0.f;
@@ -367,7 +368,9 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
mAtmHeight = ATM_HEIGHT;
mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS);
- mSunDefaultPosition = LLVector3(LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error));
+ // *LAPRAS
+ mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getLightNormal();
+
if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition"))
{
initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0));
@@ -563,27 +566,28 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile)
void LLVOSky::initAtmospherics(void)
{
- bool error;
- // uniform parameters for convenience
- dome_radius = LLWLParamManager::getInstance()->getDomeRadius();
- dome_offset_ratio = LLWLParamManager::getInstance()->getDomeOffset();
- sunlight_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("sunlight_color", error));
- ambient = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("ambient", error));
- //lightnorm = LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error);
- gamma = LLWLParamManager::getInstance()->mCurParams.getFloat("gamma", error);
- blue_density = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_density", error));
- blue_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_horizon", error));
- haze_density = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_density", error);
- haze_horizon = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_horizon", error);
- density_multiplier = LLWLParamManager::getInstance()->mCurParams.getFloat("density_multiplier", error);
- max_y = LLWLParamManager::getInstance()->mCurParams.getFloat("max_y", error);
- glow = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("glow", error));
- cloud_shadow = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", error);
- cloud_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_color", error));
- cloud_scale = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_scale", error);
- cloud_pos_density1 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density1", error));
- cloud_pos_density2 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density2", error));
+ // *LAPRAS
+ // uniform parameters for convenience
+ LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky();
+
+ dome_radius = sky->getDomeRadius();
+ dome_offset_ratio = sky->getDomeOffset();
+ sunlight_color = sky->getSunlightColor();
+ ambient = sky->getAmbientColor();
+ gamma = sky->getGama();
+ blue_density = sky->getBlueDensity();
+ blue_horizon = sky->getBlueHorizon();
+ haze_density = sky->getHazeDensity();
+ haze_horizon = sky->getHazeHorizon();
+ density_multiplier = sky->getDensityMultiplier();
+ max_y = sky->getMaxY();
+ glow = sky->getGlow();
+ cloud_shadow = sky->getCloudShadow();
+ cloud_color = sky->getCloudColor();
+ cloud_scale = sky->getCloudScale();
+ cloud_pos_density1 = sky->getCloudPosDensity1();
+ cloud_pos_density2 = sky->getCloudPosDensity2();
// light norm is different. We need the sun's direction, not the light direction
// which could be from the moon. And we need to clamp it
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index 41783c8667..de2d3bc41d 100644
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -351,7 +351,8 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
{
if (gPipeline.canUseWindLightShaders())
{
- mCurParams.update(shader);
+ LLEnvironment::instance().updateGLVariablesForSettings(shader, LLEnvironment::instance().getCurrentSky());
+ //mCurParams.update(shader);
}
if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp
index 066cb9a0ac..a2ff2c0c95 100644
--- a/indra/newview/llwlparamset.cpp
+++ b/indra/newview/llwlparamset.cpp
@@ -65,6 +65,8 @@ static LLTrace::BlockTimerStatHandle FTM_WL_PARAM_UPDATE("WL Param Update");
void LLWLParamSet::update(LLGLSLShader * shader) const
{
LL_RECORD_BLOCK_TIME(FTM_WL_PARAM_UPDATE);
+ //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL;
+
LLSD::map_const_iterator i = mParamValues.beginMap();
std::vector<LLStaticHashedString>::const_iterator n = mParamHashedNames.begin();
for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++)
@@ -91,7 +93,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
val.mV[3] = (F32) i->second[3].asReal();
stop_glerror();
- shader->uniform4fv(param, 1, val.mV);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform4fv(param, 1, val.mV);
stop_glerror();
}
else if (param == sCloudScale || param == sCloudShadow ||
@@ -102,7 +105,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
F32 val = (F32) i->second[0].asReal();
stop_glerror();
- shader->uniform1f(param, val);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform1f(param, val);
stop_glerror();
}
else // param is the uniform name
@@ -118,7 +122,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
val.mV[3] = (F32) i->second[3].asReal();
stop_glerror();
- shader->uniform4fv(param, 1, val.mV);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform4fv(param, 1, val.mV);
stop_glerror();
}
else if (i->second.isReal())
@@ -126,7 +131,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
F32 val = (F32) i->second.asReal();
stop_glerror();
- shader->uniform1f(param, val);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform1f(param, val);
stop_glerror();
}
else if (i->second.isInteger())
@@ -134,7 +140,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
S32 val = (S32) i->second.asInteger();
stop_glerror();
- shader->uniform1i(param, val);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform1i(param, val);
stop_glerror();
}
else if (i->second.isBoolean())
@@ -142,7 +149,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
S32 val = (i->second.asBoolean() ? 1 : 0);
stop_glerror();
- shader->uniform1i(param, val);
+ //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL;
+ shader->uniform1i(param, val);
stop_glerror();
}
}