diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c517c9f6026a180f259b6fe1b54e5bda453f42bc..5f010624a89e6a718af525d09e7ad76ccb6a11d6 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6334,7 +6334,10 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 	if (LLPipeline::sRenderDeferred)
 	{
-		bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater();
+		bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() &&
+							!LLToolMgr::getInstance()->inBuildMode() &&
+							gSavedSettings.getBOOL("RenderDepthOfField");
+
 		bool multisample = gSavedSettings.getU32("RenderFSAASamples") > 1;
 
 		if (multisample)
@@ -6363,7 +6366,10 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 			gGlowCombineFXAAProgram.unbind();
 			mFXAABuffer.flush();
 
-			mScreen.bindTarget();
+			if (dof_enabled)
+			{ //if depth of field is not enabled, this is the final pass (draw to window)
+				mScreen.bindTarget();
+			}
 			LLGLSLShader* shader = &gFXAAProgram;
 			shader->bind();
 
@@ -6389,158 +6395,168 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 			gGL.end();
 
 			gGL.flush();
-			mScreen.flush();
+			if (dof_enabled)
+			{
+				mScreen.flush();
+			}
 			shader->unbind();
 		}
 
 		gViewerWindow->setup3DViewport();
 				
-		LLGLSLShader* shader = &gDeferredPostProgram;
-		if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 2)
+		if (dof_enabled || !multisample)
 		{
-			shader = &gDeferredGIFinalProgram;
-			dof_enabled = false;
-		}
-		else if (!dof_enabled || LLToolMgr::getInstance()->inBuildMode() || !gSavedSettings.getBOOL("RenderDepthOfField"))
-		{ //squish focal length when in build mode (or if DoF is disabled) so DoF doesn't make editing objects difficult
-			shader = &gDeferredPostNoDoFProgram;
-			dof_enabled = false;
-		}
+			LLGLSLShader* shader = &gDeferredPostProgram;
+			if (!dof_enabled)
+			{ 
+				shader = &gDeferredPostNoDoFProgram;
+			}
 				
-		LLGLDisable blend(GL_BLEND);
-		bindDeferredShader(*shader);
+			LLGLDisable blend(GL_BLEND);
+			bindDeferredShader(*shader);
 
