From d74d0d5c41d5ea114cef19aa7e54834d1c3b554b Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 21 Dec 2009 13:02:42 -0800
Subject: [PATCH] DEV-44562 deferred rendering: crease noise sadness

---
 .../shaders/class2/deferred/blurLightF.glsl   | 52 ++++++-------------
 indra/newview/pipeline.cpp                    |  3 +-
 2 files changed, 19 insertions(+), 36 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
index 28908a311d7..0fad5b4b50b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
@@ -10,7 +10,6 @@
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
-uniform sampler2DRect edgeMap;
 
 uniform float dist_factor;
 uniform float blur_size;
@@ -46,53 +45,36 @@ void main()
 	
 	dlt /= max(-pos.z*dist_factor, 1.0);
 	
-	vec2 defined_weight = kern[0].xy; // special case the kern[0] (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
+	vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
 	vec4 col = defined_weight.xyxx * ccol;
-
-	float center_e = 1.0 - (texture2DRect(edgeMap, vary_fragcoord.xy).a+
-		      texture2DRect(edgeMap, vary_fragcoord.xy+dlt*0.333).a+
-	              texture2DRect(edgeMap, vary_fragcoord.xy-dlt*0.333).a);
 	
-	float e = center_e;
 	for (int i = 1; i < 4; i++)
 	{
 		vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
-		
-		e = max(e, 0.0);
-		
-		vec2 wght = kern[i].xy*e;
-		
-		col += texture2DRect(lightMap, tc)*wght.xyxx;
-		defined_weight += wght;
-		
-		e *= e;
-		e -= texture2DRect(edgeMap, tc.xy).a+
-			texture2DRect(edgeMap, tc.xy+dlt*0.333).a+
-			texture2DRect(edgeMap, tc.xy-dlt*0.333).a;
+	        vec3 samppos = getPosition(tc).xyz; 
+		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+		if (d*d <= 0.003)
+		{
+			col += texture2DRect(lightMap, tc)*kern[i].xyxx;
+			defined_weight += kern[i].xy;
+		}
 	}
-
-	e = center_e;
 	for (int i = 1; i < 4; i++)
 	{
 		vec2 tc = vary_fragcoord.xy - kern[i].z*dlt;
-		
-		e = max(e, 0.0);
-		
-		vec2 wght = kern[i].xy*e;
-		
-		col += texture2DRect(lightMap, tc)*wght.xyxx;
-		defined_weight += wght;
-		
-		e *= e;
-		e -= texture2DRect(edgeMap, tc.xy).a+
-			texture2DRect(edgeMap, tc.xy+dlt*0.333).a+
-			texture2DRect(edgeMap, tc.xy-dlt*0.333).a;
+	        vec3 samppos = getPosition(tc).xyz; 
+		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+		if (d*d <= 0.003)
+		{
+			col += texture2DRect(lightMap, tc)*kern[i].xyxx;
+			defined_weight += kern[i].xy;
+		}
 	}
 
 
+
 	col /= defined_weight.xyxx;
 	
 	gl_FragColor = col;
-	
-	//gl_FragColor = ccol;
 }
+
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 73b5222ee3a..4f4fc838191 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6352,7 +6352,8 @@ void LLPipeline::renderDeferredLighting()
 
 			mDeferredLight[0].flush();
 
-			if (gSavedSettings.getBOOL("RenderDeferredBlurLight"))
+			if (gSavedSettings.getBOOL("RenderDeferredBlurLight") &&
+			    gSavedSettings.getBOOL("RenderDeferredGI"))
 			{
 				LLFastTimer ftm(FTM_EDGE_DETECTION);
 				//get edge map
-- 
GitLab