summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llenvironment.cpp65
-rw-r--r--indra/newview/llenvironment.h2
-rw-r--r--indra/newview/llsettingsvo.cpp50
3 files changed, 40 insertions, 77 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index ae625630eb..da558a0ba3 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -885,6 +885,7 @@ void LLEnvironment::updateCloudScroll()
}
+// static
void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting)
{
LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE);
@@ -894,62 +895,19 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
for (auto &it: params)
{
LLSD value;
-
- bool found_in_settings = psetting->mSettings.has(it.first);
- bool found_in_legacy_settings = !found_in_settings && psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first);
-
- if (found_in_settings)
- {
- value = psetting->mSettings[it.first];
- }
- else if (found_in_legacy_settings)
+ // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor()
+ if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first))
{
value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first];
}
- else if (psetting->getSettingsType() == "sky")
+ else if (psetting->mSettings.has(it.first))
{
- // Legacy atmospherics is a special case,
- // these values either have non zero defaults when they are not present
- // in LLSD or need to be acounted for (reset) even if they are not present
- // Todo: consider better options, for example make LLSettingsSky init these options
- // Todo: we should reset shaders for all missing fields, not just these ones
- LLSettingsSky::ptr_t skyp = std::static_pointer_cast<LLSettingsSky>(psetting);
- if (it.first == LLSettingsSky::SETTING_BLUE_DENSITY)
- {
- value = skyp->getBlueDensity().getValue();
- }
- else if (it.first == LLSettingsSky::SETTING_BLUE_HORIZON)
- {
- value = skyp->getBlueHorizon().getValue();
- }
- else if (it.first == LLSettingsSky::SETTING_DENSITY_MULTIPLIER)
- {
- value = skyp->getDensityMultiplier();
- }
- else if (it.first == LLSettingsSky::SETTING_DISTANCE_MULTIPLIER)
- {
- value = skyp->getDistanceMultiplier();
- }
- else if (it.first == LLSettingsSky::SETTING_HAZE_DENSITY)
- {
- value = skyp->getHazeDensity();
- }
- else if (it.first == LLSettingsSky::SETTING_HAZE_HORIZON)
- {
- value = skyp->getHazeHorizon();
- }
- else if (it.first == LLSettingsSky::SETTING_AMBIENT)
- {
- value = skyp->getAmbientColor().getValue();
- }
- else
- {
- continue;
- }
+ value = psetting->mSettings[it.first];
}
else
{
- continue;
+ // We need to reset shaders, use defaults
+ value = it.second.getDefaultValue();
}
LLSD::Type setting_type = value.type();
@@ -957,16 +915,16 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
switch (setting_type)
{
case LLSD::TypeInteger:
- shader->uniform1i(it.second, value.asInteger());
+ shader->uniform1i(it.second.getShaderKey(), value.asInteger());
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
case LLSD::TypeReal:
- shader->uniform1f(it.second, value.asReal());
+ shader->uniform1f(it.second.getShaderKey(), value.asReal());
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
case LLSD::TypeBoolean:
- shader->uniform1i(it.second, value.asBoolean() ? 1 : 0);
+ shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0);
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
@@ -974,8 +932,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
{
LLVector4 vect4(value);
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL;
- shader->uniform4fv(it.second, 1, vect4.mV);
-
+ shader->uniform4fv(it.second.getShaderKey(), 1, vect4.mV);
break;
}
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 31c9d290be..63020ab5d7 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -124,7 +124,7 @@ public:
void update(const LLViewerCamera * cam);
- void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
+ static void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
void updateShaderUniforms(LLGLSLShader *shader);
void setSelectedEnvironment(EnvSelection_t env, LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index dad7fc9448..2696ad4df5 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -683,26 +683,31 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const
if (param_map.empty())
{
// LEGACY_ATMOSPHERICS
- 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_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY;
- param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON;
- param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER;
- param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER;
-
- param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR;
- 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_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE;
- param_map[SETTING_GLOW] = LLShaderMgr::GLOW;
- param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y;
- param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR;
- param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS;
- param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL;
- param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS;
- param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL;
+
+ // Todo: default 'legacy' values duplicate the ones from functions like getBlueDensity() find a better home for them
+ // There is LLSettingsSky::defaults(), but it doesn't contain everything since it is geared towards creating new settings.
+ param_map[SETTING_AMBIENT] = DefaultParam(LLShaderMgr::AMBIENT, LLColor3(0.25f, 0.25f, 0.25f).getValue());
+ param_map[SETTING_BLUE_DENSITY] = DefaultParam(LLShaderMgr::BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f).getValue());
+ param_map[SETTING_BLUE_HORIZON] = DefaultParam(LLShaderMgr::BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f).getValue());
+ param_map[SETTING_HAZE_DENSITY] = DefaultParam(LLShaderMgr::HAZE_DENSITY, LLSD(0.7f));
+ param_map[SETTING_HAZE_HORIZON] = DefaultParam(LLShaderMgr::HAZE_HORIZON, LLSD(0.19f));
+ param_map[SETTING_DENSITY_MULTIPLIER] = DefaultParam(LLShaderMgr::DENSITY_MULTIPLIER, LLSD(0.0001f));
+ param_map[SETTING_DISTANCE_MULTIPLIER] = DefaultParam(LLShaderMgr::DISTANCE_MULTIPLIER, LLSD(0.8f));
+
+ // Following values are always present, so we can just zero these ones, but used values from defaults()
+ LLSD& sky_defaults = LLSettingsSky::defaults();
+ param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]);
+ param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]);
+ param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]);
+ param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]);
+ param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]);
+ param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]);
+ param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]);
+ param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]);
+ param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]);
+ param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]);
+ param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]);
+ param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]);
// AdvancedAtmospherics TODO
// Provide mappings for new shader params here
@@ -911,8 +916,9 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const
if (param_map.empty())
{
- param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR;
- param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY;
+ LLSD &water_defaults = LLSettingsWater::defaults();
+ param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]);
+ param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]);
}
return param_map;
}