diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index f1996b65e96c8f0844ed126812b16d7a00289dd1..4700d351f7971a8d177c5779cb981cfb0c60f6b8 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -790,8 +790,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
     // Use alpha float to store bit flags
     // See: C++: addDeferredAttachment(), shader: frag_data[2]
-    extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS   1.0\n"); // atmo kill
-    extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS    0.0\n");
+    extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS   0.0\n"); // atmo kill
+    extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS    1.0\n");
+    extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag)    (norm.w>0.5)\n");
 
 	if (defines)
 	{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 7f2c603f87a7f867cfebc2377bdd61a2a409fc95..918e119c319a185b9caf993b252948d2b4289925 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -142,7 +142,7 @@ void main()
             color = mix(color.rgb, reflected_color, envIntensity);
         }
        
-        if (norm.w < 0.5)
+        if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
         {
             color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse.a);
             color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 7700d16007a4a68d5cf37665c5bd3e9a5a479d9c..dfb93c17dc5f2bf9297a5403ea70d12b57ed4ffb 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -139,7 +139,7 @@ void main()
         color                = mix(color.rgb, reflected_color, envIntensity);
     }
 
-    if (norm.w < 0.5)
+    if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
     {
         color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse.a);
         color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse.a);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 61757882bb05236d659813ab18e666527dbd6a07..ea89a7626f461afeb4ce8dde1b86b6f1cf0e82d1 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -170,7 +170,7 @@ void main()
         applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
     }
 
-    if (norm.w < 0.5)
+    if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
     {
         color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse.a);
         color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse.a);