From 6494eed242b1cf64160e379c6d40df333deae23a Mon Sep 17 00:00:00 2001
From: Cosmic Linden <cosmic@lindenlab.com>
Date: Thu, 23 Feb 2023 10:58:39 -0800
Subject: SL-19228: Fix GLTF texture transform rotation and add UV debug (PBR
 only). See textureUtilV.glsl for UV coordinate comments

---
 indra/newview/app_settings/settings.xml            | 12 +++++
 .../shaders/class1/deferred/pbralphaV.glsl         | 29 +++++++++---
 .../shaders/class1/deferred/pbrglowV.glsl          |  6 ++-
 .../shaders/class1/deferred/pbropaqueF.glsl        | 14 ++++++
 .../shaders/class1/deferred/pbropaqueV.glsl        | 30 +++++++++---
 .../shaders/class1/deferred/textureUtilV.glsl      | 55 ++++++++++++++++++++++
 .../shaders/class2/deferred/pbralphaF.glsl         | 14 ++++++
 indra/newview/llviewercontrol.cpp                  |  1 +
 indra/newview/llviewershadermgr.cpp                | 18 +++++++
 indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++
 10 files changed, 174 insertions(+), 15 deletions(-)
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 304932dd1a..ed6269df65 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9727,6 +9727,18 @@
     <integer>1</integer>
   </map>
 
+  <key>RenderDebugTexcoord</key>
+  <map>
+    <key>Comment</key>
+    <string>Enables a colored debug overlay on meshes to show UV coordinates. Not all meshes support this setting.</string>
+    <key>Persist</key>
+    <integer>0</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>0</integer>
+  </map>
+
   <key>RenderDeferredBlurLight</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
index da27be6e7f..ee44ad874c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
@@ -64,6 +64,9 @@ out vec2 basecolor_texcoord;
 out vec2 normal_texcoord;
 out vec2 metallic_roughness_texcoord;
 out vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+out vec2 original_texcoord;
+#endif
 
 out vec4 vertex_color;
 
@@ -71,6 +74,8 @@ out vec3 vary_tangent;
 flat out float vary_sign;
 out vec3 vary_normal;
 
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform);
+
 
 void main()
 {
@@ -90,10 +95,13 @@ void main()
     vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip);
 #endif
 
-	basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy;
-	normal_texcoord = (texture_matrix0 * vec4(texture_normal_matrix * vec3(texcoord0,1), 1)).xy;
-	metallic_roughness_texcoord = (texture_matrix0 * vec4(texture_metallic_roughness_matrix * vec3(texcoord0,1), 1)).xy;
-	emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy;
+	basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
+	normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0);
+	metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0);
+	emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
+#if DEBUG_TEXCOORD
+    original_texcoord = texcoord0;
+#endif
 
 #ifdef HAS_SKIN
 	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz;
@@ -135,9 +143,15 @@ in vec2 texcoord0;
 
 out vec2 basecolor_texcoord;
 out vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+out vec2 original_texcoord;
+#endif
 
 out vec4 vertex_color;
 
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform);
+
+
 void main()
 {
 	//transform vertex
@@ -145,8 +159,11 @@ void main()
     gl_Position = vert;
     vary_position = vert.xyz;
 
-	basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy;
-	emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy;
+	basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
+	emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
+#if DEBUG_TEXCOORD
+    original_texcoord = texcoord0;
+#endif
 
 	vertex_color = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl
index 75b24336c5..bcad1c1ceb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl
@@ -47,6 +47,8 @@ out vec2 emissive_texcoord;
  
 out vec4 vertex_emissive;
 
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform);
+
 void main()
 {
 #ifdef HAS_SKIN
@@ -62,8 +64,8 @@ void main()
     gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
 #endif
 
-    basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy;
-    emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy;
+    basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
+    emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
 
     vertex_emissive = emissive;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
index c4c5a7872b..fd2aa6eb54 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
@@ -51,6 +51,9 @@ in vec2 basecolor_texcoord;
 in vec2 normal_texcoord;
 in vec2 metallic_roughness_texcoord;
 in vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+in vec2 original_texcoord;
+#endif
 
 uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff()
 
@@ -69,6 +72,10 @@ void main()
     }
 
     vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb);
+#if DEBUG_TEXCOORD
+    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
+    col = texcoord_color;
+#endif
 
     // from mikktspace.com
     vec3 vNt = texture2D(bumpMap, normal_texcoord.xy).xyz*2.0-1.0;