-		if (dof_enabled)
-		{
-			//depth of field focal plane calculations
+			if (dof_enabled)
+			{
+				//depth of field focal plane calculations
 
-			static F32 current_distance = 16.f;
-			static F32 start_distance = 16.f;
-			static F32 transition_time = 1.f;
+				static F32 current_distance = 16.f;
+				static F32 start_distance = 16.f;
+				static F32 transition_time = 1.f;
 
-			LLVector3 focus_point;
+				LLVector3 focus_point;
 
-			LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject();
-			if (obj && obj->mDrawable && obj->isSelected())
-			{ //focus on selected media object
-				S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace();
-				if (obj && obj->mDrawable)
-				{
-					LLFace* face = obj->mDrawable->getFace(face_idx);
-					if (face)
+				LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject();
+				if (obj && obj->mDrawable && obj->isSelected())
+				{ //focus on selected media object
+					S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace();
+					if (obj && obj->mDrawable)
 					{
-						focus_point = face->getPositionAgent();
+						LLFace* face = obj->mDrawable->getFace(face_idx);
+						if (face)
+						{
+							focus_point = face->getPositionAgent();
+						}
 					}
 				}
-			}
 		
-			if (focus_point.isExactlyZero())
-			{
-				if (LLViewerJoystick::getInstance()->getOverrideCamera())
-				{ //focus on point under cursor
-					focus_point = gDebugRaycastIntersection;
-				}
-				else if (gAgentCamera.cameraMouselook())
-				{ //focus on point under mouselook crosshairs
-					gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
-												  NULL,
-												  &focus_point);
-				}
-				else
+				if (focus_point.isExactlyZero())
 				{
-					LLViewerObject* obj = gAgentCamera.getFocusObject();
-					if (obj)
-					{ //focus on alt-zoom target
-						focus_point = LLVector3(gAgentCamera.getFocusGlobal()-gAgent.getRegion()->getOriginGlobal());
+					if (LLViewerJoystick::getInstance()->getOverrideCamera())
+					{ //focus on point under cursor
+						focus_point = gDebugRaycastIntersection;
+					}
+					else if (gAgentCamera.cameraMouselook())
+					{ //focus on point under mouselook crosshairs
+						gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
+													  NULL,
+													  &focus_point);
 					}
 					else
-					{ //focus on your avatar
-						focus_point = gAgent.getPositionAgent();
+					{
+						LLViewerObject* obj = gAgentCamera.getFocusObject();
+						if (obj)
+						{ //focus on alt-zoom target
+							focus_point = LLVector3(gAgentCamera.getFocusGlobal()-gAgent.getRegion()->getOriginGlobal());
+						}
+						else
+						{ //focus on your avatar
+							focus_point = gAgent.getPositionAgent();
+						}
 					}
 				}
-			}
 
-			LLVector3 eye = LLViewerCamera::getInstance()->getOrigin();
-			F32 target_distance = 16.f;
-			if (!focus_point.isExactlyZero())
-			{
-				target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point-eye);
-			}
+				LLVector3 eye = LLViewerCamera::getInstance()->getOrigin();
+				F32 target_distance = 16.f;
+				if (!focus_point.isExactlyZero())
+				{
+					target_distance = LLViewerCamera::getInstance()->getAtAxis() * (focus_point-eye);
+				}
 
-			if (transition_time >= 1.f &&
-				fabsf(current_distance-target_distance)/current_distance > 0.01f)
-			{ //large shift happened, interpolate smoothly to new target distance
-				transition_time = 0.f;
-				start_distance = current_distance;
-			}
-			else if (transition_time < 1.f)
-			{ //currently in a transition, continue interpolating
-				transition_time += 1.f/gSavedSettings.getF32("CameraFocusTransitionTime")*gFrameIntervalSeconds;
-				transition_time = llmin(transition_time, 1.f);
+				if (transition_time >= 1.f &&
+					fabsf(current_distance-target_distance)/current_distance > 0.01f)
+				{ //large shift happened, interpolate smoothly to new target distance
+					transition_time = 0.f;
+					start_distance = current_distance;
+				}
+				else if (transition_time < 1.f)
+				{ //currently in a transition, continue interpolating
+					transition_time += 1.f/gSavedSettings.getF32("CameraFocusTransitionTime")*gFrameIntervalSeconds;
+					transition_time = llmin(transition_time, 1.f);
 
-				F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f;
-				current_distance = start_distance + (target_distance-start_distance)*t;
-			}
-			else
-			{ //small or no change, just snap to target distance
-				current_distance = target_distance;
-			}
+					F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f;
+					current_distance = start_distance + (target_distance-start_distance)*t;
+				}
+				else
+				{ //small or no change, just snap to target distance
+					current_distance = target_distance;
+				}
 
-			//convert to mm
-			F32 subject_distance = current_distance*1000.f;
-			F32 fnumber = gSavedSettings.getF32("CameraFNumber");
-			F32 default_focal_length = gSavedSettings.getF32("CameraFocalLength");
+				//convert to mm
+				F32 subject_distance = current_distance*1000.f;
+				F32 fnumber = gSavedSettings.getF32("CameraFNumber");
+				F32 default_focal_length = gSavedSettings.getF32("CameraFocalLength");
 
-			F32 fov = LLViewerCamera::getInstance()->getView();
+				F32 fov = LLViewerCamera::getInstance()->getView();
 		
-			const F32 default_fov = gSavedSettings.getF32("CameraFieldOfView") * F_PI/180.f;
-			//const F32 default_aspect_ratio = gSavedSettings.getF32("CameraAspectRatio");
+				const F32 default_fov = gSavedSettings.getF32("CameraFieldOfView") * F_PI/180.f;
+				//const F32 default_aspect_ratio = gSavedSettings.getF32("CameraAspectRatio");
 		
-			//F32 aspect_ratio = (F32) mScreen.getWidth()/(F32)mScreen.getHeight();
+				//F32 aspect_ratio = (F32) mScreen.getWidth()/(F32)mScreen.getHeight();
 		
-			F32 dv = 2.f*default_focal_length * tanf(default_fov/2.f);
-			//F32 dh = 2.f*default_focal_length * tanf(default_fov*default_aspect_ratio/2.f);
+				F32 dv = 2.f*default_focal_length * tanf(default_fov/2.f);
+				//F32 dh = 2.f*default_focal_length * tanf(default_fov*default_aspect_ratio/2.f);
 
-			F32 focal_length = dv/(2*tanf(fov/2.f));
+				F32 focal_length = dv/(2*tanf(fov/2.f));
 		 
-			//F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle);
+				//F32 tan_pixel_angle = tanf(LLDrawable::sCurPixelAngle);
 	
-			// from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f))
-			// where	 N = fnumber
-			//			 s2 = dot distance
-			//			 s1 = subject distance
-			//			 f = focal length
-			//	
+				// from wikipedia -- c = |s2-s1|/s2 * f^2/(N(S1-f))
+				// where	 N = fnumber
+				//			 s2 = dot distance
+				//			 s1 = subject distance
+				//			 f = focal length
+				//	
 
-			F32 blur_constant = focal_length*focal_length/(fnumber*(subject_distance-focal_length));
-			blur_constant /= 1000.f; //convert to meters for shader
-			F32 magnification = focal_length/(subject_distance-focal_length);
+				F32 blur_constant = focal_length*focal_length/(fnumber*(subject_distance-focal_length));
+				blur_constant /= 1000.f; //convert to meters for shader
+				F32 magnification = focal_length/(subject_distance-focal_length);
 
-			shader->uniform1f("focal_distance", -subject_distance/1000.f);
-			shader->uniform1f("blur_constant", blur_constant);
-			shader->uniform1f("tan_pixel_angle", tanf(1.f/LLDrawable::sCurPixelAngle));
-			shader->uniform1f("magnification", magnification);
-		}
+				shader->uniform1f("focal_distance", -subject_distance/1000.f);
+				shader->uniform1f("blur_constant", blur_constant);
+				shader->uniform1f("tan_pixel_angle", tanf(1.f/LLDrawable::sCurPixelAngle));
+				shader->uniform1f("magnification", magnification);
+			}
+
+			S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
+			if (channel > -1)
+			{
+				mScreen.bindTexture(0, channel);
+			}
+
+			if (multisample)
+			{ //bloom has already been added, bind black
+				channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_BLOOM);
+				if (channel > -1)
+				{
+					gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sBlackImagep);
+				}
+			}
 
-		S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
-		if (channel > -1)
-		{
-			mScreen.bindTexture(0, channel);
-		}
 	
-		gGL.begin(LLRender::TRIANGLE_STRIP);
-		gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
-		gGL.vertex2f(-1,-1);
+			gGL.begin(LLRender::TRIANGLE_STRIP);
+			gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
+			gGL.vertex2f(-1,-1);
 		
-		gGL.texCoord2f(tc1.mV[0], tc2.mV[1]);
-		gGL.vertex2f(-1,3);
+			gGL.texCoord2f(tc1.mV[0], tc2.mV[1]);
+			gGL.vertex2f(-1,3);
 		
-		gGL.texCoord2f(tc2.mV[0], tc1.mV[1]);
-		gGL.vertex2f(3,-1);
+			gGL.texCoord2f(tc2.mV[0], tc1.mV[1]);
+			gGL.vertex2f(3,-1);
 		
-		gGL.end();
+			gGL.end();
 
-		unbindDeferredShader(*shader);
+			unbindDeferredShader(*shader);
+		}
 	}
 	else
 	{