From 610764fbfce75f54c95d4b10c2a8f9482a7a7b80 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 11 Aug 2011 12:49:05 -0500
Subject: [PATCH] SH-2181 Fix for occlusion culling going bonkers when ban
 lines are present.

---
 .../shaders/class1/objects/impostorF.glsl     | 38 +++++++++----------
 indra/newview/llglsandbox.cpp                 |  2 +-
 indra/newview/pipeline.cpp                    | 21 +++++-----
 3 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
index 7257132f066..13597ee439d 100644
--- a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
@@ -5,22 +5,22 @@
  * $/LicenseInfo$
  */
  
-uniform float minimum_alpha;
-uniform float maximum_alpha;
-
-vec3 fullbrightAtmosTransport(vec3 light);
-vec3 fullbrightScaleSoftClip(vec3 light);
-
-uniform sampler2D diffuseMap;
-
-void main()
-{
-	vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color;
-	
-	if (color.a < minimum_alpha || color.a > maximum_alpha)
-	{
-		discard;
-	}
-
-	gl_FragColor = color;
-}
+uniform float minimum_alpha;
+uniform float maximum_alpha;
+
+vec3 fullbrightAtmosTransport(vec3 light);
+vec3 fullbrightScaleSoftClip(vec3 light);
+
+uniform sampler2D diffuseMap;
+
+void main()
+{
+	vec4 color = texture2D(diffuseMap,gl_TexCoord[0].xy) * gl_Color;
+	
+	if (color.a < minimum_alpha || color.a > maximum_alpha)
+	{
+		discard;
+	}
+
+	gl_FragColor = color;
+}
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 842911ecc0a..fa3f546157b 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -620,7 +620,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
 	F32 pos_y = pos.mV[VY];
 
 	LLGLSUIDefault gls_ui;
-	LLGLDepthTest gls_depth(GL_TRUE);
+	LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
 	LLGLDisable cull(GL_CULL_FACE);
 	
 	if (mCollisionBanned == BA_BANNED)
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 01ff1bb16f6..7a264041383 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3340,13 +3340,15 @@ void render_hud_elements()
 	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
 	
 	gGL.color4f(1,1,1,1);
-	if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+	
+	if (LLGLSLShader::sNoFixedFunction)
 	{
-		if (LLGLSLShader::sNoFixedFunction)
-		{
-			gUIProgram.bind();
-		}
+		gUIProgram.bind();
+	}
+	LLGLDepthTest depth(GL_TRUE, GL_FALSE);
 
+	if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+	{
 		LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0);
 		gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d()
 	
@@ -3360,10 +3362,6 @@ void render_hud_elements()
 	
 		// Render name tags.
 		LLHUDObject::renderAll();
-		if (LLGLSLShader::sNoFixedFunction)
-		{
-			gUIProgram.unbind();
-		}
 	}
 	else if (gForceRenderLandFence)
 	{
@@ -3374,6 +3372,11 @@ void render_hud_elements()
 	{
 		LLHUDText::renderAllHUD();
 	}
+
+	if (LLGLSLShader::sNoFixedFunction)
+	{
+		gUIProgram.unbind();
+	}
 	gGL.flush();
 }
 
-- 
GitLab