diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-04-25 09:13:23 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-04-25 09:13:23 -0400 |
commit | f162693a23fe5cfda8dab3857718624033812d30 (patch) | |
tree | 0768f9ea570b248b48e4caa33103e3d55c625466 /indra/newview/llenvironment.cpp | |
parent | d8931c9269a90cd01f6f6ff4de83b8fb41df11d3 (diff) | |
parent | d98fc504a1d4bc292ba86acdda053c8b4598a193 (diff) |
Merge Maint YZ branch 'main' into DRTVWR-588-cleanup-timers
Diffstat (limited to 'indra/newview/llenvironment.cpp')
-rw-r--r-- | indra/newview/llenvironment.cpp | 114 |
1 files changed, 92 insertions, 22 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 05c7decfbd..60c2682078 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -168,6 +168,9 @@ namespace // Find normalized track position of given time along full length of cycle inline LLSettingsBase::TrackPosition convert_time_to_position(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len) { + // early out to avoid divide by zero. if len is zero then jump to end position + if (len == 0.f) return 1.f; + LLSettingsBase::TrackPosition position = LLSettingsBase::TrackPosition(fmod((F64)time, (F64)len) / (F64)len); return llclamp(position, 0.0f, 1.0f); } @@ -812,7 +815,8 @@ const F64Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F64Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("6c83e853-e7f8-cad7-8ee6-5f31c453721c"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("c46226b4-0e43-5a56-9708-d27ca1df3292"); +const LLUUID LLEnvironment::KNOWN_SKY_LEGACY_MIDDAY("cef49723-0292-af49-9b14-9598a616b8a3"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); @@ -891,6 +895,14 @@ void LLEnvironment::initSingleton() gGenericDispatcher.addHandler(MESSAGE_PUSHENVIRONMENT, &environment_push_dispatch_handler); } + gSavedSettings.getControl("RenderSkyAutoAdjustProbeAmbiance")->getSignal()->connect( + [](LLControlVariable*, const LLSD& new_val, const LLSD& old_val) + { + LLSettingsSky::sAutoAdjustProbeAmbiance = new_val.asReal(); + } + ); + LLSettingsSky::sAutoAdjustProbeAmbiance = gSavedSettings.getF32("RenderSkyAutoAdjustProbeAmbiance"); + LLEventPumps::instance().obtain(PUMP_EXPERIENCE).stopListening(LISTENER_NAME); LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); } @@ -1178,13 +1190,14 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm return; } - DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + bool reset_probes = false; + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); if (fixed.first) { logEnvironment(env, fixed.first, env_version); - environment->setSky(fixed.first); + reset_probes = environment->setSky(fixed.first); environment->setFlags(DayInstance::NO_ANIMATE_SKY); } else if (!environment->getSky()) @@ -1195,7 +1208,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm // and then add water/sky on top // This looks like it will result in sky using single keyframe instead of whole day if day is present // when setting static water without static sky - environment->setSky(mCurrentEnvironment->getSky()); + reset_probes = environment->setSky(mCurrentEnvironment->getSky()); environment->setFlags(DayInstance::NO_ANIMATE_SKY); } else @@ -1213,7 +1226,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm if (substitute && substitute->getSky()) { - environment->setSky(substitute->getSky()); + reset_probes = environment->setSky(substitute->getSky()); environment->setFlags(DayInstance::NO_ANIMATE_SKY); } else @@ -1265,6 +1278,11 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm } } + if (reset_probes) + { // the sky changed in a way that merits a reset of reflection probes + gPipeline.mReflectionMapManager.reset(); + } + if (!mSignalEnvChanged.empty()) mSignalEnvChanged(env, env_version); } @@ -1629,28 +1647,31 @@ LLVector4 LLEnvironment::getRotatedLightNorm() const return toLightNorm(light_direction); } +extern BOOL gCubeSnapshot; + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; //LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); //F32Seconds now(LLDate::now().secondsSinceEpoch()); - static LLFrameTimer timer; - - F32Seconds delta(timer.getElapsedTimeAndResetF32()); - + if (!gCubeSnapshot) { - DayInstance::ptr_t keeper = mCurrentEnvironment; - // make sure the current environment does not go away until applyTimeDelta is done. - mCurrentEnvironment->applyTimeDelta(delta); + static LLFrameTimer timer; - } - // update clouds, sun, and general - updateCloudScroll(); + F32Seconds delta(timer.getElapsedTimeAndResetF32()); - // cache this for use in rotating the rotated light vec for shader param updates later... - mLastCamYaw = cam->getYaw() + SUN_DELTA_YAW; + { + DayInstance::ptr_t keeper = mCurrentEnvironment; + // make sure the current environment does not go away until applyTimeDelta is done. + mCurrentEnvironment->applyTimeDelta(delta); - stop_glerror(); + } + // update clouds, sun, and general + updateCloudScroll(); + + // cache this for use in rotating the rotated light vec for shader param updates later... + mLastCamYaw = cam->getYaw() + SUN_DELTA_YAW; + } updateSettingsUniforms(); @@ -1681,8 +1702,16 @@ void LLEnvironment::updateCloudScroll() if (mCurrentEnvironment->getSky() && !mCloudScrollPaused) { - LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate()) / 100.0; - mCloudScrollDelta += cloud_delta; + LLVector2 rate = mCurrentEnvironment->getSky()->getCloudScrollRate(); + if (rate.isExactlyZero()) + { + mCloudScrollDelta.setZero(); + } + else + { + LLVector2 cloud_delta = static_cast<F32>(delta_t) * (mCurrentEnvironment->getSky()->getCloudScrollRate()) / 100.0; + mCloudScrollDelta += cloud_delta; + } } } @@ -1739,8 +1768,30 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con case LLSD::TypeArray: { LLVector4 vect4(value); + + if (gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass()) + { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color + auto max_vec = [](LLVector4 col) + { + LLColor3 color(col); + F32 h, s, l; + color.calcHSL(&h, &s, &l); + + col.mV[0] = col.mV[1] = col.mV[2] = l; + return col; + }; + + switch (it.second.getShaderKey()) + { + case LLShaderMgr::BLUE_HORIZON: + case LLShaderMgr::BLUE_DENSITY: + vect4 = max_vec(vect4); + break; + } + } + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv(it.second.getShaderKey(), vect4 ); + shader->uniform3fv(it.second.getShaderKey(), LLVector3(vect4.mV) ); break; } @@ -2741,10 +2792,12 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett } -void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) +bool LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) { mInitialized = false; + bool changed = psky == nullptr || mSky == nullptr || mSky->getHash() != psky->getHash(); + bool different_sky = mSky != psky; mSky = psky; @@ -2758,6 +2811,8 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } + + return changed; } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) @@ -2907,12 +2962,20 @@ void LLEnvironment::DayTransition::animate() setWater(mNextInstance->getWater()); }); + + // pause probe updates and reset reflection maps on sky change + gPipeline.mReflectionMapManager.pause(); + gPipeline.mReflectionMapManager.reset(); + mSky = mStartSky->buildClone(); mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); mBlenderSky->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { mBlenderSky.reset(); + // resume reflection probe updates + gPipeline.mReflectionMapManager.resume(); + if (!mBlenderSky && !mBlenderWater) LLEnvironment::instance().mCurrentEnvironment = mNextInstance; else @@ -3503,12 +3566,19 @@ namespace LLSettingsSky::ptr_t target_sky(start_sky->buildClone()); mInjectedSky->setSource(target_sky); + // clear reflection probes and pause updates during sky change + gPipeline.mReflectionMapManager.pause(); + gPipeline.mReflectionMapManager.reset(); + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(target_sky, start_sky, psky, transition); mBlenderSky->setOnFinished( [this, psky](LLSettingsBlender::ptr_t blender) { mBlenderSky.reset(); mInjectedSky->setSource(psky); + + // resume updating reflection probes when done animating sky + gPipeline.mReflectionMapManager.resume(); setSky(mInjectedSky); if (!mBlenderWater && (countExperiencesActive() == 0)) { |