@@ -123,6 +130,9 @@ in vec4 vertex_color;
 
 in vec2 basecolor_texcoord;
 in vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+in vec2 original_texcoord;
+#endif
 
 uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff()
 
@@ -138,6 +148,10 @@ void main()
     }
 
     vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb);
+#if DEBUG_TEXCOORD
+    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
+    col = texcoord_color;
+#endif
 
     vec3 emissive = emissiveColor;
     emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
index 8320640e42..aeb6b85e12 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
@@ -53,6 +53,9 @@ out vec2 basecolor_texcoord;
 out vec2 normal_texcoord;
 out vec2 metallic_roughness_texcoord;
 out vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+out vec2 original_texcoord;
+#endif
  
 out vec4 vertex_color;
 
@@ -60,6 +63,8 @@ out vec3 vary_tangent;
 flat out float vary_sign;
 out vec3 vary_normal;
 
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform);
+
 void main()
 {
 #ifdef HAS_SKIN
@@ -75,11 +80,14 @@ void main()
 	//transform vertex
 	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
 #endif
-	
-	basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy;
-	normal_texcoord = (texture_matrix0 * vec4(texture_normal_matrix * vec3(texcoord0,1), 1)).xy;
-	metallic_roughness_texcoord = (texture_matrix0 * vec4(texture_metallic_roughness_matrix * vec3(texcoord0,1), 1)).xy;
-	emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy;
+
+    basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
+    normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0);
+    metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0);
+    emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
+#if DEBUG_TEXCOORD
+    original_texcoord = texcoord0;
+#endif
 
 #ifdef HAS_SKIN
 	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz;
@@ -115,16 +123,24 @@ in vec2 texcoord0;
 
 out vec2 basecolor_texcoord;
 out vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+out vec2 original_texcoord;
