From 7166b4009f738281cfacbb9b5810dfba360ec2fd Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 30 Nov 2010 04:26:44 -0600
Subject: [PATCH] Ditch fake anti-aliasing for deferred rendering.

---
 .../class1/deferred/postDeferredF.glsl        | 51 +------------------
 indra/newview/pipeline.cpp                    |  8 ++-
 2 files changed, 4 insertions(+), 55 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index a3799101013..77e3e41ea4d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -68,7 +68,6 @@ void main()
 	depth[0] = getDepth(tc);
 		
 	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
-	bool do_aa = true;
 	
 	if (depth[0] < far_focal_distance)
 	{ //pixel is behind far focal plane
@@ -82,7 +81,6 @@ void main()
 					
 		while (sc > 1.0)
 		{
-			do_aa = false;
 			dofSample(diff,w, fd, sc,sc);
 			dofSample(diff,w, fd, -sc,sc);
 			dofSample(diff,w, fd, sc,-sc);
@@ -112,7 +110,6 @@ void main()
 			fd = depth[0];
 			while (sc > 1.0)
 			{
-				do_aa = false;
 				dofSampleNear(diff,w, sc,sc);
 				dofSampleNear(diff,w, -sc,sc);
 				dofSampleNear(diff,w, sc,-sc);
@@ -128,54 +125,8 @@ void main()
 			}
 			diff /= w;
 		}	
-		
-		if (do_aa)
-		{
-			depth[1] = getDepth(tc+vec2(sc,sc));
-			depth[2] = getDepth(tc+vec2(-sc,-sc));
-			depth[3] = getDepth(tc+vec2(-sc,sc));
-			depth[4] = getDepth(tc+vec2(sc, -sc));
-				
-			
-			vec2 de;
-			de.x = (depth[0]-depth[1]) + (depth[0]-depth[2]);
-			de.y = (depth[0]-depth[3]) + (depth[0]-depth[4]);
-			de /= depth[0];
-			de *= de;
-			de = step(depth_cutoff, de);
-			
-			vec2 ne;
-			vec3 nexnorm = texture2DRect(normalMap, tc+vec2(-sc,-sc)).rgb;
-			nexnorm = vec3((nexnorm.xy-0.5)*2.0,nexnorm.z); // unpack norm
-			ne.x = dot(nexnorm, norm);
-			vec3 neynorm = texture2DRect(normalMap, tc+vec2(sc,sc)).rgb;
-			neynorm = vec3((neynorm.xy-0.5)*2.0,neynorm.z); // unpack norm
-			ne.y = dot(neynorm, norm);
-			
-			ne = 1.0-ne;
-			
-			ne = step(norm_cutoff, ne);
-			
-			float edge_weight = clamp(dot(de,de)+dot(ne,ne), 0.0, 1.0);
-			//edge_weight *= 0.0;
-			
-			//diff.r = edge_weight;
-			
-			if (edge_weight > 0.0)
-			{
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(1,1))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(-1,-1))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(-1,1))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(1,-1))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(-1,0))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(1,0))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(0,1))*edge_weight;
-				diff += texture2DRect(diffuseRect, vary_fragcoord.xy+vec2(0,-1))*edge_weight;
-				diff /= 1.0+edge_weight*8.0;
-			}
-		}
 	}
-			
+	
 	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
 	gl_FragColor = diff + bloom;
 	
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1ebc0a6a094..78d1044ff3c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -582,7 +582,6 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 		BOOL ssao = gSavedSettings.getBOOL("RenderDeferredSSAO");
 		bool gi = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED);
 
-		samples = llmin(samples, (U32) 8); //cap multisample buffers to 8 samples when rendering deferred
 		//allocate deferred rendering color buffers
 		mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
 		mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
@@ -693,9 +692,8 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
 	}
 	
 
-	if (LLRenderTarget::sUseFBO && !sRenderDeferred && gGLManager.mHasFramebufferMultisample && samples > 1)
-	{ // DON'T use multisample buffers when rendering deferred -- multisampling doesn't play nice with deferred rendering
-		//so a post-effect smooths edges in screen space
+	if (LLRenderTarget::sUseFBO && gGLManager.mHasFramebufferMultisample && samples > 1)
+	{ 
 		mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples);
 		if (LLPipeline::sRenderDeferred)
 		{
@@ -6372,7 +6370,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 		if (channel > -1)
 		{
 			mScreen.bindTexture(0, channel);
-			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
 		}
 
 		gGL.begin(LLRender::TRIANGLE_STRIP);
-- 
GitLab