diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index 24e808c92af0911073a471c51e67192c2bc51eb3..db30a25a4cf69da442b3000cd1b30f8d7f4493ff 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -610,10 +610,12 @@ void LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& t
 
     if (mTimeSpent > mBlendSpan)
     {
+        mIgnoreTimeDelta = false;
         triggerComplete();
         return;
     }
-    if (mTimeDeltaPassed < mTimeDeltaThreshold)
+
+    if ((mTimeDeltaPassed < mTimeDeltaThreshold) && (!mIgnoreTimeDelta))
     {
         return;
     }
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index f2fa78e41fb9af7fd987f19602cda14b033cb1c1..81158d64a7b23da4486f08fc6b5f26498c1b3408 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -387,7 +387,8 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
         mLastUpdate(0.0f),
         mTimeSpent(0.0f),
         mTimeDeltaThreshold(0.0f),
-        mTimeDeltaPassed(0.0f)
+        mTimeDeltaPassed(0.0f),
+        mIgnoreTimeDelta(false)
     {
         mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch());
         mLastUpdate = mTimeStart;
@@ -421,6 +422,9 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
         return mTimeDeltaThreshold;
     }
 
+    inline void setIgnoreTimeDeltaThreshold(bool val) { mIgnoreTimeDelta = val; }
+    inline bool getIgnoreTimeDeltaThreshold() const { return mIgnoreTimeDelta; }
+
 protected:
     LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const;
 
@@ -430,6 +434,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
     LLSettingsBase::Seconds mTimeStart;
     LLSettingsBase::Seconds mTimeDeltaThreshold;
     LLSettingsBase::Seconds mTimeDeltaPassed;
+    bool                    mIgnoreTimeDelta;
 };
 
 
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 938cf857eeb155970798a3abfb608391cd924189..e3a030225d94953fe81b6e2f0c8f99923823c56f 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -164,7 +164,7 @@ namespace
                 return;
             }
 
-            mTrackTransitionStart = mTarget->buildDerivedClone();
+            LLSettingsBase::ptr_t pstartsetting = mTarget->buildDerivedClone();
             mTrackNo = use_trackno;
 
             LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE;
@@ -177,7 +177,11 @@ namespace
             LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan);
             pendsetting->blend((*bounds.second).second, blendf);
 
-            reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE);
+//          pstartsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(0.0, 1.0, 0.0));
+//          pendsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(1.0, 0.0, 0.0));
+
+            setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold.
+            reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE);
         }
 
     protected:
@@ -185,12 +189,12 @@ namespace
         {
             if (trackno == 0)
             {   // We are dealing with the water track.  There is only ever one.
-                return 0;
+                return trackno;
             }
 
-            for (S32 test = trackno; test == 0; --test)
+            for (S32 test = trackno; test != 0; --test)
             {   // Find the track below the requested one with data.
-                LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(mTrackNo);
+                LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(test);
 
                 if (!track.empty())
                     return test;
@@ -226,7 +230,6 @@ namespace
         S32                         mTrackNo;
         LLSettingsBase::Seconds     mCycleLength;
         LLSettingsBase::Seconds     mCycleOffset;
-        LLSettingsBase::ptr_t       mTrackTransitionStart;
 
         void onFinishedSpan()
         {
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 52b5b1a3a22be598e5c8e81d735f1b3ed1aab25f..7c1fda46ffae96303018cf2b895d0671916cb4cf 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -633,12 +633,14 @@ bool LLVOSky::updateSky()
 		direction.normalize();
 		const F32 dot_lighting = direction * mLastLightingDirection;
 
+        //_WARNS("LAPRAS") << " <" << direction.getValue() << "> dot <" << mLastLightingDirection << "> = " << dot_lighting << " (threshold is " << LIGHT_DIRECTION_THRESHOLD << ")" << LL_ENDL;
+
 		LLColor3 delta_color;
 		delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0],
 							mLastTotalAmbient.mV[1] - total_ambient.mV[1],
                             mLastTotalAmbient.mV[2] - total_ambient.mV[2]);
 
-        bool light_direction_changed = (dot_lighting >= LIGHT_DIRECTION_THRESHOLD);
+        bool light_direction_changed = (dot_lighting < LIGHT_DIRECTION_THRESHOLD);
         bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD);
 
         mForceUpdate = mForceUpdate || light_direction_changed;