+#endif
  
 out vec4 vertex_color;
 
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform);
+
 void main()
 {
     //transform vertex
     gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
 
-    basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy;
-    emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy;
+    basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
+    emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
+#if DEBUG_TEXCOORD
+    original_texcoord = texcoord0;
+#endif
 
     vertex_color = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl
new file mode 100644
index 0000000000..b146c665f9
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl
@@ -0,0 +1,55 @@
+/** 
+ * @file class1/deferred/textureUtilV.glsl
+ *
+ * $LicenseInfo:firstyear=2023&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2023, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+// vertex_texcoord - The UV texture coordinates sampled from the vertex at
+//     runtime. Per SL convention, this is in a right-handed UV coordinate
+//     system. Collada models also have right-handed UVs.
+// khr_gltf_transform - The texture transform matrix as defined in the
+//     KHR_texture_transform GLTF extension spec. It assumes a left-handed UV
+//     coordinate system. GLTF models also have left-handed UVs.
+// sl_animation_transform - The texture transform matrix for texture
+//     animations, available through LSL script functions such as
+//     LlSetTextureAnim. It assumes a right-handed UV coordinate system.
+// texcoord - The final texcoord to use for image sampling
+vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform)
+{
+    vec2 texcoord = vertex_texcoord;
+
+    // Convert to left-handed coordinate system. The offset of 1 is necessary
+    // for rotations to be applied correctly.
+    // In the future, we could bake this coordinate conversion into the uniform
+    // that khr_gltf_transform comes from, since it's applied immediately
+    // before.
+    texcoord.y = 1.0 - texcoord.y;
+    texcoord = (khr_gltf_transform * vec3(texcoord, 1.0)).xy;
+    // Convert back to right-handed coordinate system
+    texcoord.y = 1.0 - texcoord.y;
+    texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy;
+
+    // To make things more confusing, all SL image assets are upside-down
+    // We may need an additional sign flip here when we implement a Vulkan backend
+
+    return texcoord;
+}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 35ccc65a8e..47d6c5e195 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -57,6 +57,9 @@ in vec2 basecolor_texcoord;
 in vec2 normal_texcoord;
 in vec2 metallic_roughness_texcoord;
 in vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+in vec2 original_texcoord;
+#endif
 
 in vec4 vertex_color;
 
@@ -173,6 +176,10 @@ void main()
 #endif
 
     vec3 col = vertex_color.rgb * basecolor.rgb;
+#if DEBUG_TEXCOORD
+    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
+    col = texcoord_color;
+#endif
 
     vec3 vNt = texture(bumpMap, normal_texcoord.xy).xyz*2.0-1.0;
     float sign = vary_sign;
@@ -265,6 +272,9 @@ in vec3 vary_position;
 
 in vec2 basecolor_texcoord;
 in vec2 emissive_texcoord;
+#if DEBUG_TEXCOORD
+in vec2 original_texcoord;
+#endif
 
 in vec4 vertex_color;
 
@@ -292,6 +302,10 @@ void main()
 #endif
 
     color = vertex_color.rgb * basecolor.rgb;
+#if DEBUG_TEXCOORD
+    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
+    color = texcoord_color;
+#endif
 
     // emissiveColor is the emissive color factor from GLTF and is already in linear space
     vec3 colorEmissive = emissiveColor;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 341f94241a..6426512d5f 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -682,6 +682,7 @@ void settings_setup_listeners()
     setting_setup_signal_listener(gSavedSettings, "RenderScreenSpaceReflections", handleReflectionProbeDetailChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderShadowDetail", handleSetShaderChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderDeferredSSAO", handleSetShaderChanged);
+	setting_setup_signal_listener(gSavedSettings, "RenderDebugTexcoord", handleSetShaderChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderPerformanceTest", handleRenderPerfTestChanged);
 	setting_setup_signal_listener(gSavedSettings, "ChatFontSize", handleChatFontSizeChanged);
 	setting_setup_signal_listener(gSavedSettings, "ChatPersistTime", handleChatPersistTimeChanged);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5d3da55499..b866cedaaa 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -653,6 +653,7 @@ std::string LLViewerShaderMgr::loadBasicShaders()
     shaders.push_back( make_pair( "environment/srgbF.glsl",                 1 ) );
 	shaders.push_back( make_pair( "avatar/avatarSkinV.glsl",                1 ) );
 	shaders.push_back( make_pair( "avatar/objectSkinV.glsl",                1 ) );
+    shaders.push_back( make_pair( "deferred/textureUtilV.glsl",             1 ) );
 	if (gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)
 	{
 		shaders.push_back( make_pair( "objects/indexedTextureV.glsl",           1 ) );
@@ -1319,6 +1320,11 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER));
         gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER));
         gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+        gDeferredPBROpaqueProgram.clearPermutations();
+        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
+        {
+            gDeferredPBROpaqueProgram.addPermutation("DEBUG_TEXCOORD", "1");
+        }
         
         success = make_rigged_variant(gDeferredPBROpaqueProgram, gDeferredSkinnedPBROpaqueProgram);
         if (success)
@@ -1355,6 +1361,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gHUDPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         gHUDPBROpaqueProgram.clearPermutations();
         gHUDPBROpaqueProgram.addPermutation("IS_HUD", "1");
+        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
+        {
+            gHUDPBROpaqueProgram.addPermutation("DEBUG_TEXCOORD", "1");
+        }
 
         success = gHUDPBROpaqueProgram.createShader(NULL, NULL);
  
@@ -1398,6 +1408,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         {
             shader->addPermutation("HAS_SUN_SHADOW", "1");
         }
+        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
+        {
+            shader->addPermutation("DEBUG_TEXCOORD", "1");
+        }
 
         shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         success = make_rigged_variant(*shader, gDeferredSkinnedPBRAlphaProgram);
@@ -1430,6 +1444,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         shader->clearPermutations();
 
         shader->addPermutation("IS_HUD", "1");
+        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
+        {
+            shader->addPermutation("DEBUG_TEXCOORD", "1");
+        }
 
         shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         success = shader->createShader(NULL, NULL);
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index b8515cb096..04dde696d5 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2843,6 +2843,16 @@ function="World.EnvPreset"
            function="Advanced.ToggleInfoDisplay"
            parameter="texture anim" />
         </menu_item_check>
+        <menu_item_check
+         label="Texture Coordinates"
+            name="RenderDebugTexcoord">
+            <menu_item_check.on_check
+             function="CheckControl"
+             parameter="RenderDebugTexcoord" />
+            <menu_item_check.on_click
+             function="ToggleControl"
+             parameter="RenderDebugTexcoord" />
+        </menu_item_check>
         <menu_item_check
          label="Texture Priority"
          name="Texture Priority">
-- 
cgit v1.2.3


From a7ecfc9b1907d6ecd5fe50aeb1c41e38540b2665 Mon Sep 17 00:00:00 2001
From: Cosmic Linden <cosmic@lindenlab.com>
Date: Fri, 24 Feb 2023 09:27:19 -0800
Subject: SL-19228: Remove DEBUG_TEXCOORD

---
 indra/newview/app_settings/settings.xml                  | 12 ------------
 .../app_settings/shaders/class1/deferred/pbralphaV.glsl  | 12 ------------
 .../app_settings/shaders/class1/deferred/pbropaqueF.glsl | 14 --------------
 .../app_settings/shaders/class1/deferred/pbropaqueV.glsl | 12 ------------
 .../app_settings/shaders/class2/deferred/pbralphaF.glsl  | 14 --------------
 indra/newview/llviewercontrol.cpp                        |  1 -
 indra/newview/llviewershadermgr.cpp                      | 16 ----------------
 indra/newview/skins/default/xui/en/menu_viewer.xml       | 10 ----------
 8 files changed, 91 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ed6269df65..304932dd1a 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9727,18 +9727,6 @@
     <integer>1</integer>
   </map>
 
-  <key>RenderDebugTexcoord</key>
-  <map>
-    <key>Comment</key>
-    <string>Enables a colored debug overlay on meshes to show UV coordinates. Not all meshes support this setting.</string>
-    <key>Persist</key>
-    <integer>0</integer>
-    <key>Type</key>
-    <string>Boolean</string>
-    <key>Value</key>
-    <integer>0</integer>
-  </map>
-
   <key>RenderDeferredBlurLight</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
index ee44ad874c..ddb53ff852 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
@@ -64,9 +64,6 @@ out vec2 basecolor_texcoord;
 out vec2 normal_texcoord;
 out vec2 metallic_roughness_texcoord;
 out vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-out vec2 original_texcoord;
-#endif
 
 out vec4 vertex_color;
 
@@ -99,9 +96,6 @@ void main()
 	normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0);
 	metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0);
 	emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
-#if DEBUG_TEXCOORD
-    original_texcoord = texcoord0;
-#endif
 
 #ifdef HAS_SKIN
 	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz;
@@ -143,9 +137,6 @@ in vec2 texcoord0;
 
 out vec2 basecolor_texcoord;
 out vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-out vec2 original_texcoord;
-#endif
 
 out vec4 vertex_color;
 
@@ -161,9 +152,6 @@ void main()
 
 	basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
 	emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
-#if DEBUG_TEXCOORD
-    original_texcoord = texcoord0;
-#endif
 
 	vertex_color = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
index fd2aa6eb54..c4c5a7872b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
@@ -51,9 +51,6 @@ in vec2 basecolor_texcoord;
 in vec2 normal_texcoord;
 in vec2 metallic_roughness_texcoord;
 in vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-in vec2 original_texcoord;
-#endif
 
 uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff()
 
@@ -72,10 +69,6 @@ void main()
     }
 
     vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb);
-#if DEBUG_TEXCOORD
-    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
-    col = texcoord_color;
-#endif
 
     // from mikktspace.com
     vec3 vNt = texture2D(bumpMap, normal_texcoord.xy).xyz*2.0-1.0;
@@ -130,9 +123,6 @@ in vec4 vertex_color;
 
 in vec2 basecolor_texcoord;
 in vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-in vec2 original_texcoord;
-#endif
 
 uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff()
 
@@ -148,10 +138,6 @@ void main()
     }
 
     vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb);
-#if DEBUG_TEXCOORD
-    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
-    col = texcoord_color;
-#endif
 
     vec3 emissive = emissiveColor;
     emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
index aeb6b85e12..f0e3d4f034 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl
@@ -53,9 +53,6 @@ out vec2 basecolor_texcoord;
 out vec2 normal_texcoord;
 out vec2 metallic_roughness_texcoord;
 out vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-out vec2 original_texcoord;
-#endif
  
 out vec4 vertex_color;
 
@@ -85,9 +82,6 @@ void main()
     normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0);
     metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0);
     emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
-#if DEBUG_TEXCOORD
-    original_texcoord = texcoord0;
-#endif
 
 #ifdef HAS_SKIN
 	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz;
@@ -123,9 +117,6 @@ in vec2 texcoord0;
 
 out vec2 basecolor_texcoord;
 out vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-out vec2 original_texcoord;
-#endif
  
 out vec4 vertex_color;
 
@@ -138,9 +129,6 @@ void main()
 
     basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0);
     emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0);
-#if DEBUG_TEXCOORD
-    original_texcoord = texcoord0;
-#endif
 
     vertex_color = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 47d6c5e195..35ccc65a8e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -57,9 +57,6 @@ in vec2 basecolor_texcoord;
 in vec2 normal_texcoord;
 in vec2 metallic_roughness_texcoord;
 in vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-in vec2 original_texcoord;
-#endif
 
 in vec4 vertex_color;
 
@@ -176,10 +173,6 @@ void main()
 #endif
 
     vec3 col = vertex_color.rgb * basecolor.rgb;
-#if DEBUG_TEXCOORD
-    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
-    col = texcoord_color;
-#endif
 
     vec3 vNt = texture(bumpMap, normal_texcoord.xy).xyz*2.0-1.0;
     float sign = vary_sign;
@@ -272,9 +265,6 @@ in vec3 vary_position;
 
 in vec2 basecolor_texcoord;
 in vec2 emissive_texcoord;
-#if DEBUG_TEXCOORD
-in vec2 original_texcoord;
-#endif
 
 in vec4 vertex_color;
 
@@ -302,10 +292,6 @@ void main()
 #endif
 
     color = vertex_color.rgb * basecolor.rgb;
-#if DEBUG_TEXCOORD
-    vec3 texcoord_color = vec3(mod(original_texcoord, 1.0), 0);
-    color = texcoord_color;
-#endif
 
     // emissiveColor is the emissive color factor from GLTF and is already in linear space
     vec3 colorEmissive = emissiveColor;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 6426512d5f..341f94241a 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -682,7 +682,6 @@ void settings_setup_listeners()
     setting_setup_signal_listener(gSavedSettings, "RenderScreenSpaceReflections", handleReflectionProbeDetailChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderShadowDetail", handleSetShaderChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderDeferredSSAO", handleSetShaderChanged);
-	setting_setup_signal_listener(gSavedSettings, "RenderDebugTexcoord", handleSetShaderChanged);
 	setting_setup_signal_listener(gSavedSettings, "RenderPerformanceTest", handleRenderPerfTestChanged);
 	setting_setup_signal_listener(gSavedSettings, "ChatFontSize", handleChatFontSizeChanged);
 	setting_setup_signal_listener(gSavedSettings, "ChatPersistTime", handleChatPersistTimeChanged);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index b866cedaaa..f99dac6ed6 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1321,10 +1321,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER));
         gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         gDeferredPBROpaqueProgram.clearPermutations();
-        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
-        {
-            gDeferredPBROpaqueProgram.addPermutation("DEBUG_TEXCOORD", "1");
-        }
         
         success = make_rigged_variant(gDeferredPBROpaqueProgram, gDeferredSkinnedPBROpaqueProgram);
         if (success)
@@ -1361,10 +1357,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gHUDPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         gHUDPBROpaqueProgram.clearPermutations();
         gHUDPBROpaqueProgram.addPermutation("IS_HUD", "1");
-        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
-        {
-            gHUDPBROpaqueProgram.addPermutation("DEBUG_TEXCOORD", "1");
-        }
 
         success = gHUDPBROpaqueProgram.createShader(NULL, NULL);
  
@@ -1408,10 +1400,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         {
             shader->addPermutation("HAS_SUN_SHADOW", "1");
         }
-        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
-        {
-            shader->addPermutation("DEBUG_TEXCOORD", "1");
-        }
 
         shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         success = make_rigged_variant(*shader, gDeferredSkinnedPBRAlphaProgram);
@@ -1444,10 +1432,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         shader->clearPermutations();
 
         shader->addPermutation("IS_HUD", "1");
-        if (gSavedSettings.getBOOL("RenderDebugTexcoord"))
-        {
-            shader->addPermutation("DEBUG_TEXCOORD", "1");
-        }
 
         shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
         success = shader->createShader(NULL, NULL);
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 04dde696d5..b8515cb096 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2843,16 +2843,6 @@ function="World.EnvPreset"
            function="Advanced.ToggleInfoDisplay"
            parameter="texture anim" />
         </menu_item_check>
-        <menu_item_check
-         label="Texture Coordinates"
-            name="RenderDebugTexcoord">
-            <menu_item_check.on_check
-             function="CheckControl"
-             parameter="RenderDebugTexcoord" />
-            <menu_item_check.on_click
-             function="ToggleControl"
-             parameter="RenderDebugTexcoord" />
-        </menu_item_check>
         <menu_item_check
          label="Texture Priority"
          name="Texture Priority">
-- 
cgit v1.2.3