diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index af3e84fd0fb6c583c7cc9bf55f202aebe3d1326a..61b59e35aacd523ea90f693108896098f5b4f557 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -39,6 +39,7 @@ namespace } const LLSettingsBase::TrackPosition LLSettingsBase::INVALID_TRACKPOS(-1.0); +const std::string LLSettingsBase::DEFAULT_SETTINGS_NAME("_default_"); //========================================================================= std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings) @@ -67,7 +68,6 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mAssetID(), mBlendedFactor(0.0) { } @@ -75,7 +75,6 @@ LLSettingsBase::LLSettingsBase(): LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), mDirty(true), - mAssetID(), mBlendedFactor(0.0) { } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 26e2901968c336c29ea6f0e10ec0274df0f77220..1d118f07899d332d12b936a1f06e756018ed2656 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -64,6 +64,7 @@ class LLSettingsBase : typedef F64 BlendFactor; typedef F32 TrackPosition; // 32-bit as these are stored in LLSD as such static const TrackPosition INVALID_TRACKPOS; + static const std::string DEFAULT_SETTINGS_NAME; static const std::string SETTING_ID; static const std::string SETTING_NAME; @@ -359,7 +360,6 @@ class LLSettingsBase : LLSD mSettings; bool mIsValid; - LLAssetID mAssetID; LLSD cloneSettings() const; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 8498425f4e810ee33fed8673b2b494d8406b0838..457e5b747898a2a37644ac3e2be4e995beac5e94 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -408,7 +408,7 @@ LLSD LLSettingsDay::defaults() if (dfltsetting.size() == 0) { - dfltsetting[SETTING_NAME] = "_default_"; + dfltsetting[SETTING_NAME] = DEFAULT_SETTINGS_NAME; dfltsetting[SETTING_TYPE] = "daycycle"; LLSD frames(LLSD::emptyMap()); @@ -421,7 +421,7 @@ LLSD LLSettingsDay::defaults() F32 time = 0.0f; for (U32 i = 0; i < FRAME_COUNT; i++) { - std::string name("_default_"); + std::string name(DEFAULT_SETTINGS_NAME); name += ('a' + i); std::string water_frame_name("water:"); diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 8776f6725df35929963f7d0b2ee74788f298d36c..f7f5bb63b667e982b94155bc7a60edf72b1b5849 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -146,8 +146,6 @@ class LLSettingsDay : public LLSettingsBase LLSettingsBase::Seconds mLastUpdateTime; - void parseFromLLSD(LLSD &data); - static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); TrackBound_t getBoundingEntries(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index c0e60e88fe6cc598f87a5012a5640c2a46be2362..d4f2ca73893bbf770c8d8be8c0ee5effa7009a36 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -679,6 +679,8 @@ inline const LLColor4 linearColor4(const LLColor4 &a) linearColor.mV[1] = sRGBtoLinear(a.mV[1]); linearColor.mV[2] = sRGBtoLinear(a.mV[2]); linearColor.mV[3] = a.mV[3]; + + return linearColor; } #endif diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index bc5dd62f457f69e6c25d8b25fe043aa62e3b5d10..53b83a40d73305d2616fe484dc065ea03ffbf797 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1659,7 +1659,7 @@ BOOL LLLightParams::unpack(LLDataPacker &dp) { LLColor4U color; dp.unpackColor4U(color, "color"); - setColor(LLColor4(color)); + setLinearColor(LLColor4(color)); F32 radius; dp.unpackF32(radius, "radius"); @@ -1707,7 +1707,7 @@ LLSD LLLightParams::asLLSD() const { LLSD sd; - sd["color"] = ll_sd_from_color4(getColor()); + sd["color"] = ll_sd_from_color4(getLinearColor()); sd["radius"] = getRadius(); sd["falloff"] = getFalloff(); sd["cutoff"] = getCutoff(); @@ -1721,7 +1721,7 @@ bool LLLightParams::fromLLSD(LLSD& sd) w = "color"; if (sd.has(w)) { - setColor( ll_color4_from_sd(sd["color"]) ); + setLinearColor( ll_color4_from_sd(sd["color"]) ); } else goto fail; w = "radius"; if (sd.has(w)) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index ed89462e5a5dc25b9b6a91f86120006857484390..b1f8112223053cd708261abbe381733e44a9e29c 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -131,8 +131,8 @@ extern const F32 LIGHT_MAX_CUTOFF; class LLLightParams : public LLNetworkData { -protected: - LLColor4 mColor; // gamma corrected color (sRGB), alpha = intensity +private: + LLColor4 mColor; // linear color (not gamma corrected), alpha = intensity F32 mRadius; F32 mFalloff; F32 mCutoff; @@ -149,21 +149,22 @@ class LLLightParams : public LLNetworkData operator LLSD() const { return asLLSD(); } bool fromLLSD(LLSD& sd); - - // set the color + // set the color by gamma corrected color value // color - gamma corrected color value (directly taken from an on-screen color swatch) - void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); } + void setSRGBColor(const LLColor4& color) { setLinearColor(linearColor4(color)); } + + // set the color by linear color value + // color - linear color value (value as it appears in shaders) + void setLinearColor(const LLColor4& color) { mColor = color; mColor.clamp(); } void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); } void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); } void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); } - // same as getSRGBColor - LLColor4 getColor() const { return mColor; } - // get the sRGB (gamma corrected) color of this light - LLColor4 getSRGBColor() const { return mColor; } - // get the linear space color of this light - LLColor4 getLinearColor() const { return linearColor4(mColor); } - + // get the linear space color of this light. This value can be fed directly to shaders + LLColor4 getLinearColor() const { return mColor; } + // get the sRGB (gamma corrected) color of this light, this is the value that should be displayed in the UI + LLColor4 getSRGBColor() const { return srgbColor4(mColor); } + F32 getRadius() const { return mRadius; } F32 getFalloff() const { return mFalloff; } F32 getCutoff() const { return mCutoff; } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 91dd845e48cb8d993fd2b3b4b5ba58c2f9bf0b94..7ed74a70c6efa1cdd3f6e0c88d3d021047715f1a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -33,6 +33,7 @@ #include "llfeaturemanager.h" #include "lluictrlfactory.h" #include "lltexteditor.h" +#include "llenvironment.h" #include "llerrorcontrol.h" #include "lleventtimer.h" #include "llviewertexturelist.h" @@ -1914,6 +1915,12 @@ bool LLAppViewer::cleanup() // Store the time of our current logoff gSavedPerAccountSettings.setU32("LastLogoff", time_corrected()); + if (LLEnvironment::instanceExists()) + { + //Store environment settings if nessesary + LLEnvironment::getInstance()->saveToSettings(); + } + // Must do this after all panels have been deleted because panels that have persistent rects // save their rects on delete. gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b8c5648cca7f2ba26611ec91e076f885dea5739f..85fe2a7c95b6203c4b798ef18a41f8103b9b80f6 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -101,6 +101,8 @@ namespace const std::string LISTENER_NAME("LLEnvironmentSingleton"); const std::string PUMP_EXPERIENCE("experience_permission"); + const std::string LOCAL_ENV_STORAGE_FILE("local_environment_data.bin"); + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -849,6 +851,8 @@ void LLEnvironment::initSingleton() } LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); + + loadFromSettings(); } void LLEnvironment::cleanupSingleton() @@ -2448,7 +2452,6 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mBlenderSky(), mBlenderWater(), mInitialized(false), - mType(TYPE_INVALID), mSkyTrack(1), mEnv(env), mAnimateFlags(0) @@ -2467,7 +2470,6 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const environment->mBlenderSky = mBlenderSky; environment->mBlenderWater = mBlenderWater; environment->mInitialized = mInitialized; - environment->mType = mType; environment->mSkyTrack = mSkyTrack; environment->mAnimateFlags = mAnimateFlags; @@ -2491,7 +2493,6 @@ bool LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& d void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { - mType = TYPE_CYCLED; mInitialized = false; mAnimateFlags = 0; @@ -2512,7 +2513,6 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) { - mType = TYPE_FIXED; mInitialized = false; bool different_sky = mSky != psky; @@ -2532,7 +2532,6 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) { - mType = TYPE_FIXED; mInitialized = false; bool different_water = mWater != pwater; @@ -2554,7 +2553,6 @@ void LLEnvironment::DayInstance::initialize() void LLEnvironment::DayInstance::clear() { - mType = TYPE_INVALID; mDayCycle.reset(); mSky.reset(); mWater.reset(); @@ -2692,6 +2690,206 @@ void LLEnvironment::DayTransition::animate() }); } +void LLEnvironment::saveToSettings() +{ + std::string user_dir = gDirUtilp->getLindenUserDir(); + if (user_dir.empty()) + { + // not logged in + return; + } + bool has_data = false; + + if (gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin")) + { + DayInstance::ptr_t environment = getEnvironmentInstance(ENV_LOCAL); + if (environment) + { + // Environment is 'layered'. No data in ENV_LOCAL means we are using parcel/region + // Store local environment for next session + LLSD env_data; + + LLSettingsDay::ptr_t day = environment->getDayCycle(); + if (day) + { + const std::string name = day->getName(); + const LLUUID asset_id = day->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["day_id"] = asset_id; + env_data["day_length"] = LLSD::Integer(environment->getDayLength()); + env_data["day_offset"] = LLSD::Integer(environment->getDayOffset()); + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["day_llsd"] = day->getSettings(); + env_data["day_length"] = LLSD::Integer(environment->getDayLength()); + env_data["day_offset"] = LLSD::Integer(environment->getDayOffset()); + has_data = true; + } + } + + LLSettingsSky::ptr_t sky = environment->getSky(); + if ((environment->getFlags() & DayInstance::NO_ANIMATE_SKY) && sky) + { + const std::string name = sky->getName(); + const LLUUID asset_id = sky->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["sky_id"] = asset_id; + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["sky_llsd"] = sky->getSettings(); + has_data = true; + } + has_data = true; + } + + LLSettingsWater::ptr_t water = environment->getWater(); + if ((environment->getFlags() & DayInstance::NO_ANIMATE_WATER) && water) + { + const std::string name = water->getName(); + const LLUUID asset_id = water->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["water_id"] = asset_id; + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["water_llsd"] = water->getSettings(); + has_data = true; + } + } + + std::string user_filepath = user_dir + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE; + llofstream out(user_filepath.c_str(), std::ios_base::out | std::ios_base::binary); + if (out.good()) + { + LLSDSerialize::toBinary(env_data, out); + out.close(); + } + else + { + LL_WARNS("ENVIRONMENT") << "Unable to open " << user_filepath << " for output." << LL_ENDL; + } + } + } + + if (!has_data) + { + LLFile::remove(user_dir + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE, ENOENT); + } +} + +bool LLEnvironment::loadFromSettings() +{ + if (!gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin")) + { + return false; + } + + std::string user_path = gDirUtilp->getLindenUserDir(); + if (user_path.empty()) + { + LL_WARNS("ENVIRONMENT") << "Can't load previous environment, Environment was initialized before user logged in" << LL_ENDL; + return false; + } + std::string user_filepath(user_path + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE); + if (!gDirUtilp->fileExists(user_filepath)) + { + // No previous environment + return false; + } + + LLSD env_data; + llifstream file(user_filepath.c_str(), std::ios_base::in | std::ios_base::binary); + if (file.is_open()) + { + LLSDSerialize::fromBinary(env_data, file, LLSDSerialize::SIZE_UNLIMITED); + if (env_data.isUndefined()) + { + LL_WARNS("ENVIRONMENT") << "error loading " << user_filepath << LL_ENDL; + return false; + } + else + { + LL_INFOS("ENVIRONMENT") << "Loaded previous session environment from: " << user_filepath << LL_ENDL; + } + file.close(); + } + else + { + LL_INFOS("ENVIRONMENT") << "Unable to open previous session environment file " << user_filepath << LL_ENDL; + } + + if (!env_data.isMap() || env_data.emptyMap()) + { + LL_DEBUGS("ENVIRONMENT") << "Empty map loaded from: " << user_filepath << LL_ENDL; + return false; + } + + bool valid = false; + + if (env_data.has("day_id")) + { + S32 length = env_data["day_length"].asInteger(); + S32 offset = env_data["day_offset"].asInteger(); + setEnvironment(ENV_LOCAL, env_data["day_id"].asUUID(), LLSettingsDay::Seconds(length), LLSettingsDay::Seconds(offset)); + valid = true; + } + else if (env_data.has("day_llsd")) + { + S32 length = env_data["day_length"].asInteger(); + S32 offset = env_data["day_offset"].asInteger(); + LLSettingsDay::ptr_t day = std::make_shared<LLSettingsVODay>(env_data["day_llsd"]); + setEnvironment(ENV_LOCAL, day, LLSettingsDay::Seconds(length), LLSettingsDay::Seconds(offset)); + valid = true; + } + + if (env_data.has("sky_id")) + { + setEnvironment(ENV_LOCAL, env_data["sky_id"].asUUID()); + valid = true; + } + else if (env_data.has("sky_llsd")) + { + LLSettingsSky::ptr_t sky = std::make_shared<LLSettingsVOSky>(env_data["sky_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } + + if (env_data.has("water_id")) + { + setEnvironment(ENV_LOCAL, env_data["water_id"].asUUID()); + valid = true; + } + else if (env_data.has("water_llsd")) + { + LLSettingsWater::ptr_t sky = std::make_shared<LLSettingsVOWater>(env_data["water_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } + + if (valid) + { + updateEnvironment(TRANSITION_INSTANT, true); + } + return valid; +} + void LLEnvironment::saveBeaconsState() { if (mEditorCounter == 0) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 3ae1d37a8c757cd6d6cb6061c54fa3ac86d5fe7f..cf8231168f01b7067b46455180e24397ac91483c 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -169,6 +169,8 @@ class LLEnvironment : public LLSingleton<LLEnvironment> bool getIsSunUp() const; bool getIsMoonUp() const; + void saveToSettings(); + bool loadFromSettings(); void saveBeaconsState(); void revertBeaconsState(); @@ -232,13 +234,6 @@ class LLEnvironment : public LLSingleton<LLEnvironment> class DayInstance: public std::enable_shared_from_this<DayInstance> { public: - enum InstanceType_t - { - TYPE_INVALID, - TYPE_FIXED, - TYPE_CYCLED - }; - typedef std::shared_ptr<DayInstance> ptr_t; static const U32 NO_ANIMATE_SKY; @@ -282,6 +277,7 @@ class LLEnvironment : public LLSingleton<LLEnvironment> void setFlags(U32 flag) { mAnimateFlags |= flag; } void clearFlags(U32 flag) { mAnimateFlags &= ~flag; } + U32 getFlags() { return mAnimateFlags; } protected: @@ -291,7 +287,6 @@ class LLEnvironment : public LLSingleton<LLEnvironment> LLSettingsWater::ptr_t mWater; S32 mSkyTrack; - InstanceType_t mType; bool mInitialized; LLSettingsDay::Seconds mDayLength; diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index f57a54163dbfcca09a1026f45171e33956e6d6e4..ea22043de88a567dccdc38c440a595f7b041eff2 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -1715,6 +1715,7 @@ void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where, cons if (where == ACTION_APPLY_LOCAL) { + day->setName("Local"); // To distinguish and make sure there is a name. Safe, because this is a copy. LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day); } else if (where == ACTION_APPLY_PARCEL) diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 41d9a6d99b48dc4474b6d788292cff13bd0575bf..37e162b2493c60ddad7eb646ab1d70fceda33fed 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -580,6 +580,7 @@ void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where, con if (where == ACTION_APPLY_LOCAL) { + settings->setName("Local"); // To distinguish and make sure there is a name. Safe, because this is a copy. LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, settings); } else if (where == ACTION_APPLY_PARCEL) diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 2b531b6acc1a614f82aebf1fdcb2a4220c8cd42a..ae727e409f3457eae549d92c5d80f2b4a89883fc 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -300,7 +300,7 @@ void LLPanelVolume::getState( ) { LightColorSwatch->setEnabled( TRUE ); LightColorSwatch->setValid( TRUE ); - LightColorSwatch->set(volobjp->getLightBaseColor()); + LightColorSwatch->set(volobjp->getLightSRGBBaseColor()); } LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control"); @@ -328,7 +328,7 @@ void LLPanelVolume::getState( ) getChild<LLUICtrl>("Light Focus")->setValue(params.mV[1]); getChild<LLUICtrl>("Light Ambiance")->setValue(params.mV[2]); - mLightSavedColor = volobjp->getLightColor(); + mLightSavedColor = volobjp->getLightSRGBColor(); } else { @@ -807,7 +807,7 @@ void LLPanelVolume::onLightSelectColor(const LLSD& data) { LLColor4 clr = LightColorSwatch->get(); LLColor3 clr3( clr ); - volobjp->setLightColor(clr3); + volobjp->setLightSRGBColor(clr3); mLightSavedColor = clr; } } @@ -881,7 +881,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) if(LightColorSwatch) { LLColor4 clr = LightColorSwatch->get(); - volobjp->setLightColor(LLColor3(clr)); + volobjp->setLightSRGBColor(LLColor3(clr)); } LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control"); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 107b65b7db3f0293043142ee483c75d1fc20b5c0..5f752e58031a6da560de3593df9101e49e2e4528 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -514,7 +514,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { default_settings = LLSettingsSky::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); LLSD results = LLSettingsBase::settingValidation(default_settings, validations); @@ -838,7 +838,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { default_settings = LLSettingsWater::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); LLSD results = LLSettingsWater::settingValidation(default_settings, validations); @@ -1166,7 +1166,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() if (!default_settings.size()) { default_settings = LLSettingsDay::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(default_settings, validations); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 4e32f0a7b5b7c735a9295efb3ddbe9ddacff0bec..d8fcee801b1c375b08c0d5d5889cf393dec0c5b2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3997,7 +3997,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, F32 scale = vovolume->getLightRadius(); gGL.scalef(scale, scale, scale); - LLColor4 color(vovolume->getLightColor(), .5f); + LLColor4 color(vovolume->getLightSRGBColor(), .5f); gGL.color4fv(color.mV); //F32 pixel_area = 100000.f; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index aa42ca6a29eb089eda5daf69e79b9b48e84d81eb..94b2bed83a50fa60107c14e95e4e33b96fc0c7dd 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3192,14 +3192,19 @@ void LLVOVolume::setIsLight(BOOL is_light) } } -void LLVOVolume::setLightColor(const LLColor3& color) +void LLVOVolume::setLightSRGBColor(const LLColor3& color) +{ + setLightLinearColor(linearColor3(color)); +} + +void LLVOVolume::setLightLinearColor(const LLColor3& color) { LLLightParams *param_block = (LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); if (param_block) { - if (param_block->getColor() != color) + if (param_block->getLinearColor() != color) { - param_block->setColor(LLColor4(color, param_block->getColor().mV[3])); + param_block->setLinearColor(LLColor4(color, param_block->getLinearColor().mV[3])); parameterChanged(LLNetworkData::PARAMS_LIGHT, true); gPipeline.markTextured(mDrawable); mFaceMappingChanged = TRUE; @@ -3212,9 +3217,9 @@ void LLVOVolume::setLightIntensity(F32 intensity) LLLightParams *param_block = (LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); if (param_block) { - if (param_block->getColor().mV[3] != intensity) + if (param_block->getLinearColor().mV[3] != intensity) { - param_block->setColor(LLColor4(LLColor3(param_block->getColor()), intensity)); + param_block->setLinearColor(LLColor4(LLColor3(param_block->getLinearColor()), intensity)); parameterChanged(LLNetworkData::PARAMS_LIGHT, true); } } @@ -3266,12 +3271,17 @@ BOOL LLVOVolume::getIsLight() const return getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT); } -LLColor3 LLVOVolume::getLightBaseColor() const +LLColor3 LLVOVolume::getLightSRGBBaseColor() const +{ + return srgbColor3(getLightLinearColor()); +} + +LLColor3 LLVOVolume::getLightLinearBaseColor() const { const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); if (param_block) { - return LLColor3(param_block->getColor()); + return LLColor3(param_block->getLinearColor()); } else { @@ -3280,18 +3290,11 @@ LLColor3 LLVOVolume::getLightBaseColor() const } LLColor3 LLVOVolume::getLightLinearColor() const -{ - LLColor3 ret = getLightSRGBColor(); - ret = linearColor3(ret); - return ret; -} - -LLColor3 LLVOVolume::getLightSRGBColor() const { const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); if (param_block) { - return LLColor3(param_block->getSRGBColor()) * param_block->getSRGBColor().mV[3]; + return LLColor3(param_block->getLinearColor()) * param_block->getLinearColor().mV[3]; } else { @@ -3299,6 +3302,13 @@ LLColor3 LLVOVolume::getLightSRGBColor() const } } +LLColor3 LLVOVolume::getLightSRGBColor() const +{ + LLColor3 ret = getLightLinearColor(); + ret = srgbColor3(ret); + return ret; +} + LLUUID LLVOVolume::getLightTextureID() const { if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) @@ -3390,7 +3400,7 @@ F32 LLVOVolume::getLightIntensity() const const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); if (param_block) { - return param_block->getColor().mV[3]; + return param_block->getLinearColor().mV[3]; } else { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index decc195208154179821fb54941fd2e8540829f74..0e1d2cf7e4dbb786f29245182451e313e7045057 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -246,7 +246,11 @@ class LLVOVolume : public LLViewerObject // For Lights void setIsLight(BOOL is_light); - void setLightColor(const LLColor3& color); + //set the gamma-corrected (sRGB) color of this light + void setLightSRGBColor(const LLColor3& color); + //set the linear color of this light + void setLightLinearColor(const LLColor3& color); + void setLightIntensity(F32 intensity); void setLightRadius(F32 radius); void setLightFalloff(F32 falloff); @@ -258,12 +262,13 @@ class LLVOVolume : public LLViewerObject // Get the light color in sRGB color space NOT scaled by intensity. - LLColor3 getLightBaseColor() const; - - //same as getLightSRGBColor() - LLColor3 getLightColor() const { return getLightSRGBColor(); } + LLColor3 getLightSRGBBaseColor() const; - // Same as linearColor3(getLightSRGBColor) + // Get the light color in linear color space NOT scaled by intensity. + LLColor3 getLightLinearBaseColor() const; + + // Get the light color in linear color space scaled by intensity + // this is the value that should be fed into shaders LLColor3 getLightLinearColor() const; // Get the light color in sRGB color space scaled by intensity. diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index b3ed7e95b21f881888211b2ecc07a51b420ba575..c35746d37d25482bde9228b88207d25f317262ef 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6369,8 +6369,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) mLightMovingMask |= (1<<cur_light); } - //NOTE: for legacy reasons, send sRGB color to light shader for both deferred and non-deferred path - LLColor4 light_color = light->getLightColor(); + //send linear light color to shader + LLColor4 light_color = light->getLightLinearColor(); light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -8814,8 +8814,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) const F32* c = center.getF32ptr(); F32 s = volume->getLightRadius()*1.5f; - //NOTE: for legacy reasons, send sRGB color to light shader - LLColor3 col = volume->getLightColor(); + //send light color to shader in linear space + LLColor3 col = volume->getLightLinearColor(); if (col.magVecSquared() < 0.001f) { @@ -8907,8 +8907,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) setupSpotLight(gDeferredSpotLightProgram, drawablep); - //NOTE: for legacy reasons, send sRGB color to light shader - LLColor3 col = volume->getLightColor(); + //send light color to shader in linear space + LLColor3 col = volume->getLightLinearColor(); gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8997,8 +8997,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); - //NOTE: for legacy reasons, send sRGB color to light shader - LLColor3 col = volume->getLightColor(); + //send light color to shader in linear space + LLColor3 col = volume->getLightLinearColor(); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final);