From 278869fd8681c1ed28749f5ccd3cb79bb851c6ba Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 13 Aug 2020 16:10:03 -0400
Subject: [PATCH] Fix legacy glFog calls running in shadered renderer

---
 indra/newview/llselectmgr.cpp | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 26b5026eacd..3f24a477af0 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6643,15 +6643,21 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
 		{
 			gGL.flush();
 			gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE);
-			LLGLEnable fog(GL_FOG);
-			glFogi(GL_FOG_MODE, GL_LINEAR);
-			float d = (viewerCamera.getPointOfInterest()-viewerCamera.getOrigin()).magVec();
-			LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
-			glFogf(GL_FOG_START, d);
-			glFogf(GL_FOG_END, d*(1 + (viewerCamera.getView() / viewerCamera.getDefaultFOV())));
-			glFogfv(GL_FOG_COLOR, fogCol.mV);
-
-			LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
+            if (!LLGLSLShader::sNoFixedFunction)
+            {
+                LLGLEnable fog(GL_FOG);
+                glFogi(GL_FOG_MODE, GL_LINEAR);
+                float d = (viewerCamera.getPointOfInterest() - viewerCamera.getOrigin()).magVec();
+                LLColor4 fogCol = color * (F32) llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal() -
+                                   gAgentCamera.getCameraPositionGlobal()).magVec() /
+                                      (LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec() * 4),
+                                  0.0, 1.0);
+                glFogf(GL_FOG_START, d);
+                glFogf(GL_FOG_END, d * (1 + (viewerCamera.getView() / viewerCamera.getDefaultFOV())));
+                glFogfv(GL_FOG_COLOR, fogCol.mV);
+            }
+
+            LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
 			gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
 			gGL.begin(LLRender::LINES);
 			{
-- 
GitLab