From 8b86e2ad1b1326cb3e98acd857dc93f4f1455b8c Mon Sep 17 00:00:00 2001
From: RunitaiLinden <davep@lindenlab.com>
Date: Thu, 14 Dec 2023 14:11:46 -0600
Subject: [PATCH] SL-20611 Followup -- fix for depth based atmospheric mask
 making atmospherics effect sun/moon/clouds

---
 .../newview/app_settings/shaders/class3/deferred/hazeF.glsl | 3 +--
 indra/newview/lldrawpool.h                                  | 6 +++---
 indra/newview/lldrawpoolwlsky.cpp                           | 3 +++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
index 229f332b36e..0b154e82ad0 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
@@ -78,13 +78,12 @@ void main()
         do_atmospherics = true;
     }
     
-
     vec3  irradiance = vec3(0);
     vec3  radiance  = vec3(0);
 
     if (depth >= 1.0)
     {
-        //should only be true of WL sky, just port over base color value
+        //should only be true of sky, clouds, sun/moon, and stars
         discard;
     }
 
diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 4300670445e..0925a01439a 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -53,7 +53,9 @@ class LLDrawPool
         // before grass, so grass should be the first alpha masked pool.  Other ordering should be done
         // based on fill rate and likelihood to occlude future passes (faster, large occluders first).
         //  
-		POOL_SIMPLE = 1,
+        POOL_SKY = 1,
+        POOL_WL_SKY,
+		POOL_SIMPLE,
 		POOL_FULLBRIGHT,
 		POOL_BUMP,
 		POOL_TERRAIN,
@@ -64,8 +66,6 @@ class LLDrawPool
 		POOL_TREE,
 		POOL_ALPHA_MASK,
 		POOL_FULLBRIGHT_ALPHA_MASK,
-        POOL_SKY,
-        POOL_WL_SKY,
 		POOL_AVATAR,
 		POOL_CONTROL_AV, // Animesh
 		POOL_GLOW,
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index 05ee328e432..b14235f25c0 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -87,6 +87,9 @@ void LLDrawPoolWLSky::endDeferredPass(S32 pass)
     cloud_shader = nullptr;
     sun_shader   = nullptr;
     moon_shader  = nullptr;
+
+    // clear the depth buffer so haze shaders can use unwritten depth as a mask
+    glClear(GL_DEPTH_BUFFER_BIT);
 }
 
 void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const
-- 
GitLab