From 513d5dcca7ae114f9de841543c9e32f706e13b4e Mon Sep 17 00:00:00 2001
From: Ptolemy <ptolemy@lindenlab.com>
Date: Thu, 4 Jun 2020 11:47:55 -0700
Subject: [PATCH] SL-13084: Fix clouds flipped along East/West axis to match
 texture preview Cloud Image and direction to match Cloud Scroll

---
 .../app_settings/shaders/class1/deferred/cloudsV.glsl |  8 +++++++-
 .../shaders/class2/windlight/cloudsV.glsl             |  7 ++++++-
 indra/newview/llsettingsvo.cpp                        | 11 ++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
index caa4fe1f65c..7ea807804a3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -78,7 +78,13 @@ void main()
 	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 
 	// Texture coords
-	vary_texcoord0 = texcoord0;
+    // SL-13084 EEP added support for custom cloud textures -- flip them horizontally to match the preview of Clouds > Cloud Scroll
+    // Keep in Sync!
+    // * indra\newview\llsettingsvo.cpp
+    // * indra\newview\app_settings\shaders\class2\windlight\cloudsV.glsl
+    // * indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl
+	vary_texcoord0 = vec2( -texcoord0.x, texcoord0.y );
+
 	vary_texcoord0.xy -= 0.5;
 	vary_texcoord0.xy /= cloud_scale;
 	vary_texcoord0.xy += 0.5;
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index 2c1475d5478..fdd90eb0049 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -72,7 +72,12 @@ void main()
 	// World / view / projection
 	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 
-	vary_texcoord0 = texcoord0;
+    // SL-13084 EEP added support for custom cloud textures -- flip them horizontally to match the preview of Clouds > Cloud Scroll
+    // Keep in Sync!
+    // * indra\newview\llsettingsvo.cpp
+    // * indra\newview\app_settings\shaders\class2\windlight\cloudsV.glsl
+    // * indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl
+	vary_texcoord0 = vec2( -texcoord0.x, texcoord0.y );
 
 	// Get relative position
 	vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index c72a0706cdc..5a4427a7b7d 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -678,8 +678,17 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
 	{
     shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV);        
 
+    // Legacy? SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate")
     LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]);
-    vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta());
+    LLVector4 cloud_scroll( LLEnvironment::instance().getCloudScrollDelta() );
+
+    // SL-13084 EEP added support for custom cloud textures -- flip them horizontally to match the preview of Clouds > Cloud Scroll
+    // Keep in Sync!
+    // * indra\newview\llsettingsvo.cpp
+    // * indra\newview\app_settings\shaders\class2\windlight\cloudsV.glsl
+    // * indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl
+    cloud_scroll[0] = -cloud_scroll[0];
+    vect_c_p_d1 += cloud_scroll;
     shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV);
 
     LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
-- 
GitLab