diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index f7bb2ab3300b147993c1d5e6b689db0d7b8e67a9..d255703a808cb40b84601d61eff2758718c914f3 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -2182,7 +2182,7 @@ bool LLKeyframeMotion::dumpToFile(const std::string& name, bool from_upload)
         S32 file_size = getFileSize();
         U8* buffer = new U8[file_size];
 
-        LL_DEBUGS("BVH") << "Dumping " << outfilename << LL_ENDL;
+        LL_DEBUGS("BVH") << "Dumping " << filename << LL_ENDL;
         LLDataPackerBinaryBuffer dp(buffer, file_size);
         if (serialize(dp))
         {
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 8338245897d09900a69b4a2e8c7a27d762a2d267..26feee7931ee7c8d3fd7cde5a75ca02b726e0b9a 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -40,31 +40,32 @@ namespace
     const LLUUID IMG_HALO("12149143-f599-91a7-77ac-b52a3c0f59cd");
 }
 
-namespace {
-    LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude)
-    {
-        F32 sinTheta = sin(azimuth);
-        F32 cosTheta = cos(azimuth);
-        F32 sinPhi   = sin(altitude);
-        F32 cosPhi   = cos(altitude);
+//BD
+//namespace {
+LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude)
+{
+    F32 sinTheta = sin(azimuth);
+    F32 cosTheta = cos(azimuth);
+    F32 sinPhi   = sin(altitude);
+    F32 cosPhi   = cos(altitude);
 
-        LLVector3 dir;
-        // +x right, +z up, +y at...	
-        dir.mV[0] = cosTheta * cosPhi;
-        dir.mV[1] = sinTheta * cosPhi;	
-        dir.mV[2] = sinPhi;
+    LLVector3 dir;
+    // +x right, +z up, +y at...	
+    dir.mV[0] = cosTheta * cosPhi;
+    dir.mV[1] = sinTheta * cosPhi;	
+    dir.mV[2] = sinPhi;
 
-        LLVector3 axis = LLVector3::x_axis % dir;
-        axis.normalize();
+    LLVector3 axis = LLVector3::x_axis % dir;
+    axis.normalize();
 
-        F32 angle = acos(LLVector3::x_axis * dir);
+    F32 angle = acos(LLVector3::x_axis * dir);
 
-        LLQuaternion quat;
-        quat.setAngleAxis(angle, axis);
+    LLQuaternion quat;
+    quat.setAngleAxis(angle, axis);
 
-        return quat;
-    }
+    return quat;
 }
+//}
 
 //=========================================================================
 const std::string LLSettingsSky::SETTING_AMBIENT("ambient");
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 572f32b598f0ad7bc9b611b6ec7a19412d304cd5..458fad29e9e4dbe20874308e1fe20c311ec1492b 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -59,7 +59,7 @@ class LLShaderFeatures
     bool attachNothing = false;
 
 //	//BD - Motion Blur
-	bool hasMotionBlur;
+	//bool hasMotionBlur;
 };
 
 // ============= Structure for caching shader uniforms ===============
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index bc6821269f9932016103cf1f7a08c83b8e55284a..de34ea63198ee4f18c8119fae42af079d898c24d 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -397,13 +397,13 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
 	}
 
 //	//BD - Motion Blur
-	if (features->hasMotionBlur)
+	/*/if (features->hasMotionBlur)
 	{
 		if (!shader->attachVertexObject("deferred/velocityFuncV.glsl"))
 		{
 			return FALSE;
 		}
-	}
+	}*/
 
 	return TRUE;
 }
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index db48b2c961e6defb41badcb2f09c457165612ac7..ab6fef0da1244b1744f382bf45b5e308d78d4eb7 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -38,6 +38,9 @@
 #include "lluiimage.h"
 #include "lluistring.h"
 
+ //BD
+#include "llsearchablecontrol.h"
+
 //
 // Constants
 //
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index b2fe45cf3e1a1ac18c9343ccf583dd88879276b8..35227b305ffc40cfb288bcc60fc1fe8f45ae1098 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -31,6 +31,8 @@
 #include "llbutton.h"
 #include "lltextbox.h"
 #include "v4color.h"
+ //BD
+#include "llsearchablecontrol.h"
 
 //
 // Constants
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 8ce38a54a27b794ab89528e9c5838dba30436248..166a1841580e5d60023f83bae289ee0f55da6bea 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -37,6 +37,8 @@
 #include "llscrolllistctrl.h"
 #include "lllineeditor.h"
 #include <boost/function.hpp>
+//BD
+#include "llsearchablecontrol.h"
 
 #include "lliconctrl.h"
 
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index a2063093d77758d5d909bffdf33af66eb9a7eaea..276a11396e7c04e5bff34f4add6df07a5e1a7da3 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -38,6 +38,8 @@
 #include "lluistring.h"
 #include "llview.h"
 #include <boost/function.hpp>
+ //BD
+#include "llsearchablecontrol.h"
 
 extern S32 MENU_BAR_HEIGHT;
 extern S32 MENU_BAR_WIDTH;
@@ -756,13 +758,13 @@ class LLContextMenuBranch : public LLMenuItemGL
 	// onCommit() - do the primary funcationality of the menu item.
 	virtual void	onCommit( void );
 
-	LLContextMenu*	getBranch() { return mBranchHandle.get(); }
+	LLContextMenu*	getBranch() { return mBranch.get(); }
 	void			setHighlight( BOOL highlight );
 
 protected:
 	void	showSubMenu();
 
-	LLHandle<LLContextMenu> mBranchHandle;
+	LLHandle<LLContextMenu> mBranch;
 };
 
 
diff --git a/indra/llui/llsearchablecontrol.cpp b/indra/llui/llsearchablecontrol.cpp
deleted file mode 100644
index 8ff37255ff53adfa333434e5dfe8007d5ffa0064..0000000000000000000000000000000000000000
--- a/indra/llui/llsearchablecontrol.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
-* @file llsearchablecontrol.cpp
-* @brief A text display widget
-*
-* $LicenseInfo:firstyear=2001&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2010, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
-* $/LicenseInfo$
-*/
-
-#include "linden_common.h"
-#include "llsearchablecontrol.h"
-
-LLSearchableControl::LLSearchableControl()
-	: mIsHighlighed(false)
-{
-}
-
-LLSearchableControl::~LLSearchableControl()
-{
-}
-
-LLColor4 LLSearchableControl::getHighlightColor() const
-{
-	static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red);
-	return highlight_color.get();
-}
-
-void LLSearchableControl::setHighlighted(bool aVal) const
-{
-	mIsHighlighed = aVal;
-	onSetHighlight();
-}
-
-/*virtual*/
-/*void LLSearchableControl::onSetHighlight() const
-{
-}*/
-
-bool LLSearchableControl::getHighlighted() const
-{
-	return mIsHighlighed;
-}
-
-std::string LLSearchableControl::getSearchText() const
-{
-	return _getSearchText();
-}
\ No newline at end of file
diff --git a/indra/llui/llsearchablecontrol.h b/indra/llui/llsearchablecontrol.h
index 6e3bbce5138d44ad8062870b0cb1f38c078c47c9..ea1e2df1a4ee28cca196fe010b1be8b1b24f5ee1 100644
--- a/indra/llui/llsearchablecontrol.h
+++ b/indra/llui/llsearchablecontrol.h
@@ -33,19 +33,36 @@ class LLSearchableControl
 {
 	mutable bool mIsHighlighed;
 public:
-	LLSearchableControl();
-	virtual ~LLSearchableControl();
+	LLSearchableControl()
+		: mIsHighlighed(false)
+	{ }
+	virtual ~LLSearchableControl()
+	{ }
 
-	void setHighlighted(bool aVal) const;
+	LLColor4 getHighlightColor() const
+	{
+		static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red);
+		return highlight_color.get();
+	}
 
-	bool getHighlighted() const;
+	void setHighlighted(bool aVal) const
+	{
+		mIsHighlighed = aVal;
+		onSetHighlight();
+	}
+	bool getHighlighted() const
+	{
+		return mIsHighlighed;
+	}
 
-	LLColor4 getHighlightColor() const;
-
-	std::string getSearchText() const;
+	std::string getSearchText() const
+	{
+		return _getSearchText();
+	}
 protected:
-	virtual std::string _getSearchText() const { return ""; }
-	virtual void onSetHighlight() const {}
+	virtual std::string _getSearchText() const = 0;
+	virtual void onSetHighlight() const
+	{ }
 };
 
 
diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h
index 4ab0dbdffb246cd7b47cd071c579744378a92e89..9c996c28172f541a112514f10d369113410045a3 100644
--- a/indra/llui/llsliderctrl.h
+++ b/indra/llui/llsliderctrl.h
@@ -33,6 +33,8 @@
 #include "lltextbox.h"
 #include "llrect.h"
 #include "lllineeditor.h"
+//BD
+#include "llsearchablecontrol.h"
 
 
 class LLSliderCtrl : public LLF32UICtrl, public LLSearchableControl
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index e0ced3f9b8706a140ceb4af8051265e65dfca308..842ee03fe997fb6e7a7ddea0b65cd78f13d1966c 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -35,6 +35,9 @@
 #include "llkeywords.h"
 #include "llpanel.h"
 
+ //BD
+#include "llsearchablecontrol.h"
+
 #include <string>
 #include <vector>
 #include <set>
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index ae4a6cc90e447a8de10df6e0cf92a598dadf147d..e37c654d9cd190cd1c617e025a1972ebdc43732c 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -283,7 +283,6 @@ set(viewer_SOURCE_FILES
     llfloaterpathfindinglinksets.cpp
     llfloaterpathfindingobjects.cpp
     llfloaterpay.cpp
-    llfloaterperformance.cpp
     llfloaterperms.cpp
     llfloaterpostprocess.cpp
     llfloaterprofile.cpp
@@ -953,7 +952,6 @@ set(viewer_HEADER_FILES
     llfloaterpathfindinglinksets.h
     llfloaterpathfindingobjects.h
     llfloaterpay.h
-    llfloaterperformance.h
     llfloaterperms.h
     llfloaterpostprocess.h
     llfloaterprofile.h
diff --git a/indra/newview/bdfloatercomplexity.cpp b/indra/newview/bdfloatercomplexity.cpp
index 481e77df58c03bb4bfcfb324c8577c297a6cbd58..2990ca88628dbbd4162f6205af9f5c66591fa8f7 100644
--- a/indra/newview/bdfloatercomplexity.cpp
+++ b/indra/newview/bdfloatercomplexity.cpp
@@ -23,7 +23,10 @@
 #include "llavatarnamecache.h"
 #include "llcharacter.h"
 #include "lldrawable.h"
+#include "llface.h"
 #include "llmeshrepository.h"
+#include "llprimitive.h"
+#include "llpartdata.h"
 #include "llselectmgr.h"
 #include "llviewerobjectlist.h"
 #include "llviewerobject.h"
@@ -31,8 +34,8 @@
 #include "llviewerjointattachment.h"
 #include "llviewerobjectlist.h"
 #include "llviewerobject.h"
-#include "llvovolume.h"
-#include "llface.h"
+#include "llviewerpartsource.h"
+#include "llvolumemgr.h"
 //BD - Animesh Support
 //#include "llcontrolavatar.h"
 
@@ -261,7 +264,7 @@ void BDFloaterComplexity::calcARC()
 									attachment_total_triangles, attachment_total_vertices);
 
 								//BD - Get all necessary data.
-								volume->getRenderCostValues(flexible_cost, particle_cost, light_cost, projector_cost,
+								getRenderCostValues(volume, flexible_cost, particle_cost, light_cost, projector_cost,
 									alpha_cost, rigged_cost, animesh_cost, media_cost, bump_cost, shiny_cost,
 									glow_cost, animated_cost);
 
@@ -279,7 +282,7 @@ void BDFloaterComplexity::calcARC()
 											attachment_volume_cost, attachment_base_cost,
 											attachment_total_triangles, attachment_total_vertices);
 
-										child->getRenderCostValues(flexible_cost, particle_cost, light_cost, projector_cost,
+										getRenderCostValues(child, flexible_cost, particle_cost, light_cost, projector_cost,
 											alpha_cost, rigged_cost, animesh_cost, media_cost, bump_cost, shiny_cost,
 											glow_cost, animated_cost);
 
@@ -299,16 +302,16 @@ void BDFloaterComplexity::calcARC()
 								}
 
 								//BD - Count the texture impact and memory usage here now that we got all textures collected.
-								for (auto volume_texture : textures)
+								/*for (auto volume_texture : textures)
 								{
-									LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(volume_texture.first);
+									LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(volume_texture);
 									if (texture)
 									{
 										attachment_memory_usage += (texture->getTextureMemory() / 1024);
 									}
-									attachment_texture_cost += volume_texture.second;
+									//attachment_texture_cost += volume_texture.second;
 									++texture_count;
-								}
+								}*/
 
 								//BD - Final results.
 								//     Do not add HUDs to this.
@@ -522,7 +525,7 @@ void BDFloaterComplexity::checkObject(LLVOVolume* vovolume, LLVOVolume::texture_
 	//BD - Check all the easy costs and counts first.
 	volume_cost = vovolume->getRenderCost(textures);
 	base_cost += vovolume->mRenderComplexityBase;
-	total_triangles += vovolume->getHighLODTriangleCount64();
+	total_triangles += getHighLODTriangleCount64(vovolume);
 	total_vertices += vovolume->getNumVertices();
 }
 
@@ -583,4 +586,559 @@ void BDFloaterComplexity::onSelectAttachment()
 			}
 		}
 	}
+}
+
+void BDFloaterComplexity::getRenderCostValues(LLVOVolume* volume, U32& flexible_cost, U32& particle_cost, U32& light_cost, U32& projector_cost,
+	U32& alpha_cost, U32& rigged_cost, U32& animesh_cost, U32& media_cost, U32& bump_cost,
+	U32& shiny_cost, U32& glow_cost, U32& animated_cost) const
+{
+	/*****************************************************************
+	* This calculation should not be modified by third party viewers,
+	* since it is used to limit rendering and should be uniform for
+	* everyone. If you have suggested improvements, submit them to
+	* the official viewer for consideration.
+	*****************************************************************/
+
+	// Get access to params we'll need at various points.  
+	// Skip if this is object doesn't have a volume (e.g. is an avatar).
+	BOOL has_volume = (volume != NULL);
+	LLVolumeParams volume_params;
+	LLPathParams path_params;
+	LLProfileParams profile_params;
+
+	U32 num_triangles = 0;
+
+	//BD - Experimental new ARC
+	// per-prim costs
+	//BD - Particles need to be punished extremely harsh, they are besides all other features, the single biggest
+	//     performance hog in Second Life. Just having them enabled and a tiny bunch around drops the framerate
+	//     noticeably.
+	static const U32 ARC_PARTICLE_COST = 8; //16
+	//BD - Lights are an itchy thing. They don't have any impact if used carefully. They do however have an
+	//     increasingly bigger impact above a certain threshold at which they will significantly drop your average
+	//     FPS. We should punish them slightly but not too hard otherwise Avatars with a few lights get overpunished.
+	static const U32 ARC_LIGHT_COST = 256; //512
+	//BD - Projectors have a huge impact, whether or not they cast a shadow or not, multiple of these will make quick
+	//     work of any good framerate.
+	static const U32 ARC_PROJECTOR_COST = 8192; //16384
+	//BD - Media faces have a huge impact on performance, they should never ever be attached and should be used
+	//     carefully. Punish them with extreme measure, besides, by default we can only have 6-8 active at any time
+	//     those alone will significantly draw resources both RAM and FPS.
+	static const U32 ARC_MEDIA_FACE_COST = 50000; //100000 - static cost per media-enabled face 
+
+	// per-prim multipliers
+	//BD - Glow has nearly no impact, the impact is already there due to the omnipresent ambient glow Black Dragon
+	//     uses, putting up hundreds of glowing prims does nothing, it's a global post processing effect.
+	static const F32 ARC_GLOW_MULT = 0.05f;
+	//BD - Bump has nearly no impact, it's biggest impact is texture memory which we really shouldn't be including.
+	static const F32 ARC_BUMP_MULT = 0.05f;
+	//BD - I'm unsure about flexi, on one side its very efficient but if huge amounts of flexi are active at the same
+	//     time they can quickly become extremely slow which is hardly ever the case.
+	static const F32 ARC_FLEXI_MULT = 0.15f;
+	//BD - Shiny has nearly no impact, it's basically a global post process effect.
+	static const F32 ARC_SHINY_MULT = 0.05f;
+	//BD - Invisible prims are not rendered anymore in Black Dragon.
+	//static const F32 ARC_INVISI_COST = 1.0f;
+	//BD - Weighted mesh does have quite some impact and it only gets worse with more triangles to transform.
+	static const F32 ARC_WEIGHTED_MESH = 2.0f; //4.0
+
+	//BD - Animated textures hit quite hard, not as hard as quick alpha state changes.
+	static const F32 ARC_ANIM_TEX_COST = 1.f;
+	//BD - Alpha's are bad.
+	static const F32 ARC_ALPHA_COST = 1.0f;
+	//BD - Alpha's aren't that bad as normal alphas if they are rigged and worn, static ones are evil.
+	//     Besides, as long as they are fully invisible Black Dragon won't render them anyway.
+	static const F32 ARC_RIGGED_ALPHA_COST = 0.25f;
+	//BD - In theory animated mesh are pretty limited and they are rendering wise not different to normal avatars.
+	//     Thus they should not be weighted differently, however, since they are just basic dummy avatars with no
+	//     super extensive information, relations, name tag and so on they deserve a tiny complexity discount.
+	static const F32 ARC_ANIMATED_MESH_COST = -0.05f;
+
+	U32 shiny = 0;
+	U32 glow = 0;
+	U32 alpha = 0;
+	U32 animtex = 0;
+	U32 bump = 0;
+	U32 weighted_mesh = 0;
+	U32 media_faces = 0;
+
+	LLDrawable* drawablep = volume->mDrawable;
+	U32 num_faces = drawablep->getNumFaces();
+
+	if (has_volume)
+	{
+		volume_params = volume->getVolume()->getParams();
+		num_triangles = drawablep->getVOVolume()->getHighLODTriangleCount();
+	}
+
+	if (num_triangles == 0)
+	{
+		num_triangles = 4;
+	}
+
+	if (volume->isSculpted())
+	{
+		if (volume->isMesh())
+		{
+			S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(), volume->getLOD());
+			if (size > 0)
+			{
+				if (volume->getSkinInfo())
+				{
+					weighted_mesh = 1;
+				}
+			}
+		}
+	}
+
+	for (S32 i = 0; i < num_faces; ++i)
+	{
+		const LLFace* face = drawablep->getFace(i);
+		if (!face) continue;
+		const LLTextureEntry* te = face->getTextureEntry();
+
+		if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
+		{
+			alpha = 1;
+		}
+
+		if (face->hasMedia())
+		{
+			media_faces++;
+		}
+
+		if (te)
+		{
+			if (te->getBumpmap())
+			{
+				bump = 1;
+			}
+			if (te->getShiny())
+			{
+				shiny = 1;
+			}
+			if (te->getGlow() > 0.f)
+			{
+				glow = 1;
+			}
+			if (face->mTextureMatrix != NULL)
+			{
+				animtex = 1;
+			}
+		}
+	}
+
+	//BD - shame currently has the "base" cost of 1 point per 5 triangles, min 2.
+	U32 shame = volume->mRenderComplexityBase;
+
+	if (animtex)
+	{
+		animated_cost += (shame * ARC_ANIM_TEX_COST);
+	}
+
+	if (glow)
+	{
+		glow_cost += (shame * ARC_GLOW_MULT);
+	}
+
+	if (bump)
+	{
+		bump_cost += (shame * ARC_BUMP_MULT);
+	}
+
+	if (shiny)
+	{
+		shiny_cost += (shame * ARC_SHINY_MULT);
+	}
+
+	if (weighted_mesh)
+	{
+		rigged_cost += (shame * ARC_WEIGHTED_MESH);
+
+		if (alpha)
+		{
+			alpha_cost += (shame * ARC_ALPHA_COST);
+		}
+	}
+	else
+	{
+		if (alpha)
+		{
+			alpha_cost += (shame * ARC_RIGGED_ALPHA_COST);
+		}
+	}
+
+	if (volume->isAnimatedObject())
+	{
+		animesh_cost += (shame * ARC_ANIMATED_MESH_COST);
+	}
+
+	// multiply shame by multipliers
+	if (volume->isFlexible())
+	{
+		flexible_cost += (shame * ARC_FLEXI_MULT);
+	}
+
+	// add additional costs
+	if (volume->isParticleSource())
+	{
+		const LLPartSysData* part_sys_data = &(drawablep->getVObj()->getParticleSource()->mPartSysData);
+		const LLPartData* part_data = &(part_sys_data->mPartData);
+		U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil(part_data->mMaxAge / part_sys_data->mBurstRate));
+		//BD
+		F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f;
+		particle_cost += num_particles * part_size * ARC_PARTICLE_COST;
+	}
+
+	if (volume->getIsLight())
+	{
+		light_cost += ARC_LIGHT_COST;
+	}
+	else if (volume->getHasShadow())
+	{
+		projector_cost += ARC_PROJECTOR_COST;
+	}
+
+	if (media_faces)
+	{
+		media_cost += media_faces * ARC_MEDIA_FACE_COST;
+	}
+}
+
+//BD - Altered Complexity Calculation
+// Returns a base cost and adds textures to passed in set.
+// total cost is returned value + 5 * size of the resulting set.
+// Cannot include cost of textures, as they may be re-used in linked
+// children, and cost should only be increased for unique textures  -Nyx
+U32 BDFloaterComplexity::getRenderCost(LLVOVolume* volume, texture_cost& textures) const
+{
+	/*****************************************************************
+	 * This calculation should not be modified by third party viewers,
+	 * since it is used to limit rendering and should be uniform for
+	 * everyone. If you have suggested improvements, submit them to
+	 * the official viewer for consideration.
+	 *****************************************************************/
+
+	 // Get access to params we'll need at various points.  
+	 // Skip if this is object doesn't have a volume (e.g. is an avatar).
+	LLVolumeParams volume_params;
+	LLPathParams path_params;
+	LLProfileParams profile_params;
+
+	U32 num_triangles = 0;
+
+	//BD - Experimental new ARC
+	// per-prim costs
+	//BD - Particles need to be punished extremely harsh, they are besides all other features, the single biggest
+	//     performance hog in Second Life. Just having them enabled and a tiny bunch around drops the framerate
+	//     noticeably.
+	static const U32 ARC_PARTICLE_COST = 4; //16
+	//BD - Textures don't directly influence performance impact on a large scale but allocating a lot of textures
+	//     and filling the Viewer memory as well as texture memory grinds at the Viewer's overall performance, the
+	//     lost performance does not fully recover when leaving the area in question, textures overall have a lingering
+	//     performance impact that slowly drives down the Viewer's performance, we should punish them much harder.
+	//     Textures are not free after all and not everyone can have 2+GB texture memory for SL.
+	static const U32 ARC_TEXTURE_COST = 1.25; //5
+	//BD - Lights are an itchy thing. They don't have any impact if used carefully. They do however have an
+	//     increasingly bigger impact above a certain threshold at which they will significantly drop your average
+	//     FPS. We should punish them slightly but not too hard otherwise Avatars with a few lights get overpunished.
+	static const U32 ARC_LIGHT_COST = 128; //512
+	//BD - Projectors have a huge impact, whether or not they cast a shadow or not, multiple of these will make quick
+	//     work of any good framerate.
+	static const U32 ARC_PROJECTOR_COST = 4096; //16384
+	//BD - Media faces have a huge impact on performance, they should never ever be attached and should be used
+	//     carefully. Punish them with extreme measure, besides, by default we can only have 6-8 active at any time
+	//     those alone will significantly draw resources both RAM and FPS.
+	static const U32 ARC_MEDIA_FACE_COST = 25000; //100000 - static cost per media-enabled face 
+
+	// per-prim multipliers
+	//BD - Glow has nearly no impact, the impact is already there due to the omnipresent ambient glow Black Dragon
+	//     uses, putting up hundreds of glowing prims does nothing, it's a global post processing effect.
+	static const F32 ARC_GLOW_MULT = 0.05f;
+	//BD - Bump has nearly no impact, it's biggest impact is texture memory which we really shouldn't be including.
+	static const F32 ARC_BUMP_MULT = 0.05f;
+	//BD - I'm unsure about flexi, on one side its very efficient but if huge amounts of flexi are active at the same
+	//     time they can quickly become extremely slow which is hardly ever the case.
+	static const F32 ARC_FLEXI_MULT = 0.15f;
+	//BD - Shiny has nearly no impact, it's basically a global post process effect.
+	static const F32 ARC_SHINY_MULT = 0.05f;
+	//BD - Invisible prims are not rendered anymore in Black Dragon.
+	//static const F32 ARC_INVISI_COST = 1.0f;
+	//BD - Weighted mesh does have quite some impact and it only gets worse with more triangles to transform.
+	static const F32 ARC_WEIGHTED_MESH = 2.0f; //4.0
+
+	//BD - Animated textures hit quite hard, not as hard as quick alpha state changes.
+	static const F32 ARC_ANIM_TEX_COST = 1.f;
+	//BD - Alpha's are bad.
+	static const F32 ARC_ALPHA_COST = 1.0f;
+	//BD - Alpha's aren't that bad as normal alphas if they are rigged and worn, static ones are evil.
+	//     Besides, as long as they are fully invisible Black Dragon won't render them anyway.
+	static const F32 ARC_RIGGED_ALPHA_COST = 0.25f;
+	//BD - In theory animated mesh are pretty limited and they are rendering wise not different to normal avatars.
+	//     Thus they should not be weighted differently, however, since they are just basic dummy avatars with no
+	//     super extensive information, relations, name tag and so on they deserve a tiny complexity discount.
+	static const F32 ARC_ANIMATED_MESH_COST = -0.05f;
+
+	F32 shame = 0;
+
+	U32 shiny = 0;
+	U32 glow = 0;
+	U32 alpha = 0;
+	U32 animtex = 0;
+	U32 bump = 0;
+	U32 weighted_mesh = 0;
+	U32 animated_mesh = 0;
+	U32 media_faces = 0;
+
+	LLDrawable* drawablep = volume->mDrawable;
+	U32 num_faces = drawablep->getNumFaces();
+
+	if (volume->isMeshFast() && volume->getVolume())
+	{
+		volume_params = volume->getVolume()->getParams();
+		path_params = volume_params.getPathParams();
+		profile_params = volume_params.getProfileParams();
+
+		//BD - Punish high triangle counts.
+		num_triangles = drawablep->getVOVolume()->getHighLODTriangleCount();
+	}
+
+	if (num_triangles <= 0)
+	{
+		num_triangles = 4;
+	}
+
+	if (volume->isSculpted())
+	{
+		if (volume->isMesh())
+		{
+			// base cost is dependent on mesh complexity
+			// note that 3 is the highest LOD as of the time of this coding.
+			S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(), volume->getLOD());
+			if (size > 0)
+			{
+				if (volume->isRiggedMesh())
+				{
+					// weighted attachment - 1 point for every 3 bytes
+					weighted_mesh = 1;
+				}
+			}
+			else
+			{
+				// something went wrong - user should know their content isn't render-free
+				return 0;
+			}
+
+			if (volume->isAnimatedObject())
+			{
+				animated_mesh = 1;
+			}
+		}
+		else
+		{
+			const LLSculptParams* sculpt_params = (LLSculptParams*)drawablep->getVObj()->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+			LLUUID sculpt_id = sculpt_params->getSculptTexture();
+			LLViewerFetchedTexture* texture = LLViewerTextureManager::getFetchedTexture(sculpt_id);
+			if (textures.find(texture) == textures.end())
+			{
+				if (texture)
+				{
+					//BD - Punish sculpt usage compared to normal prims or the much faster mesh.
+					//S32 texture_cost = 256 + (S32)(((ARC_TEXTURE_COST * 2) * (texture->getFullHeight() * texture->getFullWidth())) / 1024);
+					//textures.insert(texture_cost::value_type(texture));
+					//vovolume->mRenderComplexityTextures += texture_cost;
+				}
+			}
+		}
+	}
+
+	for (S32 i = 0; i < num_faces; ++i)
+	{
+		const LLFace* face = drawablep->getFace(i);
+		if (!face) continue;
+		const LLTextureEntry* te = face->getTextureEntry();
+
+		S32 j = 0;
+		while (j < LLRender::NUM_TEXTURE_CHANNELS)
+		{
+			const LLViewerTexture* img = face->getTexture(j);
+			if (img)
+			{
+				if (textures.find(img) == textures.end())
+				{
+					S32 texture_cost = 256 + (S32)((ARC_TEXTURE_COST * (img->getFullHeight() * img->getFullWidth())) / 1024);
+					//textures.insert(texture_cost::value_type(img));
+					volume->mRenderComplexityTextures += texture_cost;
+				}
+			}
+			++j;
+		}
+
+		if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
+		{
+			alpha = 1;
+		}
+
+		if (face->hasMedia())
+		{
+			media_faces++;
+		}
+
+		if (te)
+		{
+			if (te->getBumpmap())
+			{
+				// bump is a multiplier, don't add per-face
+				bump = 1;
+			}
+			if (te->getShiny())
+			{
+				// shiny is a multiplier, don't add per-face
+				shiny = 1;
+				//BD
+				volume->setHasShiny(true);
+			}
+			if (te->getGlow() > 0.f)
+			{
+				// glow is a multiplier, don't add per-face
+				glow = 1;
+				//BD
+				volume->setHasGlow(true);
+			}
+			if (face->mTextureMatrix != NULL)
+			{
+				animtex = 1;
+				//BD
+				volume->setIsAnimated(true);
+			}
+		}
+	}
+
+	//BD - shame currently has the "base" cost of 1 point per 5 triangles, min 2.
+	shame = num_triangles / 10; //5
+	shame = shame < 2.f ? 2.f : shame;
+
+	volume->setRenderComplexityBase((S32)shame);
+	F32 extra_shame = 0.f;
+	if (animtex)
+	{
+		extra_shame += (shame * ARC_ANIM_TEX_COST);
+	}
+
+	if (glow)
+	{
+		extra_shame += (shame * ARC_GLOW_MULT);
+	}
+
+	if (bump)
+	{
+		extra_shame += (shame * ARC_BUMP_MULT);
+	}
+
+	if (shiny)
+	{
+		extra_shame += (shame * ARC_SHINY_MULT);
+	}
+
+	if (weighted_mesh)
+	{
+		extra_shame += (shame * ARC_WEIGHTED_MESH);
+
+		if (alpha)
+		{
+			extra_shame += (shame * ARC_ALPHA_COST);
+		}
+	}
+	else
+	{
+		if (alpha)
+		{
+			extra_shame += (shame * ARC_RIGGED_ALPHA_COST);
+		}
+	}
+
+	if (animated_mesh)
+	{
+		extra_shame += (shame * ARC_ANIMATED_MESH_COST);
+	}
+
+	// multiply shame by multipliers
+	if (volume->isFlexible())
+	{
+		extra_shame += (shame * ARC_FLEXI_MULT);
+	}
+
+	// Streaming cost for animated objects includes a fixed cost
+	// per linkset. Add a corresponding charge here translated into
+	// triangles, but not weighted by any graphics properties.
+	/*if (isAnimatedObject() && isRootEdit())
+	{
+		shame += (ANIMATED_OBJECT_BASE_COST / 0.06) * 5.0f;
+	}*/
+
+	// add additional costs
+	if (volume->isParticleSource())
+	{
+		const LLPartSysData* part_sys_data = &(drawablep->getVObj()->getParticleSource()->mPartSysData);
+		const LLPartData* part_data = &(part_sys_data->mPartData);
+		U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil(part_data->mMaxAge / part_sys_data->mBurstRate));
+		//BD
+		F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f;
+		shame += num_particles * part_size * ARC_PARTICLE_COST;
+	}
+
+	shame += extra_shame;
+
+	if (volume->getIsLight())
+	{
+		shame += ARC_LIGHT_COST;
+	}
+
+	if (volume->getHasShadow())
+	{
+		shame += ARC_PROJECTOR_COST;
+	}
+
+	if (media_faces)
+	{
+		shame += (media_faces * ARC_MEDIA_FACE_COST);
+	}
+
+	/*vovolume->mRenderComplexityTotal = (S32)shame;
+
+	if (shame > mRenderComplexity_current)
+	{
+		mRenderComplexity_current = (S32)shame;
+	}*/
+
+	return (U32)shame;
+}
+
+U64 BDFloaterComplexity::getHighLODTriangleCount64(LLVOVolume* volume)
+{
+	U64 ret = 0;
+	LLVolume* vol = volume->getVolume();
+
+	if (!volume->isSculpted())
+	{
+		LLVolume* ref = LLPrimitive::getVolumeManager()->refVolume(vol->getParams(), 3);
+		ret = ref->getNumTriangles64();
+		LLPrimitive::getVolumeManager()->unrefVolume(ref);
+	}
+	else if (volume->isMesh())
+	{
+		LLVolume* ref = LLPrimitive::getVolumeManager()->refVolume(vol->getParams(), 3);
+		if (!ref->isMeshAssetLoaded() || ref->getNumVolumeFaces() == 0)
+		{
+			gMeshRepo.loadMesh(volume, vol->getParams(), LLModel::LOD_HIGH);
+		}
+		ret = ref->getNumTriangles64();
+		LLPrimitive::getVolumeManager()->unrefVolume(ref);
+	}
+	else
+	{ //default sculpts have a constant number of triangles
+		ret = 31 * 2 * 31;  //31 rows of 31 columns of quads for a 32x32 vertex patch
+	}
+
+	return ret;
 }
\ No newline at end of file
diff --git a/indra/newview/bdfloatercomplexity.h b/indra/newview/bdfloatercomplexity.h
index 0e7e0e9083ed1fcdf5940e5796616530faed9cd1..b00a8dd69def727e37d66f8ba58a1099f19f343f 100644
--- a/indra/newview/bdfloatercomplexity.h
+++ b/indra/newview/bdfloatercomplexity.h
@@ -47,6 +47,14 @@ class BDFloaterComplexity :
 	void onSelectEntry();
 	void onSelectAttachment();
 
+	const typedef std::unordered_set<const LLViewerTexture*> texture_cost;
+	U32	 getRenderCost(LLVOVolume* volume, texture_cost& textures) const;
+	void getRenderCostValues(LLVOVolume* volume, U32& flexible_cost, U32& particle_cost, U32& light_cost, U32& projector_cost,
+							U32& alpha_cost, U32& rigged_cost, U32& animesh_cost, U32& media_cost, U32& bump_cost,
+							U32& shiny_cost, U32& glow_cost, U32& animated_cost) const;
+
+	U64  getHighLODTriangleCount64(LLVOVolume* volume);
+
 	/*virtual*/ void onOpen(const LLSD& key);
 	/*virtual*/	void onClose(bool app_quitting);
 
diff --git a/indra/newview/exopostprocess.cpp b/indra/newview/exopostprocess.cpp
index c9a396e43cb24f43abd745ff9de5be53bb89592f..d02deab647229b07fdd1df9ac0fdbeacb6f2a9fc 100644
--- a/indra/newview/exopostprocess.cpp
+++ b/indra/newview/exopostprocess.cpp
@@ -47,8 +47,8 @@ BOOL		exoPostProcess::sRenderLensFlare;
 exoPostProcess::exoPostProcess()
 {
     
-    mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1, 0);
-	mExoPostBuffer->allocateBuffer(8, 0, true);
+    mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1);
+	mExoPostBuffer->allocateBuffer(8, 0);
     
     LLStrider<LLVector3> vert; 
     mExoPostBuffer->getVertexStrider(vert);
@@ -161,14 +161,14 @@ void exoPostProcess::ExodusRenderPostSettingsUpdate()
 void exoPostProcess::ExodusRenderPostUpdate()
 {
     etc1.setVec(0,0);
-	etc2.setVec((F32) gPipeline.mScreen.getWidth(),
-               (F32) gPipeline.mScreen.getHeight());
+	etc2.setVec((F32) gPipeline.mRT->screen.getWidth(),
+               (F32) gPipeline.mRT->screen.getHeight());
     if (!gPipeline.sRenderDeferred)
     {
         // Destroy our old buffer, and create a new vertex buffer for the screen (shamelessly ganked from pipeline.cpp).
         mExoPostBuffer = NULL;
-        mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1, 0);
-		mExoPostBuffer->allocateBuffer(3,0,TRUE);
+        mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1);
+		mExoPostBuffer->allocateBuffer(3,0);
         
 		LLStrider<LLVector3> v;
 		LLStrider<LLVector2> uv1;
@@ -190,11 +190,11 @@ void exoPostProcess::ExodusRenderPostUpdate()
 		v[1] = LLVector3(-1,3,0);
 		v[2] = LLVector3(3,-1,0);
         
-		mExoPostBuffer->flush();
+		mExoPostBuffer->unmapBuffer();
     } else {
         mExoPostBuffer = NULL;
-        mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1, 0);
-        mExoPostBuffer->allocateBuffer(8, 0, true);
+        mExoPostBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1);
+        mExoPostBuffer->allocateBuffer(8, 0);
         
         LLStrider<LLVector3> vert; 
         mExoPostBuffer->getVertexStrider(vert);
@@ -242,7 +242,7 @@ void exoPostProcess::ExodusRenderToneMapping(LLRenderTarget *src, LLRenderTarget
     }
 
     shader->bind();
-    mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+    mExoPostBuffer->setBuffer();
     exoShader::BindRenderTarget(dst, shader, LLShaderMgr::EXO_RENDER_SCREEN, 0);
     shader->uniform1f(LLShaderMgr::EXO_RENDER_EXPOSURE, sExodusRenderToneExposure);
     if (type == EXODUS_RENDER_TONE_FILMIC_ADV)
@@ -265,7 +265,7 @@ void exoPostProcess::ExodusRenderColorGrade(LLRenderTarget *src, LLRenderTarget
         {
             src->bindTarget();
             gColorGradePost.bind();
-            mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+            mExoPostBuffer->setBuffer();
             exoShader::BindRenderTarget(dst, &gColorGradePost, LLShaderMgr::EXO_RENDER_SCREEN, 0);
             exoShader::BindTex2D(LLViewerFetchedTexture::sExodusColorGradeTexp, &gColorGradePost, LLShaderMgr::EXO_RENDER_GRADE, 1);
             
@@ -280,7 +280,7 @@ void exoPostProcess::ExodusRenderColorGrade(LLRenderTarget *src, LLRenderTarget
     {
         src->bindTarget();
         gColorGradePostLegacy.bind();
-        mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+        mExoPostBuffer->setBuffer();
         exoShader::BindRenderTarget(dst, &gColorGradePostLegacy, LLShaderMgr::EXO_RENDER_SCREEN, 0);
         
         gColorGradePostLegacy.uniform3fv(LLShaderMgr::EXO_RENDER_GAMMA, 1, sExodusRenderGamma.mV);
@@ -300,7 +300,7 @@ void exoPostProcess::ExodusRenderVignette(LLRenderTarget* src, LLRenderTarget* d
     LLGLSLShader *shader = &gVignettePost;
     shader->bind();
     
-    mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+    mExoPostBuffer->setBuffer();
     
     exoShader::BindRenderTarget(dst, shader, LLShaderMgr::EXO_RENDER_SCREEN);
     
@@ -318,7 +318,7 @@ void exoPostProcess::ExodusRenderSpecial(LLRenderTarget* src, LLRenderTarget* ds
     LLGLSLShader *shader = &gSpecialPost;
     shader->bind();
     
-    mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+    mExoPostBuffer->setBuffer();
     
     exoShader::BindRenderTarget(dst, shader, LLShaderMgr::EXO_RENDER_SCREEN);
     
@@ -338,7 +338,7 @@ void exoPostProcess::ExodusRenderLens(LLRenderTarget* src, LLRenderTarget* dst)
     LLGLSLShader *shader = &gLensFlare;
     shader->bind();
     
-    mExoPostBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+    mExoPostBuffer->setBuffer();
     
     exoShader::BindRenderTarget(dst, shader, LLShaderMgr::EXO_RENDER_SCREEN);
 
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index f8eb51a96232fee79ad239ecfc2811b50d98f68b..589f4de2ee932c357d0ab0b9fe2f7e8ce024539e 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1538,7 +1538,7 @@ bool LLAppViewer::doFrame()
 			{
 				LLPerfStats::RecordSceneTime T(LLPerfStats::StatType_t::RENDER_IDLE);
 				//BD
-				gJoystick->scanJoystick();k();
+				gJoystick->scanJoystick();
 				gKeyboard->scanKeyboard();
                 gViewerInput.scanMouse();
 			}
diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp
index 2359bc7880f27c1107e4324ee5b82004c5ddce4a..561b64cc4bf4d8747bcad9d0ecb2313d8adc33da 100644
--- a/indra/newview/llavatarrenderinfoaccountant.cpp
+++ b/indra/newview/llavatarrenderinfoaccountant.cpp
@@ -225,10 +225,10 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U
             !avatar->isControlAvatar() &&						// Not part of an animated object
             avatar->getObjectHost() == regionp->getHost())		// Ensure it's on the same region
         {
-            avatar->calculateUpdateOriginalRenderComplexity();	// Make sure the numbers are up-to-date
+            avatar->calculateUpdateRenderComplexity();	// Make sure the numbers are up-to-date
 
             LLSD info = LLSD::emptyMap();
-            U32 avatar_complexity = avatar->getOriginalVisualComplexity();
+            U32 avatar_complexity = avatar->getVisualComplexity();
             if (avatar_complexity > 0)
             {
                 // the weight/complexity is unsigned, but LLSD only stores signed integers,
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 411e580d217d1e15ddf7b211fdebb0f638d4724d..f2791cbd6bda20b9507e1cb17fc1b91b6c77093d 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -276,7 +276,7 @@ void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
 }
 
 //BD - Motion Blur
-void LLDrawPoolAvatar::beginMotionBlurPass(S32 pass)
+/*void LLDrawPoolAvatar::beginMotionBlurPass(S32 pass)
 {
 	glh::matrix4f last(gGLLastModelView);
 	glh::matrix4f last_inv = last.inverse();
@@ -359,7 +359,7 @@ void LLDrawPoolAvatar::renderMotionBlur(S32 pass)
 
 		avatarp->renderSkinned();
 	}
-}
+}*/
 
 
 S32 LLDrawPoolAvatar::getNumShadowPasses()
diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h
index 459a651de617196ace42813825cfe55658d84afd..ef3c43b48af779c7fa839b8b7f4d519e41cd4307 100644
--- a/indra/newview/lldrawpoolavatar.h
+++ b/indra/newview/lldrawpoolavatar.h
@@ -100,10 +100,10 @@ typedef enum
 	/*virtual*/ void renderShadow(S32 pass);
 
 //	//BD - Motion Blur
-	/*virtual*/ void beginMotionBlurPass(S32 pass);
-	/*virtual*/ void endMotionBlurPass(S32 pass);
-	/*virtual*/ S32 getNumMotionBlurPasses();
-	/*virtual*/ void renderMotionBlur(S32 pass = 0);
+	///*virtual*/ void beginMotionBlurPass(S32 pass);
+	///*virtual*/ void endMotionBlurPass(S32 pass);
+	///*virtual*/ S32 getNumMotionBlurPasses();
+	///*virtual*/ void renderMotionBlur(S32 pass = 0);
 	
 	void beginRigid();
 	void beginImpostor();
diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h
index 1d085e2ee46aafd72c2dacd41858049d921f0454..7f1945356720946ff9e1ccbd97210d4c3e4456fe 100644
--- a/indra/newview/llfloatereditextdaycycle.h
+++ b/indra/newview/llfloatereditextdaycycle.h
@@ -97,10 +97,12 @@ class LLFloaterEditExtDayCycle : public LLFloater
     LLUUID                      getEditingAssetId() { return mEditDay ? mEditDay->getAssetId() : LLUUID::null; }
     LLUUID                      getEditingInventoryId() { return mInventoryId; }
 
+    virtual LLSettingsBase::ptr_t getEditSettings()   const { return mEditDay; }
 
     BOOL			            handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) override;
 
-    BOOL                        isDirty() const override { return getIsDirty(); } 
+protected:
+    virtual void                setEditSettingsAndUpdate(const LLSettingsBase::ptr_t& settings);
 
 private:
     typedef std::function<void()> on_confirm_fn;
diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp
index 18b7dc72eae1c3fa7342a62a714fe68f95aba484..982b2415f5c0d6259949a5e2f8038b56779fd3e9 100644
--- a/indra/newview/llfloaterenvironmentadjust.cpp
+++ b/indra/newview/llfloaterenvironmentadjust.cpp
@@ -307,7 +307,6 @@ void LLFloaterEnvironmentAdjust::onClose(bool app_quitting)
 //-------------------------------------------------------------------------
 void LLFloaterEnvironmentAdjust::refresh()
 {
-<<<<<<< HEAD
 	if (!mLiveSky)
 	{
 		setAllChildrenEnabled(FALSE);
@@ -866,7 +865,7 @@ void LLFloaterEnvironmentAdjust::onButtonDelete()
 
 void LLFloaterEnvironmentAdjust::onButtonImport()
 {   // Load a a legacy Windlight XML from disk.
-	(new LLFilePickerReplyThread(boost::bind(&LLFloaterEnvironmentAdjust::loadSkySettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile();
+	LLFilePickerReplyThread::startPicker(boost::bind(&LLFloaterEnvironmentAdjust::loadSkySettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false);
 }
 
 void LLFloaterEnvironmentAdjust::loadSkySettingFromFile(const std::vector<std::string>& filenames)
diff --git a/indra/newview/llfloaterenvironmentadjust.h b/indra/newview/llfloaterenvironmentadjust.h
index c36119aba215e92b80c9187bd704098b5a627cf9..eab836e6c5f30e4856118b0dcdf217985d8c7b1c 100644
--- a/indra/newview/llfloaterenvironmentadjust.h
+++ b/indra/newview/llfloaterenvironmentadjust.h
@@ -119,8 +119,6 @@ class LLFloaterEnvironmentAdjust : public LLFloater
 
 	void						loadSkySettingFromFile(const std::vector<std::string>& filenames);
 
-    void                        onButtonReset();
-
     LLSettingsSky::ptr_t        mLiveSky;
     LLEnvironment::connection_t mEventConnection;
 
diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp
index b674ca9b8a9d378cdbf1aa753bb109d2552e2f05..e82e89e6ac6466628bc098364a78f6aecee2d986 100644
--- a/indra/newview/llfloaterfixedenvironment.cpp
+++ b/indra/newview/llfloaterfixedenvironment.cpp
@@ -258,7 +258,8 @@ void LLFloaterFixedEnvironment::refresh()
 
 void LLFloaterFixedEnvironment::populatePresetsList()
 {
-    mSettings = settings; // shouldn't this do buildDeepCloneAndUncompress() ?
+	if (!mSettings)
+		return;
     updateEditEnvironment();
     syncronizeTabs();
     refresh();
diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp
index d1765b6844ac19d59a61e8dc469c360ca9ec8a20..d7fba96221b018140a2a3119a7e22d9fb75ae82e 100644
--- a/indra/newview/llfloaterimsession.cpp
+++ b/indra/newview/llfloaterimsession.cpp
@@ -1128,10 +1128,12 @@ void LLFloaterIMSession::processAgentListUpdates(const LLSD& body)
 	if (body.isMap() && body.has("agent_updates") && body["agent_updates"].isMap())
 	{
 		LLSD::map_const_iterator update_it;
-		for(const auto& agent_update : body["agent_updates"].map())
+		for (update_it = body["agent_updates"].beginMap();
+			update_it != body["agent_updates"].endMap();
+			++update_it)
 		{
-			LLUUID agent_id(agent_update.first);
-			LLSD agent_data = agent_update.second;
+			LLUUID agent_id(update_it->first);
+			LLSD agent_data = update_it->second;
 
 			if (agent_data.isMap())
 			{
diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp
deleted file mode 100644
index 19fc3e673e41f0a2523291cf7fcb14fa24528ad5..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterperformance.cpp
+++ /dev/null
@@ -1,748 +0,0 @@
-/** 
- * @file llfloaterperformance.cpp
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2021, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llfloaterperformance.h"
-
-#include "llagent.h"
-#include "llagentcamera.h"
-#include "llappearancemgr.h"
-#include "llavataractions.h"
-#include "llavatarrendernotifier.h"
-#include "llcheckboxctrl.h"
-#include "llcombobox.h"
-#include "llfeaturemanager.h"
-#include "llfloaterpreference.h" // LLAvatarComplexityControls
-#include "llfloaterreg.h"
-#include "llnamelistctrl.h"
-#include "llnotificationsutil.h"
-#include "llperfstats.h"
-#include "llpresetsmanager.h"
-#include "llradiogroup.h"
-#include "llsliderctrl.h"
-#include "lltextbox.h"
-#include "lltrans.h"
-#include "llviewerobjectlist.h"
-#include "llviewerwindow.h"
-#include "llvoavatar.h"
-#include "llvoavatarself.h"
-#include "llworld.h"
-#include "pipeline.h"
-
-const F32 REFRESH_INTERVAL = 1.0f;
-const S32 BAR_LEFT_PAD = 2;
-const S32 BAR_RIGHT_PAD = 5;
-const S32 BAR_BOTTOM_PAD = 9;
-
-class LLExceptionsContextMenu : public LLListContextMenu
-{
-public:
-    LLExceptionsContextMenu(LLFloaterPerformance* floater_settings)
-        :   mFloaterPerformance(floater_settings)
-    {}
-protected:
-    LLContextMenu* createMenu()
-    {
-        LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-        LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
-        registrar.add("Settings.SetRendering", boost::bind(&LLFloaterPerformance::onCustomAction, mFloaterPerformance, _2, mUUIDs.front()));
-        enable_registrar.add("Settings.IsSelected", boost::bind(&LLFloaterPerformance::isActionChecked, mFloaterPerformance, _2, mUUIDs.front()));
-        LLContextMenu* menu = createFromFile("menu_avatar_rendering_settings.xml");
-
-        return menu;
-    }
-
-    LLFloaterPerformance* mFloaterPerformance;
-};
-
-LLFloaterPerformance::LLFloaterPerformance(const LLSD& key)
-:   LLFloater(key),
-    mUpdateTimer(new LLTimer())
-{
-    mContextMenu = new LLExceptionsContextMenu(this);
-}
-
-LLFloaterPerformance::~LLFloaterPerformance()
-{
-    mMaxARTChangedSignal.disconnect();
-    delete mContextMenu;
-    delete mUpdateTimer;
-}
-
-BOOL LLFloaterPerformance::postBuild()
-{
-    mMainPanel = getChild<LLPanel>("panel_performance_main");
-    mNearbyPanel = getChild<LLPanel>("panel_performance_nearby");
-    mComplexityPanel = getChild<LLPanel>("panel_performance_complexity");
-    mSettingsPanel = getChild<LLPanel>("panel_performance_preferences");
-    mHUDsPanel = getChild<LLPanel>("panel_performance_huds");
-    mAutoadjustmentsPanel = getChild<LLPanel>("panel_performance_autoadjustments");
-
-    getChild<LLPanel>("nearby_subpanel")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::showSelectedPanel, this, mNearbyPanel));
-    getChild<LLPanel>("complexity_subpanel")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::showSelectedPanel, this, mComplexityPanel));
-    getChild<LLPanel>("settings_subpanel")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::showSelectedPanel, this, mSettingsPanel));
-    getChild<LLPanel>("huds_subpanel")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::showSelectedPanel, this, mHUDsPanel));
-    getChild<LLPanel>("autoadjustments_subpanel")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::showSelectedPanel, this, mAutoadjustmentsPanel));
-
-    initBackBtn(mNearbyPanel);
-    initBackBtn(mComplexityPanel);
-    initBackBtn(mSettingsPanel);
-    initBackBtn(mHUDsPanel);
-    initBackBtn(mAutoadjustmentsPanel);
-
-    mHUDList = mHUDsPanel->getChild<LLNameListCtrl>("hud_list");
-    mHUDList->setNameListType(LLNameListCtrl::SPECIAL);
-    mHUDList->setHoverIconName("StopReload_Off");
-    mHUDList->setIconClickedCallback(boost::bind(&LLFloaterPerformance::detachItem, this, _1));
-
-    mObjectList = mComplexityPanel->getChild<LLNameListCtrl>("obj_list");
-    mObjectList->setNameListType(LLNameListCtrl::SPECIAL);
-    mObjectList->setHoverIconName("StopReload_Off");
-    mObjectList->setIconClickedCallback(boost::bind(&LLFloaterPerformance::detachItem, this, _1));
-
-    mSettingsPanel->getChild<LLButton>("advanced_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickAdvanced, this));
-    mSettingsPanel->getChild<LLButton>("defaults_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickDefaults, this));
-    mSettingsPanel->getChild<LLRadioGroup>("graphics_quality")->setCommitCallback(boost::bind(&LLFloaterPerformance::onChangeQuality, this, _2));
-    mSettingsPanel->getChild<LLCheckBoxCtrl>("advanced_lighting_model")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::onClickAdvancedLighting, this));
-    mSettingsPanel->getChild<LLComboBox>("ShadowDetail")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::onClickShadows, this));
-
-    mNearbyPanel->getChild<LLButton>("exceptions_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickExceptions, this));
-    mNearbyPanel->getChild<LLCheckBoxCtrl>("hide_avatars")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickHideAvatars, this));
-    mNearbyPanel->getChild<LLCheckBoxCtrl>("hide_avatars")->set(!LLPipeline::hasRenderTypeControl(LLPipeline::RENDER_TYPE_AVATAR));
-    mNearbyList = mNearbyPanel->getChild<LLNameListCtrl>("nearby_list");
-    mNearbyList->setRightMouseDownCallback(boost::bind(&LLFloaterPerformance::onAvatarListRightClick, this, _1, _2, _3));
-
-    mMaxARTChangedSignal = gSavedSettings.getControl("RenderAvatarMaxART")->getCommitSignal()->connect(boost::bind(&LLFloaterPerformance::updateMaxRenderTime, this));
-    mNearbyPanel->getChild<LLSliderCtrl>("RenderAvatarMaxART")->setCommitCallback(boost::bind(&LLFloaterPerformance::updateMaxRenderTime, this));
-
-    if(!LLPerfStats::tunables.userAutoTuneEnabled)
-    {
-        gSavedSettings.setF32("AutoTuneRenderFarClipTarget", LLPipeline::RenderFarClip);
-    }
-
-    LLStringExplicit fps_limit(llformat("%d", gViewerWindow->getWindow()->getRefreshRate()));
-    mAutoadjustmentsPanel->getChild<LLTextBox>("vsync_desc_limit")->setTextArg("[FPS_LIMIT]", fps_limit);
-    mAutoadjustmentsPanel->getChild<LLTextBox>("display_desc")->setTextArg("[FPS_LIMIT]", fps_limit);
-    mAutoadjustmentsPanel->getChild<LLButton>("defaults_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickDefaults, this));
-
-    mStartAutotuneBtn = mAutoadjustmentsPanel->getChild<LLButton>("start_autotune");
-    mStopAutotuneBtn = mAutoadjustmentsPanel->getChild<LLButton>("stop_autotune");
-    mStartAutotuneBtn->setCommitCallback(boost::bind(&LLFloaterPerformance::startAutotune, this));
-    mStopAutotuneBtn->setCommitCallback(boost::bind(&LLFloaterPerformance::stopAutotune, this));
-
-    gSavedPerAccountSettings.declareBOOL("HadEnabledAutoFPS", FALSE, "User had enabled AutoFPS at least once", LLControlVariable::PERSIST_ALWAYS);
-
-    return TRUE;
-}
-
-void LLFloaterPerformance::showSelectedPanel(LLPanel* selected_panel)
-{
-    hidePanels();
-    mMainPanel->setVisible(FALSE);
-    selected_panel->setVisible(TRUE);
-
-    if (mHUDsPanel == selected_panel)
-    {
-        populateHUDList();
-    }
-    else if (mNearbyPanel == selected_panel)
-    {
-        populateNearbyList();
-    }
-    else if (mComplexityPanel == selected_panel)
-    {
-        populateObjectList();
-    }
-}
-
-void LLFloaterPerformance::showAutoadjustmentsPanel()
-{
-    showSelectedPanel(mAutoadjustmentsPanel);
-}
-
-void LLFloaterPerformance::draw()
-{
-    enableAutotuneWarning();
-
-    if (mUpdateTimer->hasExpired() && 
-        !LLFloaterReg::instanceVisible("save_pref_preset", PRESETS_GRAPHIC)) // give user a chance to save the graphics settings before updating them
-    {
-        setFPSText();
-        if (mHUDsPanel->getVisible())
-        {
-            populateHUDList();
-        }
-        else if (mNearbyPanel->getVisible())
-        {
-            populateNearbyList();
-            mNearbyPanel->getChild<LLCheckBoxCtrl>("hide_avatars")->set(!LLPipeline::hasRenderTypeControl(LLPipeline::RENDER_TYPE_AVATAR));
-        }
-        else if (mComplexityPanel->getVisible())
-        {
-            populateObjectList();
-        }
-
-        mUpdateTimer->setTimerExpirySec(REFRESH_INTERVAL);
-    }
-    updateAutotuneCtrls(LLPerfStats::tunables.userAutoTuneEnabled);
-
-    LLFloater::draw();
-}
-
-void LLFloaterPerformance::showMainPanel()
-{
-    hidePanels();
-    mMainPanel->setVisible(TRUE);
-}
-
-void LLFloaterPerformance::hidePanels()
-{
-    mNearbyPanel->setVisible(FALSE);
-    mComplexityPanel->setVisible(FALSE);
-    mHUDsPanel->setVisible(FALSE);
-    mSettingsPanel->setVisible(FALSE);
-    mAutoadjustmentsPanel->setVisible(FALSE);
-}
-
-void LLFloaterPerformance::initBackBtn(LLPanel* panel)
-{
-    panel->getChild<LLButton>("back_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::showMainPanel, this));
-
-    panel->getChild<LLTextBox>("back_lbl")->setShowCursorHand(false);
-    panel->getChild<LLTextBox>("back_lbl")->setSoundFlags(LLView::MOUSE_UP);
-    panel->getChild<LLTextBox>("back_lbl")->setClickedCallback(boost::bind(&LLFloaterPerformance::showMainPanel, this));
-}
-
-void LLFloaterPerformance::populateHUDList()
-{
-    S32 prev_pos = mHUDList->getScrollPos();
-    LLUUID prev_selected_id = mHUDList->getSelectedSpecialId();
-    mHUDList->clearRows();
-    mHUDList->updateColumns(true);
-
-    LLVOAvatar* avatar = gAgentAvatarp;
-
-    gPipeline.profileAvatar(avatar, true);
-
-    LLVOAvatar::attachment_map_t::iterator iter;
-    LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin();
-    LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end();
-
-    // get max gpu render time of all attachments
-    F32 max_gpu_time = -1.f;
-
-    for (iter = begin; iter != end; ++iter)
-    {
-        LLViewerJointAttachment* attachment = iter->second;
-        for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-            attachment_iter != attachment->mAttachedObjects.end();
-            ++attachment_iter)
-        {
-            LLViewerObject* attached_object = attachment_iter->get();
-            if (attached_object && attached_object->isHUDAttachment())
-            {
-                max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime);
-            }
-        }
-    }
-
-
-    for (iter = begin; iter != end; ++iter)
-    {
-        if (!iter->second)
-        {
-            continue;
-        }
-
-        LLViewerJointAttachment* attachment = iter->second;
-        for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-            attachment_iter != attachment->mAttachedObjects.end();
-            ++attachment_iter)
-        {
-            LLViewerObject* attached_object = attachment_iter->get();
-            if (attached_object && attached_object->isHUDAttachment())
-            {
-                F32 gpu_time = attached_object->mGPURenderTime;
-
-                LLSD item;
-                item["special_id"] = attached_object->getID();
-                item["target"] = LLNameListCtrl::SPECIAL;
-                LLSD& row = item["columns"];
-                row[0]["column"] = "complex_visual";
-                row[0]["type"] = "bar";
-                LLSD& value = row[0]["value"];
-                value["ratio"] = gpu_time / max_gpu_time;
-                value["bottom"] = BAR_BOTTOM_PAD;
-                value["left_pad"] = BAR_LEFT_PAD;
-                value["right_pad"] = BAR_RIGHT_PAD;
-
-                row[1]["column"] = "complex_value";
-                row[1]["type"] = "text";
-                // show gpu time in us
-                row[1]["value"] = llformat("%.f", gpu_time * 1000.f);
-                row[1]["font"]["name"] = "SANSSERIF";
-
-                row[2]["column"] = "name";
-                row[2]["type"] = "text";
-                row[2]["value"] = attached_object->getAttachmentItemName();
-                row[2]["font"]["name"] = "SANSSERIF";
-
-                LLScrollListItem* obj = mHUDList->addElement(item);
-                if (obj)
-                {
-                    LLScrollListText* value_text = dynamic_cast<LLScrollListText*>(obj->getColumn(1));
-                    if (value_text)
-                    {
-                        value_text->setAlignment(LLFontGL::HCENTER);
-                    }
-                }
-            }
-        }
-    }
-    mHUDList->sortByColumnIndex(1, FALSE);
-    mHUDList->setScrollPos(prev_pos);
-    mHUDList->selectItemBySpecialId(prev_selected_id);
-}
-
-void LLFloaterPerformance::populateObjectList()
-{
-    S32 prev_pos = mObjectList->getScrollPos();
-    LLUUID prev_selected_id = mObjectList->getSelectedSpecialId();
-    mObjectList->clearRows();
-    mObjectList->updateColumns(true);
-
-    LLVOAvatar* avatar = gAgentAvatarp;
-
-    gPipeline.profileAvatar(avatar, true);
-
-    LLVOAvatar::attachment_map_t::iterator iter;
-    LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin();
-    LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end();
-
-    // get max gpu render time of all attachments
-    F32 max_gpu_time = -1.f;
-
-    for (iter = begin; iter != end; ++iter)
-    {
-        LLViewerJointAttachment* attachment = iter->second;
-        for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-            attachment_iter != attachment->mAttachedObjects.end();
-            ++attachment_iter)
-        {
-            LLViewerObject* attached_object = attachment_iter->get();
-            if (attached_object && !attached_object->isHUDAttachment())
-            {
-                max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime);
-            }
-        }
-    }
-
-    {
-        for (iter = begin; iter != end; ++iter)
-        {
-            if (!iter->second)
-            {
-                continue;
-            }
-
-            LLViewerJointAttachment* attachment = iter->second;
-            for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-                attachment_iter != attachment->mAttachedObjects.end();
-                ++attachment_iter)
-            {
-                LLViewerObject* attached_object = attachment_iter->get();
-                if (attached_object && !attached_object->isHUDAttachment())
-                {
-                    F32 gpu_time = attached_object->mGPURenderTime;
-
-                    LLSD item;
-                    item["special_id"] = attached_object->getID();
-                    item["target"] = LLNameListCtrl::SPECIAL;
-                    LLSD& row = item["columns"];
-                    row[0]["column"] = "complex_visual";
-                    row[0]["type"] = "bar";
-                    LLSD& value = row[0]["value"];
-                    value["ratio"] = gpu_time / max_gpu_time;
-                    value["bottom"] = BAR_BOTTOM_PAD;
-                    value["left_pad"] = BAR_LEFT_PAD;
-                    value["right_pad"] = BAR_RIGHT_PAD;
-
-                    row[1]["column"] = "complex_value";
-                    row[1]["type"] = "text";
-                    // show gpu time in us
-                    row[1]["value"] = llformat("%.f", gpu_time * 1000.f);
-                    row[1]["font"]["name"] = "SANSSERIF";
-
-                    row[2]["column"] = "name";
-                    row[2]["type"] = "text";
-                    row[2]["value"] = attached_object->getAttachmentItemName();
-                    row[2]["font"]["name"] = "SANSSERIF";
-
-                    LLScrollListItem* obj = mObjectList->addElement(item);
-                    if (obj)
-                    {
-                        LLScrollListText* value_text = dynamic_cast<LLScrollListText*>(obj->getColumn(1));
-                        if (value_text)
-                        {
-                            value_text->setAlignment(LLFontGL::HCENTER);
-                        }
-                    }
-                }
-            }
-        }
-    }
-    mObjectList->sortByColumnIndex(1, FALSE);
-    mObjectList->setScrollPos(prev_pos);
-    mObjectList->selectItemBySpecialId(prev_selected_id);
-}
-
-void LLFloaterPerformance::populateNearbyList()
-{
-    LL_PROFILE_ZONE_SCOPED_CATEGORY_APP;
-    static LLCachedControl<bool> showTunedART(gSavedSettings, "ShowTunedART");
-    S32 prev_pos = mNearbyList->getScrollPos();
-    LLUUID prev_selected_id = mNearbyList->getStringUUIDSelectedItem();
-    mNearbyList->clearRows();
-    mNearbyList->updateColumns(true);
-
-    static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0);
-    std::vector<LLCharacter*> valid_nearby_avs;
-    mNearbyMaxGPUTime = LLWorld::getInstance()->getNearbyAvatarsAndMaxGPUTime(valid_nearby_avs);
-
-    std::vector<LLCharacter*>::iterator char_iter = valid_nearby_avs.begin();
-
-    while (char_iter != valid_nearby_avs.end())
-    {
-        LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*char_iter);
-        if (avatar && (LLVOAvatar::AOA_INVISIBLE != avatar->getOverallAppearance()))
-        {
-            F32 render_av_gpu_ms = avatar->getGPURenderTime();
-
-            auto is_slow = avatar->isTooSlow();
-            LLSD item;
-            item["id"] = avatar->getID();
-            LLSD& row = item["columns"];
-            row[0]["column"] = "complex_visual";
-            row[0]["type"] = "bar";
-            LLSD& value = row[0]["value"];
-            // The ratio used in the bar is the current cost, as soon as we take action this changes so we keep the 
-            // pre-tune value for the numerical column and sorting.
-            value["ratio"] = render_av_gpu_ms / mNearbyMaxGPUTime;
-            value["bottom"] = BAR_BOTTOM_PAD;
-            value["left_pad"] = BAR_LEFT_PAD;
-            value["right_pad"] = BAR_RIGHT_PAD;
-
-            row[1]["column"] = "complex_value";
-            row[1]["type"] = "text";
-            // use GPU time in us
-            row[1]["value"] = llformat( "%.f", render_av_gpu_ms * 1000.f);
-            row[1]["font"]["name"] = "SANSSERIF";
-
-            row[3]["column"] = "name";
-            row[3]["type"] = "text";
-            row[3]["value"] = avatar->getFullname();
-            row[3]["font"]["name"] = "SANSSERIF";
-
-            LLScrollListItem* av_item = mNearbyList->addElement(item);
-            if(av_item)
-            {
-                LLScrollListText* value_text = dynamic_cast<LLScrollListText*>(av_item->getColumn(1));
-                if (value_text)
-                {
-                    value_text->setAlignment(LLFontGL::HCENTER);
-                }
-                LLScrollListText* name_text = dynamic_cast<LLScrollListText*>(av_item->getColumn(2));
-                if (name_text)
-                {
-                    if (avatar->isSelf())
-                    {
-                        name_text->setColor(LLUIColorTable::instance().getColor("DrYellow"));
-                    }
-                    else
-                    {
-                        std::string color = "white";
-                        if (is_slow || LLVOAvatar::AOA_JELLYDOLL == avatar->getOverallAppearance())
-                        {
-                            color = "LabelDisabledColor";
-                            LLScrollListBar* bar = dynamic_cast<LLScrollListBar*>(av_item->getColumn(0));
-                            if (bar)
-                            {
-                                bar->setColor(LLUIColorTable::instance().getColor(color));
-                            }
-                        }
-                        else if (LLVOAvatar::AOA_NORMAL == avatar->getOverallAppearance())
-                        {
-                            color = LLAvatarActions::isFriend(avatar->getID()) ? "ConversationFriendColor" : "white";
-                        }
-                        name_text->setColor(LLUIColorTable::instance().getColor(color));
-                    }
-                }
-            }
-        }
-        char_iter++;
-    }
-    mNearbyList->sortByColumnIndex(1, FALSE);
-    mNearbyList->setScrollPos(prev_pos);
-    mNearbyList->selectByID(prev_selected_id);
-}
-
-void LLFloaterPerformance::setFPSText()
-{
-    const S32 NUM_PERIODS = 50;
-    S32 current_fps = (S32)llround(LLTrace::get_frame_recording().getPeriodMedianPerSec(LLStatViewer::FPS, NUM_PERIODS));
-    getChild<LLTextBox>("fps_value")->setValue(current_fps);
-
-    std::string fps_text = getString("fps_text");
-    static LLCachedControl<bool> vsync_enabled(gSavedSettings, "RenderVSyncEnable", true);
-    S32 refresh_rate = gViewerWindow->getWindow()->getRefreshRate();
-    if (vsync_enabled && (refresh_rate > 0) && (current_fps >= refresh_rate))
-    {
-        fps_text += getString("max_text");
-    }
-    getChild<LLTextBox>("fps_lbl")->setValue(fps_text);
-}
-
-void LLFloaterPerformance::detachItem(const LLUUID& item_id)
-{
-    LLAppearanceMgr::instance().removeItemFromAvatar(item_id);
-}
-
-void LLFloaterPerformance::onClickAdvanced()
-{
-    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->saveSettings();
-    }
-    LLFloaterReg::showInstance("prefs_graphics_advanced");
-}
-
-void LLFloaterPerformance::onClickDefaults()
-{
-    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->setRecommendedSettings();
-    }
-}
-
-void LLFloaterPerformance::onChangeQuality(const LLSD& data)
-{
-    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->onChangeQuality(data);
-    }
-}
-
-void LLFloaterPerformance::onClickHideAvatars()
-{
-    LLPipeline::toggleRenderTypeControl(LLPipeline::RENDER_TYPE_AVATAR);
-}
-
-void LLFloaterPerformance::onClickExceptions()
-{
-    LLFloaterReg::showInstance("avatar_render_settings");
-}
-
-void LLFloaterPerformance::updateMaxRenderTime()
-{
-    LLAvatarComplexityControls::updateMaxRenderTime(
-        mNearbyPanel->getChild<LLSliderCtrl>("RenderAvatarMaxART"),
-        mNearbyPanel->getChild<LLTextBox>("RenderAvatarMaxARTText"), 
-        true);
-}
-
-static LLVOAvatar* find_avatar(const LLUUID& id)
-{
-    LLViewerObject *obj = gObjectList.findObject(id);
-    while (obj && obj->isAttachment())
-    {
-        obj = (LLViewerObject *)obj->getParent();
-    }
-
-    if (obj && obj->isAvatar())
-    {
-        return (LLVOAvatar*)obj;
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-void LLFloaterPerformance::onCustomAction(const LLSD& userdata, const LLUUID& av_id)
-{
-    const std::string command_name = userdata.asString();
-
-    S32 new_setting = 0;
-    if ("default" == command_name)
-    {
-        new_setting = S32(LLVOAvatar::AV_RENDER_NORMALLY);
-    }
-    else if ("never" == command_name)
-    {
-        new_setting = S32(LLVOAvatar::AV_DO_NOT_RENDER);
-    }
-    else if ("always" == command_name)
-    {
-        new_setting = S32(LLVOAvatar::AV_ALWAYS_RENDER);
-    }
-
-    LLVOAvatar *avatarp = find_avatar(av_id);
-    if (avatarp)
-    {
-        avatarp->setVisualMuteSettings(LLVOAvatar::VisualMuteSettings(new_setting));
-    }
-    else
-    {
-        LLRenderMuteList::getInstance()->saveVisualMuteSetting(av_id, new_setting);
-    }
-}
-
-
-bool LLFloaterPerformance::isActionChecked(const LLSD& userdata, const LLUUID& av_id)
-{
-    const std::string command_name = userdata.asString();
-
-    S32 visual_setting = LLRenderMuteList::getInstance()->getSavedVisualMuteSetting(av_id);
-    if ("default" == command_name)
-    {
-        return (visual_setting == S32(LLVOAvatar::AV_RENDER_NORMALLY));
-    }
-    else if ("non_default" == command_name)
-    {
-        return (visual_setting != S32(LLVOAvatar::AV_RENDER_NORMALLY));
-    }
-    else if ("never" == command_name)
-    {
-        return (visual_setting == S32(LLVOAvatar::AV_DO_NOT_RENDER));
-    }
-    else if ("always" == command_name)
-    {
-        return (visual_setting == S32(LLVOAvatar::AV_ALWAYS_RENDER));
-    }
-    return false;
-}
-
-void LLFloaterPerformance::onAvatarListRightClick(LLUICtrl* ctrl, S32 x, S32 y)
-{
-    LLNameListCtrl* list = dynamic_cast<LLNameListCtrl*>(ctrl);
-    if (!list) return;
-    list->selectItemAt(x, y, MASK_NONE);
-    uuid_vec_t selected_uuids;
-
-    if((list->getCurrentID().notNull()) && (list->getCurrentID() != gAgentID))
-    {
-        selected_uuids.push_back(list->getCurrentID());
-        mContextMenu->show(ctrl, selected_uuids, x, y);
-    }
-}
-
-const U32 RENDER_QUALITY_LEVEL = 3;
-void LLFloaterPerformance::changeQualityLevel(const std::string& notif)
-{
-    LLNotificationsUtil::add(notif, LLSD(), LLSD(),
-        [](const LLSD&notif, const LLSD&resp)
-    {
-        S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp);
-        if (opt == 0)
-        {
-            LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-            if (instance)
-            {
-                gSavedSettings.setU32("RenderQualityPerformance", RENDER_QUALITY_LEVEL);
-                instance->onChangeQuality(LLSD((S32)RENDER_QUALITY_LEVEL));
-            }
-        }
-    });
-}
-
-bool is_ALM_available()
-{
-    bool bumpshiny = LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump");
-    bool shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders");
-    
-    return LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-        bumpshiny &&
-        shaders;
-}
-
-void LLFloaterPerformance::onClickAdvancedLighting()
-{
-    if (!is_ALM_available())
-    {
-        changeQualityLevel("AdvancedLightingConfirm");
-    }
-}
-
-void LLFloaterPerformance::onClickShadows()
-{
-    if (!is_ALM_available() || !gSavedSettings.getBOOL("RenderDeferred"))
-    {
-        changeQualityLevel("ShadowsConfirm");
-    }
-
-}
-
-void LLFloaterPerformance::startAutotune()
-{
-    LLPerfStats::tunables.userAutoTuneEnabled = true;
-}
-
-void LLFloaterPerformance::stopAutotune()
-{
-    LLPerfStats::tunables.userAutoTuneEnabled = false;
-}
-
-void LLFloaterPerformance::updateAutotuneCtrls(bool autotune_enabled)
-{
-    static LLCachedControl<bool> auto_tune_locked(gSavedSettings, "AutoTuneLock");
-    mStartAutotuneBtn->setEnabled(!autotune_enabled && !auto_tune_locked);
-    mStopAutotuneBtn->setEnabled(autotune_enabled && !auto_tune_locked);
-    getChild<LLCheckBoxCtrl>("AutoTuneContinuous")->setEnabled(!autotune_enabled || (autotune_enabled && auto_tune_locked));
-
-    getChild<LLTextBox>("wip_desc")->setVisible(autotune_enabled && !auto_tune_locked);
-    getChild<LLTextBox>("display_desc")->setVisible(LLPerfStats::tunables.vsyncEnabled);
-}
-
-void LLFloaterPerformance::enableAutotuneWarning()
-{
-    if (!gSavedPerAccountSettings.getBOOL("HadEnabledAutoFPS") && LLPerfStats::tunables.userAutoTuneEnabled)
-    {
-        gSavedPerAccountSettings.setBOOL("HadEnabledAutoFPS", TRUE);
-
-        LLNotificationsUtil::add("EnableAutoFPSWarning", LLSD(), LLSD(),
-            [](const LLSD& notif, const LLSD& resp)
-            {
-                S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp);
-                if (opt == 0)
-                { // offer user to save current graphics settings as a preset
-                    LLFloaterReg::showInstance("save_pref_preset", PRESETS_GRAPHIC);
-                }
-            });
-    }
-}
-// EOF
diff --git a/indra/newview/llfloaterperformance.h b/indra/newview/llfloaterperformance.h
deleted file mode 100644
index 620dbac5bb7c117a6b346793f02c53a3789398f6..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterperformance.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/** 
- * @file llfloaterperformance.h
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2021, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLFLOATERPERFORMANCE_H
-#define LL_LLFLOATERPERFORMANCE_H
-
-#include "llfloater.h"
-#include "lllistcontextmenu.h"
-
-class LLCharacter;
-class LLNameListCtrl;
-
-class LLFloaterPerformance : public LLFloater
-{
-public:
-    LLFloaterPerformance(const LLSD& key);
-    virtual ~LLFloaterPerformance();
-
-    /*virtual*/ BOOL postBuild();
-    /*virtual*/ void draw();
-
-    void showSelectedPanel(LLPanel* selected_panel);
-    void showMainPanel();
-    void hidePanels();
-    void showAutoadjustmentsPanel();
-
-    void detachItem(const LLUUID& item_id);
-
-    void onAvatarListRightClick(LLUICtrl* ctrl, S32 x, S32 y);
-
-    void onCustomAction (const LLSD& userdata, const LLUUID& av_id);
-    bool isActionChecked(const LLSD& userdata, const LLUUID& av_id);
-
-private:
-    void initBackBtn(LLPanel* panel);
-    void populateHUDList();
-    void populateObjectList();
-    void populateNearbyList();
-    void setFPSText();
-
-    void onClickAdvanced();
-    void onClickDefaults();
-    void onChangeQuality(const LLSD& data);
-    void onClickHideAvatars();
-    void onClickExceptions();
-    void onClickShadows();
-    void onClickAdvancedLighting();
-
-    void startAutotune();
-    void stopAutotune();
-    void updateAutotuneCtrls(bool autotune_enabled);
-    void enableAutotuneWarning();
-
-    void updateMaxRenderTime();
-
-    static void changeQualityLevel(const std::string& notif);
-
-    LLPanel* mMainPanel;
-    LLPanel* mNearbyPanel;
-    LLPanel* mComplexityPanel;
-    LLPanel* mHUDsPanel;
-    LLPanel* mSettingsPanel;
-    LLPanel* mAutoadjustmentsPanel;
-    LLNameListCtrl* mHUDList;
-    LLNameListCtrl* mObjectList;
-    LLNameListCtrl* mNearbyList;
-
-    LLButton* mStartAutotuneBtn;
-    LLButton* mStopAutotuneBtn;
-
-    LLListContextMenu* mContextMenu;
-
-    LLTimer* mUpdateTimer;
-
-    // maximum GPU time of nearby avatars in ms according to LLWorld::getNearbyAvatarsAndMaxGPUTime
-    // -1.f if no profile has happened yet
-    F32 mNearbyMaxGPUTime = -1.f;
-
-    boost::signals2::connection	mMaxARTChangedSignal;
-};
-
-#endif // LL_LLFLOATERPERFORMANCE_H
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 4442266fc2f45bcbb933006b7f8c3d13a3bcc183..f58f6fb1ee1fb004aac630a9feaf8aabdcf6b183 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -52,8 +52,6 @@
 #include "llfloaterreg.h"
 #include "llfloaterabout.h"
 #include "llfavoritesbar.h"
-#include "llfloaterpreferencesgraphicsadvanced.h"
-#include "llfloaterperformance.h"
 #include "llfloatersidepanelcontainer.h"
 #include "llfloaterimsession.h"
 #include "llkeyboard.h"
@@ -147,7 +145,6 @@
 #include <json/json.h>
 #include <utility>
 
-#include "llsearchableui.h"
 #include "llperfstats.h"
 
 const F32 BANDWIDTH_UPDATER_TIMEOUT = 0.5f;
@@ -1187,10 +1184,11 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
 	mCommitCallbackRegistrar.add("Pref.RememberedUsernames",    boost::bind(&LLFloaterPreference::onClickRememberedUsernames, this));
 	mCommitCallbackRegistrar.add("Pref.SpellChecker",           boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
 
-	mCommitCallbackRegistrar.add("Pref.AddSkin",				boost::bind(&LLFloaterPreference::onAddSkin, this));
+	//BD - Custom User Skins ~ Currently disabled.
+	/*mCommitCallbackRegistrar.add("Pref.AddSkin", boost::bind(&LLFloaterPreference::onAddSkin, this));
 	mCommitCallbackRegistrar.add("Pref.RemoveSkin",				boost::bind(&LLFloaterPreference::onRemoveSkin, this));
 	mCommitCallbackRegistrar.add("Pref.ApplySkin",				boost::bind(&LLFloaterPreference::onApplySkin, this));
-	mCommitCallbackRegistrar.add("Pref.SelectSkin",				boost::bind(&LLFloaterPreference::onSelectSkin, this, _2));
+	mCommitCallbackRegistrar.add("Pref.SelectSkin",				boost::bind(&LLFloaterPreference::onSelectSkin, this, _2));*/
 
 	gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
 	gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
@@ -1949,10 +1947,10 @@ void LLFloaterPreference::refreshEverything()
 
 			//BD - Motion Blur
 			//================
-			bool blur_enabled = (gPipeline.RenderMotionBlur && deferred_enabled);
+			/*bool blur_enabled = (gPipeline.RenderMotionBlur && deferred_enabled);
 			mRenderRiggedMotionBlurQuality->setEnabled(blur_enabled);
 			mMotionBlurQuality->setEnabled(blur_enabled);
-			mWarning13->setBackgroundVisible(blur_enabled);
+			mWarning13->setBackgroundVisible(blur_enabled);*/
 
 			//BD - Volumetric Lighting
 			//========================
@@ -1967,7 +1965,7 @@ void LLFloaterPreference::refreshEverything()
 
 		//BD - Tone Mapping
 		//=================
-		LLRect tone_rect = mDisplayTabs[2]->calcScreenRect();
+		/*LLRect tone_rect = mDisplayTabs[2]->calcScreenRect();
 		if (scroll_rect.overlaps(tone_rect))
 		{
 			//BD - Tone Mapping
@@ -2005,7 +2003,7 @@ void LLFloaterPreference::refreshEverything()
 			mExodusRenderVignette[0]->setEnabled(deferred_enabled);
 			mExodusRenderVignette[1]->setEnabled(deferred_enabled);
 			mExodusRenderVignette[2]->setEnabled(deferred_enabled);
-		}
+		}*/
 	}
 
 	if (mTabContainer->getCurrentPanelIndex() == 8)
@@ -2325,9 +2323,6 @@ void LLFloaterPreference::refreshCameraControls()
 	getChild<LLUICtrl>("FocusOffset_Y")->setValue(vec3d.mdV[VY]);
 	getChild<LLUICtrl>("FocusOffset_Z")->setValue(vec3d.mdV[VZ]);
 	LLLogChat::getInstance()->setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
-	
-	loadUserSkins();
-	
 
 	//BD - Disable the delete button when we have a default preset selected.
 	//     We will instead use the default buttons which essentially do the same
@@ -2430,7 +2425,7 @@ void LLFloaterPreference::deleteGraphicPreset()
 ////////////////////////////////////////////////////
 // Skins panel
 
-skin_t manifestFromJson(const std::string& filename, const ESkinType type)
+/*skin_t manifestFromJson(const std::string& filename, const ESkinType type)
 {
 	skin_t skin;
 	Json::Reader reader;
@@ -2685,7 +2680,7 @@ void LLFloaterPreference::refreshSkinInfo(const skin_t& skin)
 	getChild<LLTextBase>("skin_compatibility")->setText(skin.mCompatVer);
 	getChild<LLTextBase>("skin_notes")->setText(skin.mNotes);
 }
-
+*/
 
 void LLFloaterPreference::refreshGraphicPresets()
 {
@@ -4989,7 +4984,7 @@ void collectChildren(LLView const *aView, LLSearchableUI::LLPanelDataPtr aParent
 		//}
 		else if (pSCtrl && pSCtrl->getSearchText().size())
 		{
-			LLSearchableUI::LLSearchableItemPtr item = LLSearchableUI::LLSearchableItemPtr(new LLSearchableItem());
+			LLSearchableUI::LLSearchableItemPtr item = LLSearchableUI::LLSearchableItemPtr(new LLSearchableItem);
 			item->mView = pView;
 			item->mCtrl = pSCtrl;
 
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index d06b4eb54073f5d00b2c594c0dada9f2fa598859..4a1f31ffc12a34e2f30b38a4bd810bffb6225742 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -40,6 +40,7 @@
 #include "lllistcontextmenu.h"
 #include "llmutelist.h"
 #include "llsearchableui.h"
+#include "llsearchablecontrol.h"
 #include "llnamelistctrl.h"
 #include "llsearcheditor.h"
 
@@ -57,8 +58,6 @@ class LLTextBox;
 class LLNameListCtrl;
 class LLProgressBar;
 class LLTabContainer;
-class LLSearchableUI;
-class LLSearchableControl;
 struct skin_t;
 
 typedef std::map<std::string, std::string> notifications_map;
@@ -279,7 +278,6 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	void deleteGraphicPreset();
 	void refreshGraphicPresets();
 
-    void setRecommendedSettings();
     void resetAutotuneSettings();
 
 private:
@@ -290,7 +288,8 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 
 	static bool loadFromFilename(const std::string& filename, std::map<std::string, std::string> &label_map);
 	
-	void loadUserSkins();
+	//BD - Custom User Skins ~ Currently disabled.
+	/*void loadUserSkins();
 	void reloadSkinList();
 	void onAddSkin();
 	void onRemoveSkin();
@@ -298,7 +297,7 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	void onApplySkin();
 	void callbackApplySkin(const LLSD& notification, const LLSD& response);
 	void onSelectSkin(const LLSD& data);
-	void refreshSkinInfo(const skin_t& skin);
+	void refreshSkinInfo(const skin_t& skin);*/
 
 	static std::string sSkin;
 	notifications_map mNotificationOptions;
diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp
deleted file mode 100644
index a91f0ec0603462e1cf472a20f0ef73154540281f..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp
+++ /dev/null
@@ -1,480 +0,0 @@
-/** 
- * @file llfloaterpreferencesgraphicsadvanced.cpp
- * @brief floater for adjusting camera position
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2021, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llfloaterpreferencesgraphicsadvanced.h"
-
-#include "llcheckboxctrl.h"
-#include "llcombobox.h"
-#include "llfeaturemanager.h"
-#include "llfloaterpreference.h"
-#include "llfloaterreg.h"
-#include "llnotificationsutil.h"
-#include "llsliderctrl.h"
-#include "lltextbox.h"
-#include "lltrans.h"
-#include "llviewershadermgr.h"
-#include "llviewertexturelist.h"
-#include "llvoavatar.h"
-#include "pipeline.h"
-
-
-LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key)
-    : LLFloater(key)
-{
-    mCommitCallbackRegistrar.add("Pref.RenderOptionUpdate",            boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable, this));
-    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this));
-    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",   boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this));
-
-    mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onBtnCancel, this, _2));
-    mCommitCallbackRegistrar.add("Pref.OK",     boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onBtnOK, this, _2));
-
-    gSavedSettings.getControl("RenderAvatarMaxNonImpostors")->getSignal()->connect(boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateIndirectMaxNonImpostors, this, _2));
-}
-
-LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced()
-{
-    mComplexityChangedSignal.disconnect();
-    mLODFactorChangedSignal.disconnect();
-}
-
-BOOL LLFloaterPreferenceGraphicsAdvanced::postBuild()
-{
-    // Don't do this on Mac as their braindead GL versioning
-    // sets this when 8x and 16x are indeed available
-    //
-#if !LL_DARWIN
-    if (gGLManager.mIsIntel || gGLManager.mGLVersion < 3.f)
-    { //remove FSAA settings above "4x"
-        LLComboBox* combo = getChild<LLComboBox>("fsaa");
-        combo->remove("8x");
-        combo->remove("16x");
-    }
-
-    LLCheckBoxCtrl *use_HiDPI = getChild<LLCheckBoxCtrl>("use HiDPI");
-    use_HiDPI->setVisible(FALSE);
-#endif
-
-    mComplexityChangedSignal = gSavedSettings.getControl("RenderAvatarMaxComplexity")->getCommitSignal()->connect(boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateComplexityText, this)); 
-    mLODFactorChangedSignal = gSavedSettings.getControl("RenderVolumeLODFactor")->getCommitSignal()->connect(boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateObjectMeshDetailText, this));
-    return TRUE;
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onOpen(const LLSD& key)
-{
-    refresh();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onClickCloseBtn(bool app_quitting)
-{
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->cancel();
-    }
-    updateMaxComplexity();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable()
-{
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->refresh();
-    }
-
-    refreshEnabledGraphics();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onAdvancedAtmosphericsEnable()
-{
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->refresh();
-    }
-
-    refreshEnabledGraphics();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::refresh()
-{
-    getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer)  gSavedSettings.getU32("RenderFSAASamples"));
-
-    // sliders and their text boxes
-    //	mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
-    // slider text boxes
-    updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail",		true), getChild<LLTextBox>("ObjectMeshDetailText",		true));
-    updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail",	true), getChild<LLTextBox>("FlexibleMeshDetailText",	true));
-    updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail",		true), getChild<LLTextBox>("TreeMeshDetailText",		true));
-    updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail",		true), getChild<LLTextBox>("AvatarMeshDetailText",		true));
-    updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail",	true), getChild<LLTextBox>("AvatarPhysicsDetailText",		true));
-    updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail",	true), getChild<LLTextBox>("TerrainMeshDetailText",		true));
-    updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess",	true), getChild<LLTextBox>("PostProcessText",			true));
-    updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail",		true), getChild<LLTextBox>("SkyMeshDetailText",			true));
-    updateSliderText(getChild<LLSliderCtrl>("TerrainDetail",		true), getChild<LLTextBox>("TerrainDetailText",			true));	
-    LLAvatarComplexityControls::setIndirectControls();
-    setMaxNonImpostorsText(
-        gSavedSettings.getU32("RenderAvatarMaxNonImpostors"),
-        getChild<LLTextBox>("IndirectMaxNonImpostorsText", true));
-    LLAvatarComplexityControls::setText(
-        gSavedSettings.getU32("RenderAvatarMaxComplexity"),
-        getChild<LLTextBox>("IndirectMaxComplexityText", true));
-    refreshEnabledState();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics()
-{
-    refreshEnabledState();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
-{
-    // Called when the IndirectMaxComplexity control changes
-    LLAvatarComplexityControls::updateMax(
-        getChild<LLSliderCtrl>("IndirectMaxComplexity"),
-        getChild<LLTextBox>("IndirectMaxComplexityText"));
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateComplexityText()
-{
-    LLAvatarComplexityControls::setText(gSavedSettings.getU32("RenderAvatarMaxComplexity"),
-        getChild<LLTextBox>("IndirectMaxComplexityText", true));
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateObjectMeshDetailText()
-{
-    updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail", true), getChild<LLTextBox>("ObjectMeshDetailText", true));
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box)
-{
-    if (text_box == NULL || ctrl== NULL)
-        return;
-
-    // get range and points when text should change
-    F32 value = (F32)ctrl->getValue().asReal();
-    F32 min = ctrl->getMinValue();
-    F32 max = ctrl->getMaxValue();
-    F32 range = max - min;
-    llassert(range > 0);
-    F32 midPoint = min + range / 3.0f;
-    F32 highPoint = min + (2.0f * range / 3.0f);
-
-    // choose the right text
-    if (value < midPoint)
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityLow"));
-    } 
-    else if (value < highPoint)
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityMid"));
-    }
-    else
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
-    }
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors()
-{
-    // Called when the IndirectMaxNonImpostors control changes
-    // Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors
-    LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
-    U32 value = ctrl->getValue().asInteger();
-
-    if (0 == value || LLVOAvatar::NON_IMPOSTORS_MAX_SLIDER <= value)
-    {
-        value=0;
-    }
-    gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value);
-    LLVOAvatar::updateImpostorRendering(value); // make it effective immediately
-    setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::updateIndirectMaxNonImpostors(const LLSD& newvalue)
-{
-    U32 value = newvalue.asInteger();
-    if ((value != 0) && (value != gSavedSettings.getU32("IndirectMaxNonImpostors")))
-    {
-        gSavedSettings.setU32("IndirectMaxNonImpostors", value);
-        setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
-    }
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::setMaxNonImpostorsText(U32 value, LLTextBox* text_box)
-{
-    if (0 == value)
-    {
-        text_box->setText(LLTrans::getString("no_limit"));
-    }
-    else
-    {
-        text_box->setText(llformat("%d", value));
-    }
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()
-{	
-    LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
-    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-    LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-    LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
-    LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-    LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
-    LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText");
-    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-
-    // disabled windlight
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
-    {
-        ctrl_wind_light->setEnabled(FALSE);
-        ctrl_wind_light->setValue(FALSE);
-
-        sky->setEnabled(FALSE);
-        sky_text->setEnabled(FALSE);
-
-        //deferred needs windlight, disable deferred
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-
-    // disabled deferred
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"))
-    {
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-
-    // disabled deferred SSAO
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
-    {
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-    }
-
-    // disabled deferred shadows
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
-    {
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-    }
-
-    // disabled reflections
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
-    {
-        ctrl_reflections->setEnabled(FALSE);
-        ctrl_reflections->setValue(FALSE);
-        reflections_text->setEnabled(FALSE);
-    }
-
-    // disabled av
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
-    {
-        ctrl_avatar_vp->setEnabled(FALSE);
-        ctrl_avatar_vp->setValue(FALSE);
-
-        ctrl_avatar_cloth->setEnabled(FALSE);
-        ctrl_avatar_cloth->setValue(FALSE);
-
-        //deferred needs AvatarVP, disable deferred
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-
-    // disabled cloth
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
-    {
-        ctrl_avatar_cloth->setEnabled(FALSE);
-        ctrl_avatar_cloth->setValue(FALSE);
-    }
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState()
-{
-    LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
-    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-
-    // Reflections
-    BOOL reflections = LLCubeMap::sUseCubeMaps;
-    ctrl_reflections->setEnabled(reflections);
-    reflections_text->setEnabled(reflections);
-
-    // Bump & Shiny	
-    LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny");
-    bool bumpshiny = LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
-    bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE);
-
-    // Avatar Mode
-    // Enable Avatar Shaders
-    LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-    // Avatar Render Mode
-    LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
-
-    bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
-    if (LLViewerShaderMgr::sInitialized)
-    {
-        S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
-        avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
-    }
-
-    ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
-
-    if (gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
-    {
-        ctrl_avatar_cloth->setEnabled(FALSE);
-    } 
-    else
-    {
-        ctrl_avatar_cloth->setEnabled(TRUE);
-    }
-
-    // Vertex Shaders, Global Shader Enable
-    // SL-12594 Basic shaders are always enabled. DJH TODO clean up now-orphaned state handling code
-    LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail");   // can be linked with control var
-    LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText");
-
-    terrain_detail->setEnabled(FALSE);
-    terrain_text->setEnabled(FALSE);
-
-    // WindLight
-    //LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-    //ctrl_wind_light->setEnabled(TRUE);
-    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-    sky->setEnabled(TRUE);
-    sky_text->setEnabled(TRUE);
-
-    BOOL enabled = TRUE;
-#if 0 // deferred always on now
-    //Deferred/SSAO/Shadows
-    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-
-    enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-        ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) &&
-        (ctrl_wind_light->get()) ? TRUE : FALSE;
-
-    ctrl_deferred->setEnabled(enabled);
-#endif
-    
-    LLCheckBoxCtrl* ctrl_pbr = getChild<LLCheckBoxCtrl>("UsePBRShaders");
-
-    //PBR
-    ctrl_pbr->setEnabled(TRUE);
-
-    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-    LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
-    LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText");
-
-    // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it
-    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO");// && (ctrl_deferred->get() ? TRUE : FALSE);
-
-    //ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred"));
-
-    ctrl_ssao->setEnabled(enabled);
-    ctrl_dof->setEnabled(enabled);
-
-    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
-
-    ctrl_shadow->setEnabled(enabled);
-    shadow_text->setEnabled(enabled);
-
-    // Hardware settings
-    
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable"))
-    {
-        getChildView("vbo")->setEnabled(FALSE);
-    }
-
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures"))
-    {
-        getChildView("texture compression")->setEnabled(FALSE);
-    }
-
-    // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
-    LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma");
-    gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"));
-
-    // now turn off any features that are unavailable
-    disableUnavailableSettings();
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onBtnOK(const LLSD& userdata)
-{
-    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->onBtnOK(userdata);
-    }
-}
-
-void LLFloaterPreferenceGraphicsAdvanced::onBtnCancel(const LLSD& userdata)
-{
-    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->onBtnCancel(userdata);
-    }
-}
diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.h b/indra/newview/llfloaterpreferencesgraphicsadvanced.h
deleted file mode 100644
index 2c92f3dbf1062cf0040c4cac1e48e8a6d0fc9a9f..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterpreferencesgraphicsadvanced.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/** 
- * @file llfloaterpreferencesgraphicsadvanced.h
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2021, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LLFLOATERPREFERENCEGRAPHICSADVANCED_H
-#define LLFLOATERPREFERENCEGRAPHICSADVANCED_H
-
-#include "llcontrol.h"
-#include "llfloater.h"
-
-class LLSliderCtrl;
-class LLTextBox;
-
-class LLFloaterPreferenceGraphicsAdvanced : public LLFloater
-{
-public: 
-    LLFloaterPreferenceGraphicsAdvanced(const LLSD& key);
-    ~LLFloaterPreferenceGraphicsAdvanced();
-    /*virtual*/ BOOL postBuild();
-    void onOpen(const LLSD& key);
-    void onClickCloseBtn(bool app_quitting);
-    void disableUnavailableSettings();
-    void refreshEnabledGraphics();
-    void refreshEnabledState();
-    void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box);
-    void updateMaxNonImpostors();
-    void updateIndirectMaxNonImpostors(const LLSD& newvalue);
-    void setMaxNonImpostorsText(U32 value, LLTextBox* text_box);
-    void updateMaxComplexity();
-    void updateComplexityText();
-    void updateObjectMeshDetailText();
-    void refresh();
-    // callback for when client modifies a render option
-    void onRenderOptionEnable();
-    void onAdvancedAtmosphericsEnable();
-    LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced);
-
-protected:	
-    void		onBtnOK(const LLSD& userdata);
-    void		onBtnCancel(const LLSD& userdata);
-
-    boost::signals2::connection	mComplexityChangedSignal;
-    boost::signals2::connection	mLODFactorChangedSignal;
-};
-
-#endif //LLFLOATERPREFERENCEGRAPHICSADVANCED_H
-
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
deleted file mode 100644
index f8db738923359072443744297795191971ee1e2b..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/** 
- * @file llfloaterpreferenceviewadvanced.cpp
- * @brief floater for adjusting camera position
- *
- * $LicenseInfo:firstyear=2018&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2018, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llagentcamera.h"
-#include "llfloaterpreferenceviewadvanced.h"
-#include "llfloater.h"
-#include "llfloaterreg.h"
-#include "lluictrlfactory.h"
-#include "llspinctrl.h"
-#include "llviewercontrol.h"
-
-
-LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) 
-:	LLFloater(key)
-{
-	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
-}
-
-LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced()
-{}
-
-void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector)
-{
-	getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
-	getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
-	getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
-}
-
-void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vector3d)
-{
-	getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
-	getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
-	getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
-}
-
- void LLFloaterPreferenceViewAdvanced::draw()
-{
-	updateCameraControl(gAgentCamera.getCameraOffsetInitial());
-	updateFocusControl(gAgentCamera.getFocusOffsetInitial());
-
-	LLFloater::draw();
-}
-
-void LLFloaterPreferenceViewAdvanced::onCommitSettings()
-{
-	LLVector3 vector;
-	LLVector3d vector3d;
-
-	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
-	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
-	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-	gSavedSettings.setVector3("CameraOffsetRearView", vector);
-
-	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
-	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
-	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
-}
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
deleted file mode 100644
index 4619fdaab16b9f79aaea2071b04c5c5252556adb..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterpreferenceviewadvanced.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/** 
- * @file llfloaterpreferenceviewadvanced.h
- * @brief floater for adjusting camera position
- *
- * $LicenseInfo:firstyear=2018&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2018, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LLFLOATERPREFERENCEVIEWADVANCED_H
-#define LLFLOATERPREFERENCEVIEWADVANCED_H
-
-#include "llcontrol.h"
-#include "llfloater.h"
-
-class LLFloaterPreferenceViewAdvanced
-:	public LLFloater
-{
-	friend class LLFloaterReg;
-
-public:
-	LLFloaterPreferenceViewAdvanced(const LLSD& key);
-	virtual void draw();
-
-	void onCommitSettings();
-	void updateCameraControl(const LLVector3& vector);
-	void updateFocusControl(const LLVector3d& vector3d);
-
-private:
-	virtual ~LLFloaterPreferenceViewAdvanced();
-};
-
-#endif //LLFLOATERPREFERENCEVIEWADVANCED_H
-
diff --git a/indra/newview/llfloaterwateradjust.cpp b/indra/newview/llfloaterwateradjust.cpp
index 39f8c8ba7ff0f4aa6581f9a22765618de2814e19..73ae25753224ecd056961d26035001fc7091518e 100644
--- a/indra/newview/llfloaterwateradjust.cpp
+++ b/indra/newview/llfloaterwateradjust.cpp
@@ -511,7 +511,7 @@ void LLFloaterWaterAdjust::onButtonDelete()
 
 void LLFloaterWaterAdjust::onButtonImport()
 {   // Load a a legacy Windlight XML from disk.
-	(new LLFilePickerReplyThread(boost::bind(&LLFloaterWaterAdjust::loadWaterSettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile();
+	LLFilePickerReplyThread::startPicker(boost::bind(&LLFloaterWaterAdjust::loadWaterSettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false);
 }
 
 void LLFloaterWaterAdjust::loadWaterSettingFromFile(const std::vector<std::string>& filenames)
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 8f07f22c4ea7baa07876a44d8c1360a273f11ad4..7138ac4f46760a66c5261d4bf31ff5f4fb89e3d8 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -3664,16 +3664,23 @@ void LLIMMgr::addPendingAgentListUpdates(
 	{
 		//new school update
 		LLSD update_types = LLSD::emptyArray();
+		LLSD::array_iterator array_iter;
 		update_types.append("agent_updates");
 		update_types.append("updates");
 
-		for (const auto& update_type : update_types.array())
+		for (
+			array_iter = update_types.beginArray();
+			array_iter != update_types.endArray();
+			++array_iter)
 		{
 			//we only want to include the last update for a given agent
-			for (const auto& update_pair : updates[update_type.asStringRef()].map())
+			for (
+				iter = updates[array_iter->asString()].beginMap();
+				iter != updates[array_iter->asString()].endMap();
+				++iter)
 			{
-				mPendingAgentListUpdates[session_id.asString()][update_type.asStringRef()][update_pair.first] =
-					update_pair.second;
+				mPendingAgentListUpdates[session_id.asString()][array_iter->asString()][iter->first] =
+					iter->second;
 			}
 		}
 	}
@@ -3685,10 +3692,13 @@ void LLIMMgr::addPendingAgentListUpdates(
 		//of agent_id -> "LEAVE"/"ENTER"
 
 		//only want to keep last update for each agent
-		for (const auto& update_pair : updates["updates"].map())
+		for (
+			iter = updates["updates"].beginMap();
+			iter != updates["updates"].endMap();
+			++iter)
 		{
-			mPendingAgentListUpdates[session_id.asString()]["updates"][update_pair.first] =
-				update_pair.second;
+			mPendingAgentListUpdates[session_id.asString()]["updates"][iter->first] =
+				iter->second;
 		}
 	}
 }
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index f94f2212374bd7c389337ba865e6be8d2ede3805..9ee2ee23b07f75328559d0e1276bdd869a1f505b 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -822,11 +822,6 @@ void show_item_original(const LLUUID& item_uuid)
     LLSidepanelInventory *sidepanel_inventory =	LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
     if (sidepanel_inventory)
     {
-        LLPanelMainInventory* main_inventory = sidepanel_inventory->getMainInventoryPanel();
-        if (main_inventory)
-        {
-            main_inventory->resetAllItemsFilters();
-        }
         reset_inventory_filter();
 
 		//BD - Show the item in the main inventory tab, always.
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index a5069a7048d54f831e3a4b8e3704972ad418e930..f544b318d6f89c55ff48a7dda7070505173bf0b3 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -260,7 +260,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive)
 	if (cat || (id.isNull() && ! isEverythingFetched()))
 	{
 		// it's a folder, do a bulk fetch
-		// _LL_DEBUGS(LOG_INV) << "Start fetching category: " << id << ", recursive: " << recursive << LL_ENDL;
+		LL_DEBUGS(LOG_INV) << "Start fetching category: " << id << ", recursive: " << recursive << LL_ENDL;
 
 		mBackgroundFetchActive = TRUE;
 		mFolderFetchActive = true;
@@ -576,9 +576,11 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
 
 bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID & cat_id) const
 {
-	for (const auto& item : mFetchQueue)
+	for (fetch_queue_t::const_iterator it = mFetchQueue.begin();
+		 it != mFetchQueue.end();
+		 ++it)
 	{
-		const LLUUID & fetch_id = item.mUUID;
+		const LLUUID & fetch_id = (*it).mUUID;
 		if (gInventory.isObjectDescendentOf(fetch_id, cat_id))
 			return false;
 	}
@@ -667,8 +669,12 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res
 	{
 		LLSD folders(content["folders"]);
 		
-		for (const auto& folder_sd : folders.array())
+		for (LLSD::array_const_iterator folder_it = folders.beginArray();
+			folder_it != folders.endArray();
+			++folder_it)
 		{	
+			LLSD folder_sd(*folder_it);
+
 			//LLUUID agent_id = folder_sd["agent_id"];
 
 			//if(agent_id != gAgent.getID())	//This should never happen.
@@ -689,12 +695,16 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res
 				LLSD items(folder_sd["items"]);
 			    LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
 				
-			    for (const auto& item : items.array())
+			    for (LLSD::array_const_iterator item_it = items.beginArray();
+				    item_it != items.endArray();
+				    ++item_it)
 			    {	
                     const LLUUID lost_uuid(gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND));
 
                     if (lost_uuid.notNull())
                     {
+				        LLSD item(*item_it);
+
 				        titem->unpackMessage(item);
 				
                         LLInventoryModel::update_list_t update;
@@ -716,8 +726,11 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res
 			}
 
 			LLSD categories(folder_sd["categories"]);
-			for (const auto& category : categories.array())
+			for (LLSD::array_const_iterator category_it = categories.beginArray();
+				category_it != categories.endArray();
+				++category_it)
 			{	
+				LLSD category(*category_it);
 				tcategory->fromLLSD(category); 
 				
 				const bool recursive(getIsRecursive(tcategory->getUUID()));
@@ -733,8 +746,11 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res
 
 			LLSD items(folder_sd["items"]);
 			LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
-			for (const auto& item : items.array())
+			for (LLSD::array_const_iterator item_it = items.beginArray();
+				 item_it != items.endArray();
+				 ++item_it)
 			{	
+				LLSD item(*item_it);
 				titem->unpackMessage(item);
 				
 				gInventory.updateItem(titem);
@@ -754,8 +770,13 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res
 	if (content.has("bad_folders"))
 	{
 		LLSD bad_folders(content["bad_folders"]);
-		for (const auto& folder_sd : bad_folders.array())
+		for (LLSD::array_const_iterator folder_it = bad_folders.beginArray();
+			 folder_it != bad_folders.endArray();
+			 ++folder_it)
 		{
+			// *TODO: Stop copying data [ed:  this isn't copying data]
+			LLSD folder_sd(*folder_it);
+			
 			// These folders failed on the dataserver.  We probably don't want to retry them.
 			LL_WARNS(LOG_INV) << "Folder " << folder_sd["folder_id"].asString() 
 							  << "Error: " << folder_sd["error"].asString() << LL_ENDL;
@@ -848,8 +869,11 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http
 	if (false)
 	{
 		// timed out or curl failure
-		for (const auto& folder_sd : mRequestSD["folders"].array())
+		for (LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
+			 folder_it != mRequestSD["folders"].endArray();
+			 ++folder_it)
 		{
+			LLSD folder_sd(*folder_it);
 			LLUUID folder_id(folder_sd["folder_id"].asUUID());
 			const BOOL recursive = getIsRecursive(folder_id);
 			fetcher->addRequestAtFront(folder_id, recursive, true);
@@ -882,8 +906,11 @@ void BGFolderHttpHandler::processFailure(const char * const reason, LLCore::Http
 	LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
 	if (true)
 	{
-		for (const auto& folder_sd : mRequestSD["folders"].array())
+		for (LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
+			 folder_it != mRequestSD["folders"].endArray();
+			 ++folder_it)
 		{
+			LLSD folder_sd(*folder_it);
 			LLUUID folder_id(folder_sd["folder_id"].asUUID());
 			const BOOL recursive = getIsRecursive(folder_id);
 			fetcher->addRequestAtFront(folder_id, recursive, true);
diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp
index 542d07081116ca31a63fd3f3765c95e16b51ec7b..59fe1b4b5f7fd2a53c02b195df5f8db59b2480b7 100644
--- a/indra/newview/llpaneleditsky.cpp
+++ b/indra/newview/llpaneleditsky.cpp
@@ -175,27 +175,6 @@ BOOL LLPanelSettingsSkyAtmosTab::postBuild()
 	return TRUE;
 }
 
-//virtual
-void LLPanelSettingsSkyAtmosTab::setEnabled(BOOL enabled)
-{
-    LLPanelSettingsSky::setEnabled(enabled);
-
-    // Make sure we have initialized children (initialized)
-    if (getFirstChild())
-    {
-        getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->setEnabled(enabled);
-        getChild<LLUICtrl>(FIELD_REFLECTION_PROBE_AMBIANCE)->setEnabled(enabled);
-    }
-}
-
 void LLPanelSettingsSkyAtmosTab::refresh()
 {
 	if (!mSkySettings)
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 17dd0b9cdcfe5d8c1bcadbcd10416010c8d9cfbe..cb81e16ec5b4e5a892ae2d93ac22cf5489453ae5 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -574,7 +574,6 @@ static void init_texture_ctrl(LLPanelEditWearable* self, LLPanel* panel, const L
                 // Don't allow (no copy) or (notransfer) textures to be selected.
                 texture_ctrl->setImmediateFilterPermMask(PERM_NONE);
                 texture_ctrl->setDnDFilterPermMask(PERM_NONE);
-                texture_ctrl->setNonImmediateFilterPermMask(PERM_NONE);
 				
 				//BD - Don't allow local textures in BOM bakes.
 				//     We should disable Bakes for clothing items as Bakes are only used on objects.
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 754dcda1a6823466779d9ab15b6830241f3453b7..263530bf6267cb3b64fded43dfcd140f80a4113a 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -201,13 +201,11 @@ LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit()
         U32 matmedia_selection = mComboMatMedia->getCurrentIndex();
         if (matmedia_selection == MATMEDIA_MATERIAL)
         {
-            LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
-            channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex();
+            channel_to_edit = (LLRender::eTexIndex)mRadioMaterialType->getSelectedIndex();
         }
         if (matmedia_selection == MATMEDIA_PBR)
         {
-            LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_pbr_type");
-            channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex();
+            channel_to_edit = (LLRender::eTexIndex)mRadioMaterialType->getSelectedIndex();
         }
     }
 
@@ -388,6 +386,10 @@ BOOL	LLPanelFace::postBuild()
 	mComboTexGen = getChild<LLComboBox>("combobox texgen");
 	mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen, this);
 
+    mComboMatMedia = getChild<LLComboBox>("combobox matmedia");
+    mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia, this);
+    mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL);
+
 	//BD
 	mRadioMaterialType = getChild<LLRadioGroup>("radio mattype");
 	mRadioMaterialType->setCommitCallback(LLPanelFace::onCommitMaterialType, this);
@@ -411,10 +413,14 @@ BOOL	LLPanelFace::postBuild()
 }
 
 LLPanelFace::LLPanelFace()
-	: LLPanel(),
-	mIsAlpha(false)
+    : LLPanel(),
+    mIsAlpha(false),
+    mComboMatMedia(NULL),
+    mTitleMedia(NULL),
+    mTitleMediaText(NULL),
+    mNeedMediaTitle(true)
 {
-	USE_TEXTURE = LLTrans::getString("use_texture");
+    USE_TEXTURE = LLTrans::getString("use_texture");
 }
 
 
@@ -452,14 +458,14 @@ void LLPanelFace::sendTexture()
 			id = mTextureCtrl->getImageAssetID();
 		}
 
-		//		//BD - We have to do this to make sure selection a different texture channel
-				//     doesnt interfere the diffuse texture picker. If we don't do this our
-				//     selected diffuse map will always be applied to the currently selected
-				//     texture channel for some reason, this behavior doesnt apply to the
-				//     other texture pickers, probably because they got a special function to
-				//     set their normal/specular image, this function here seems to be
-				//     generalized, taking whatever texture channel is currently selected.
-		LLSelectMgr::getInstance()->setTextureChannel(LLRender::DIFFUSE_MAP);
+//		//BD - We have to do this to make sure selection a different texture channel
+		//     doesnt interfere the diffuse texture picker. If we don't do this our
+		//     selected diffuse map will always be applied to the currently selected
+		//     texture channel for some reason, this behavior doesnt apply to the
+		//     other texture pickers, probably because they got a special function to
+		//     set their normal/specular image, this function here seems to be
+		//     generalized, taking whatever texture channel is currently selected.
+		//LLSelectMgr::getInstance()->setTextureChannel(LLRender::DIFFUSE_MAP);
 		LLSelectMgr::getInstance()->selectionSetImage(id);
 
         if (!LLSelectMgr::getInstance()->selectionSetImage(id))
@@ -597,16 +603,16 @@ void LLPanelFace::sendGlow()
 
 struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
 {
-	LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {}
-	virtual bool apply(LLViewerObject* object, S32 te)
-	{
-		BOOL valid;
-		F32 value;
+    LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {}
+    virtual bool apply(LLViewerObject* object, S32 te)
+    {
+        BOOL valid;
+        F32 value;
         std::string prefix;
 
         // Effectively the same as MATMEDIA_PBR sans using different radio,
         // separate for the sake of clarity
-        LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type");
+        LLRadioGroup* radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type");
         switch (radio_mat_type->getSelectedIndex())
         {
         case MATTYPE_DIFFUSE:
@@ -620,232 +626,305 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
             break;
         }
 
-		llassert(object);
+        LLSpinCtrl* ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleU");
+        LLSpinCtrl* ctrlTexScaleT = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleV");
+        LLSpinCtrl* ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetU");
+        LLSpinCtrl* ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetV");
+        LLSpinCtrl* ctrlTexRotation = mPanel->getChild<LLSpinCtrl>(prefix + "Rot");
 
-		if (mPanel->mTexScaleU)
-		{
-			valid = !mPanel->mTexScaleU->getTentative(); // || !checkFlipScaleS->getTentative();
-			if (valid || align_planar)
-			{
-				value = mPanel->mTexScaleU->getValue().asReal();
-				if (mPanel->mComboTexGen &&
-					mPanel->mComboTexGen->getCurrentIndex() == 1)
-				{
-					value *= 0.5f;
-				}
-				object->setTEScaleS(te, value);
+        LLComboBox* comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
+        LLCheckBoxCtrl* cb_planar_align = mPanel->getChild<LLCheckBoxCtrl>("checkbox planar align");
+        bool align_planar = (cb_planar_align && cb_planar_align->get());
 
-				if (align_planar)
-				{
-					LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, value, te);
-					LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, value, te);
-				}
-			}
-		}
+        llassert(comboTexGen);
+        llassert(object);
 
-		if (mPanel->mTexScaleV)
-		{
-			valid = !mPanel->mTexScaleV->getTentative(); // || !checkFlipScaleT->getTentative();
-			if (valid || align_planar)
-			{
-				value = mPanel->mTexScaleV->getValue().asReal();
-				//if( checkFlipScaleT->get() )
-				//{
-				//	value = -value;
-				//}
-				if (mPanel->mComboTexGen &&
-					mPanel->mComboTexGen->getCurrentIndex() == 1)
-				{
-					value *= 0.5f;
-				}
-				object->setTEScaleT(te, value);
+        if (ctrlTexScaleS)
+        {
+            valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative();
+            if (valid || align_planar)
+            {
+                value = ctrlTexScaleS->get();
+                if (comboTexGen &&
+                    comboTexGen->getCurrentIndex() == 1)
+                {
+                    value *= 0.5f;
+                }
+                object->setTEScaleS(te, value);
 
-				if (align_planar)
-				{
-					LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, value, te);
-					LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, value, te);
-				}
-			}
-		}
+                if (align_planar)
+                {
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, value, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, value, te, object->getID());
+                }
+            }
+        }
 
-		if (mPanel->mTexOffsetU)
-		{
-			valid = !mPanel->mTexOffsetU->getTentative();
-			if (valid || align_planar)
-			{
-				value = mPanel->mTexOffsetU->getValue().asReal();
-				object->setTEOffsetS(te, value);
+        if (ctrlTexScaleT)
+        {
+            valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative();
+            if (valid || align_planar)
+            {
+                value = ctrlTexScaleT->get();
+                //if( checkFlipScaleT->get() )
+                //{
+                //	value = -value;
+                //}
+                if (comboTexGen &&
+                    comboTexGen->getCurrentIndex() == 1)
+                {
+                    value *= 0.5f;
+                }
+                object->setTEScaleT(te, value);
 
-				if (align_planar)
-				{
-					LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, value, te);
-					LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, value, te);
-				}
-			}
-		}
+                if (align_planar)
+                {
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, value, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, value, te, object->getID());
+                }
+            }
+        }
 
-		if (mPanel->mTexOffsetV)
-		{
-			valid = !mPanel->mTexOffsetV->getTentative();
-			if (valid || align_planar)
-			{
-				value = mPanel->mTexOffsetV->getValue().asReal();
-				object->setTEOffsetT(te, value);
+        if (ctrlTexOffsetS)
+        {
+            valid = !ctrlTexOffsetS->getTentative();
+            if (valid || align_planar)
+            {
+                value = ctrlTexOffsetS->get();
+                object->setTEOffsetS(te, value);
 
-				if (align_planar)
-				{
-					LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, value, te);
-					LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, value, te);
-				}
-			}
-		}
+                if (align_planar)
+                {
+                    LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, value, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, value, te, object->getID());
+                }
+            }
+        }
 
-		if (mPanel->mTexRot)
-		{
-			valid = !mPanel->mTexRot->getTentative();
-			if (valid || align_planar)
-			{
-				value = mPanel->mTexRot->getValue().asReal() * DEG_TO_RAD;
-				object->setTERotation(te, value);
+        if (ctrlTexOffsetT)
+        {
+            valid = !ctrlTexOffsetT->getTentative();
+            if (valid || align_planar)
+            {
+                value = ctrlTexOffsetT->get();
+                object->setTEOffsetT(te, value);
 
-				if (align_planar)
-				{
-					LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, value, te);
-					LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, value, te);
-				}
-			}
-		}
-		return true;
-	}
+                if (align_planar)
+                {
+                    LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, value, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, value, te, object->getID());
+                }
+            }
+        }
+
+        if (ctrlTexRotation)
+        {
+            valid = !ctrlTexRotation->getTentative();
+            if (valid || align_planar)
+            {
+                value = ctrlTexRotation->get() * DEG_TO_RAD;
+                object->setTERotation(te, value);
+
+                if (align_planar)
+                {
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, value, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, value, te, object->getID());
+                }
+            }
+        }
+        return true;
+    }
 private:
-	LLPanelFace* mPanel;
+    LLPanelFace* mPanel;
 };
 
 // Functor that aligns a face to mCenterFace
 struct LLPanelFaceSetAlignedTEFunctor : public LLSelectedTEFunctor
 {
-	LLPanelFaceSetAlignedTEFunctor(LLPanelFace* panel, LLFace* center_face) :
-		mPanel(panel),
-		mCenterFace(center_face) {}
+    LLPanelFaceSetAlignedTEFunctor(LLPanelFace* panel, LLFace* center_face) :
+        mPanel(panel),
+        mCenterFace(center_face) {}
 
-	virtual bool apply(LLViewerObject* object, S32 te)
-	{
-		LLFace* facep = object->mDrawable->getFace(te);
-		if (!facep)
-		{
-			return true;
-		}
+    virtual bool apply(LLViewerObject* object, S32 te)
+    {
+        LLFace* facep = object->mDrawable->getFace(te);
+        if (!facep)
+        {
+            return true;
+        }
 
-		if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
-		{
-			return true;
-		}
+        if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
+        {
+            return true;
+        }
 
-		bool set_aligned = true;
-		if (facep == mCenterFace)
-		{
-			set_aligned = false;
-		}
-		if (set_aligned)
-		{
-			LLVector2 uv_offset, uv_scale;
-			F32 uv_rot;
-			set_aligned = facep->calcAlignedPlanarTE(mCenterFace, &uv_offset, &uv_scale, &uv_rot);
-			if (set_aligned)
-			{
-				object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
-				object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
-				object->setTERotation(te, uv_rot);
-
-				LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
-
-				LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
-
-				LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
-				LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
-			}
-		}
-		if (!set_aligned)
-		{
-			LLPanelFaceSetTEFunctor setfunc(mPanel);
-			setfunc.apply(object, te);
-		}
-		return true;
-	}
+        bool set_aligned = true;
+        if (facep == mCenterFace)
+        {
+            set_aligned = false;
+        }
+        if (set_aligned)
+        {
+            LLVector2 uv_offset, uv_scale;
+            F32 uv_rot;
+            set_aligned = facep->calcAlignedPlanarTE(mCenterFace, &uv_offset, &uv_scale, &uv_rot);
+            if (set_aligned)
+            {
+                object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
+                object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
+                object->setTERotation(te, uv_rot);
+
+                LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
+
+                LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+
+                LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+                LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+            }
+        }
+        if (!set_aligned)
+        {
+            LLPanelFaceSetTEFunctor setfunc(mPanel);
+            setfunc.apply(object, te);
+        }
+        return true;
+    }
+private:
+    LLPanelFace* mPanel;
+    LLFace* mCenterFace;
+};
+
+struct LLPanelFaceSetAlignedConcreteTEFunctor : public LLSelectedTEFunctor
+{
+    LLPanelFaceSetAlignedConcreteTEFunctor(LLPanelFace* panel, LLFace* center_face, LLRender::eTexIndex map) :
+        mPanel(panel),
+        mChefFace(center_face),
+        mMap(map)
+    {}
+
+    virtual bool apply(LLViewerObject* object, S32 te)
+    {
+        LLFace* facep = object->mDrawable->getFace(te);
+        if (!facep)
+        {
+            return true;
+        }
+
+        if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
+        {
+            return true;
+        }
+
+        if (mChefFace != facep)
+        {
+            LLVector2 uv_offset, uv_scale;
+            F32 uv_rot;
+            if (facep->calcAlignedPlanarTE(mChefFace, &uv_offset, &uv_scale, &uv_rot, mMap))
+            {
+                switch (mMap)
+                {
+                case LLRender::DIFFUSE_MAP:
+                    object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
+                    object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
+                    object->setTERotation(te, uv_rot);
+                    break;
+                case LLRender::NORMAL_MAP:
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+                    break;
+                case LLRender::SPECULAR_MAP:
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
+                    LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
+                    break;
+                default: /*make compiler happy*/
+                    break;
+                }
+            }
+        }
+
+        return true;
+    }
 private:
-	LLPanelFace* mPanel;
-	LLFace* mCenterFace;
+    LLPanelFace* mPanel;
+    LLFace* mChefFace;
+    LLRender::eTexIndex mMap;
 };
 
 // Functor that tests if a face is aligned to mCenterFace
 struct LLPanelFaceGetIsAlignedTEFunctor : public LLSelectedTEFunctor
 {
-	LLPanelFaceGetIsAlignedTEFunctor(LLFace* center_face) :
-		mCenterFace(center_face) {}
+    LLPanelFaceGetIsAlignedTEFunctor(LLFace* center_face) :
+        mCenterFace(center_face) {}
 
-	virtual bool apply(LLViewerObject* object, S32 te)
-	{
-		LLFace* facep = object->mDrawable->getFace(te);
-		if (!facep)
-		{
-			return false;
-		}
+    virtual bool apply(LLViewerObject* object, S32 te)
+    {
+        LLFace* facep = object->mDrawable->getFace(te);
+        if (!facep)
+        {
+            return false;
+        }
 
-		if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
-		{ //volume face does not exist, can't be aligned
-			return false;
-		}
+        if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
+        { //volume face does not exist, can't be aligned
+            return false;
+        }
 
-		if (facep == mCenterFace)
-		{
-			return true;
-		}
+        if (facep == mCenterFace)
+        {
+            return true;
+        }
 
-		LLVector2 aligned_st_offset, aligned_st_scale;
-		F32 aligned_st_rot;
-		if (facep->calcAlignedPlanarTE(mCenterFace, &aligned_st_offset, &aligned_st_scale, &aligned_st_rot))
-		{
-			const LLTextureEntry* tep = facep->getTextureEntry();
-			LLVector2 st_offset, st_scale;
-			tep->getOffset(&st_offset.mV[VX], &st_offset.mV[VY]);
-			tep->getScale(&st_scale.mV[VX], &st_scale.mV[VY]);
-			F32 st_rot = tep->getRotation();
-
-			bool eq_offset_x = is_approx_equal_fraction(st_offset.mV[VX], aligned_st_offset.mV[VX], 12);
-			bool eq_offset_y = is_approx_equal_fraction(st_offset.mV[VY], aligned_st_offset.mV[VY], 12);
-			bool eq_scale_x = is_approx_equal_fraction(st_scale.mV[VX], aligned_st_scale.mV[VX], 12);
-			bool eq_scale_y = is_approx_equal_fraction(st_scale.mV[VY], aligned_st_scale.mV[VY], 12);
-			bool eq_rot = is_approx_equal_fraction(st_rot, aligned_st_rot, 6);
-
-			// needs a fuzzy comparison, because of fp errors
-			if (eq_offset_x &&
-				eq_offset_y &&
-				eq_scale_x &&
-				eq_scale_y &&
-				eq_rot)
-			{
-				return true;
-			}
-		}
-		return false;
-	}
+        LLVector2 aligned_st_offset, aligned_st_scale;
+        F32 aligned_st_rot;
+        if (facep->calcAlignedPlanarTE(mCenterFace, &aligned_st_offset, &aligned_st_scale, &aligned_st_rot))
+        {
+            const LLTextureEntry* tep = facep->getTextureEntry();
+            LLVector2 st_offset, st_scale;
+            tep->getOffset(&st_offset.mV[VX], &st_offset.mV[VY]);
+            tep->getScale(&st_scale.mV[VX], &st_scale.mV[VY]);
+            F32 st_rot = tep->getRotation();
+
+            bool eq_offset_x = is_approx_equal_fraction(st_offset.mV[VX], aligned_st_offset.mV[VX], 12);
+            bool eq_offset_y = is_approx_equal_fraction(st_offset.mV[VY], aligned_st_offset.mV[VY], 12);
+            bool eq_scale_x = is_approx_equal_fraction(st_scale.mV[VX], aligned_st_scale.mV[VX], 12);
+            bool eq_scale_y = is_approx_equal_fraction(st_scale.mV[VY], aligned_st_scale.mV[VY], 12);
+            bool eq_rot = is_approx_equal_fraction(st_rot, aligned_st_rot, 6);
+
+            // needs a fuzzy comparison, because of fp errors
+            if (eq_offset_x &&
+                eq_offset_y &&
+                eq_scale_x &&
+                eq_scale_y &&
+                eq_rot)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
 private:
-	LLFace* mCenterFace;
+    LLFace* mCenterFace;
 };
 
 struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor
 {
-	virtual bool apply(LLViewerObject* object)
-	{
-		object->sendTEUpdate();
-		return true;
-	}
+    virtual bool apply(LLViewerObject* object)
+    {
+        object->sendTEUpdate();
+        return true;
+    }
 };
 
 void LLPanelFace::sendTextureInfo()
@@ -868,6 +947,16 @@ void LLPanelFace::sendTextureInfo()
 	LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
 }
 
+void LLPanelFace::alignTestureLayer()
+{
+    LLFace* last_face = NULL;
+    bool identical_face = false;
+    LLSelectedTE::getFace(last_face, identical_face);
+
+    LLPanelFaceSetAlignedConcreteTEFunctor setfunc(this, last_face, static_cast<LLRender::eTexIndex>(mRadioMaterialType->getSelectedIndex()));
+    LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
+}
+
 void LLPanelFace::getState()
 {
 	updateUI();
@@ -909,12 +998,12 @@ void LLPanelFace::updateUI(bool force_set_values)
 
         mComboMatMedia->setEnabled(editable);
 
-        LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
-        if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE)
+        if (mRadioMaterialType->getSelectedIndex() < MATTYPE_DIFFUSE)
         {
-            radio_mat_type->selectNthItem(MATTYPE_DIFFUSE);
+            mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE);
         }
-        radio_mat_type->setEnabled(editable);
+        mRadioMaterialType->setEnabled(editable);
+        U32 material_type = mRadioMaterialType->getSelectedIndex();
 
         LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type");
         if (radio_pbr_type->getSelectedIndex() < PBRTYPE_RENDER_MATERIAL_ID)
@@ -1090,18 +1179,18 @@ void LLPanelFace::updateUI(bool force_set_values)
 
 			updateAlphaControls();
 
-			if (texture_ctrl)
+			if (mTextureCtrl)
 			{
 				if (identical_diffuse)
 				{
-					texture_ctrl->setTentative(FALSE);
-					texture_ctrl->setEnabled(editable && !has_pbr_material);
-					texture_ctrl->setImageAssetID(id);
+                    mTextureCtrl->setTentative(FALSE);
+                    mTextureCtrl->setEnabled(editable && !has_pbr_material);
+                    mTextureCtrl->setImageAssetID(id);
 					mComboAlpha->setEnabled(editable && mIsAlpha && transparency <= 0.f && !has_pbr_material);
 					mLabelAlpha->setEnabled(editable && mIsAlpha && !has_pbr_material);
 					mMaskCutoff->setEnabled(editable && mIsAlpha && !has_pbr_material);
 
-					texture_ctrl->setBakeTextureEnabled(TRUE);
+                    mTextureCtrl->setBakeTextureEnabled(TRUE);
 				}
 				else if (id.isNull())
 				{
@@ -1458,7 +1547,7 @@ void LLPanelFace::updateUI(bool force_set_values)
             U32 material_type = MATTYPE_DIFFUSE;
             if (material_selection == MATMEDIA_MATERIAL)
             {
-                material_type = radio_mat_type->getSelectedIndex();
+                material_type = mRadioMaterialType->getSelectedIndex();
             }
             else if (material_selection == MATMEDIA_PBR)
             {
@@ -2581,7 +2670,7 @@ void LLPanelFace::updateVisibility()
     bool show_material = materials_media == MATMEDIA_MATERIAL;
 	bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && mComboMatMedia->getEnabled()));
 	bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled();
-	bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled();
+	//bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled();
     const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();
     const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex();
     const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type);
@@ -2713,12 +2802,11 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh
 		}
 	}
 
-	LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
 	U32 materials_media = mComboMatMedia->getCurrentIndex();
-	U32 material_type = radio_mat_type->getSelectedIndex();
+	U32 material_type = mRadioMaterialType->getSelectedIndex();
 	bool show_material = (materials_media == MATMEDIA_MATERIAL);
 	bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled();
-	U32 shiny_value = comboShiny->getCurrentIndex();
+	U32 shiny_value = mComboShiny->getCurrentIndex();
 	bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture
 	getChildView("label glossiness")->setVisible(show_shinyctrls);
 	getChildView("glossiness")->setVisible(show_shinyctrls);
@@ -4077,14 +4165,6 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
     }
 }
 
-// TODO: I don't know who put these in or what these are for???
-void LLPanelFace::setMediaURL(const std::string& url)
-{
-}
-void LLPanelFace::setMediaType(const std::string& mime_type)
-{
-}
-
 // static
 void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata)
 {
@@ -4633,13 +4713,3 @@ void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identic
 	} max_diff_repeats_func;
 	identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&max_diff_repeats_func, repeats);
 }
-
-LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit()
-{
-	//BD
-	LLRender::eTexIndex channel_to_edit = (LLRender::eTexIndex)mRadioMaterialType->getSelectedIndex();
-
-	channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP) ? (getCurrentNormalMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit;
-	channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP) ? (getCurrentSpecularMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit;
-	return channel_to_edit;
-}
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index 2da4f7349458e7c5ce1e74d6b77e2372e2a4cd08..e4b8493679a3023e10d3675a8be1dc70c1758383 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -50,6 +50,8 @@ class LLViewerObject;
 class LLFloater;
 class LLRadioGroup;
 class LLMaterialID;
+class LLMediaCtrl;
+class LLMenuButton;
 
 // Represents an edit for use in replicating the op across one or more materials in the selection set.
 //
@@ -122,6 +124,12 @@ class LLPanelFace : public LLPanel
     LLRender::eTexIndex getTextureDropChannel();
 
 protected:
+	void            navigateToTitleMedia(const std::string url);
+	bool            selectedMediaEditable();
+	void            clearMediaSettings();
+	void            updateMediaSettings();
+	void            updateMediaTitle();
+	
 	void			getState();
 
 	void			sendTexture();				// applies and sends texture
@@ -241,6 +249,14 @@ class LLPanelFace : public LLPanel
 	static F32     valueGlow(LLViewerObject* object, S32 face);
 
 public:
+	// needs to be accessible to selection manager
+	void            onCopyColor(); // records all selected faces
+	void            onPasteColor(); // to specific face
+	void            onPasteColor(LLViewerObject* objectp, S32 te); // to specific face
+	void            onCopyTexture();
+	void            onPasteTexture();
+	void            onPasteTexture(LLViewerObject* objectp, S32 te);
+
 	LLTextureCtrl*	mTextureCtrl;
 	LLTextureCtrl*	mShinyTextureCtrl;
 	LLTextureCtrl*	mBumpyTextureCtrl;
@@ -283,6 +299,10 @@ class LLPanelFace : public LLPanel
 	LLUICtrl* mTexRot;
 	LLUICtrl* mRepeats;
 
+	LLComboBox*		mComboMatMedia;
+	LLMediaCtrl*	mTitleMedia;
+	LLTextBox*		mTitleMediaText;
+
 private:
 	bool		isAlpha() { return mIsAlpha; }
 
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 01d9b72cb87a4d8792942b9f644bed5561dbf586..85fb204b61fccab73fa95f492478158a6fbd7ca8 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -310,13 +310,6 @@ LLPanelMainInventory::~LLPanelMainInventory( void )
     
 	gInventory.removeObserver(this);
 	delete mSavedFolderState;
-
-	auto menu = mMenuAddHandle.get();
-	if(menu)
-	{
-		menu->die();
-		mMenuAddHandle.markDead();
-	}
 }
 
 LLInventoryPanel* LLPanelMainInventory::getAllItemsPanel()
@@ -712,12 +705,6 @@ BOOL LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 	return handled;
 }
 
-// virtual
-void LLPanelMainInventory::changed(U32)
-{
-	updateItemcountText();
-}
-
 void LLPanelMainInventory::setFocusFilterEditor()
 {
 	if(mFilterEditor)
@@ -775,29 +762,6 @@ void LLPanelMainInventory::draw()
 		mResortActivePanel = false;
 	}
 	LLPanel::draw();
-	updateItemcountText();
-}
-
-void LLPanelMainInventory::updateItemcountText()
-{
-	if(mItemCount != gInventory.getItemCount())
-	{
-		mItemCount = gInventory.getItemCount();
-		mItemCountString = "";
-		LLLocale locale(LLLocale::USER_LOCALE);
-		LLResMgr::getInstance()->getIntegerString(mItemCountString, mItemCount);
-	}
-
-	if(mCategoryCount != gInventory.getCategoryCount())
-	{
-		mCategoryCount = gInventory.getCategoryCount();
-		mCategoryCountString = "";
-		LLLocale locale(LLLocale::USER_LOCALE);
-		LLResMgr::getInstance()->getIntegerString(mCategoryCountString, mCategoryCount);
-	}
-
-	//string_args["[CATEGORY_COUNT]"] = mCategoryCountString;
-    //mCounterCtrl->setToolTip(text);
 }
 
 void LLPanelMainInventory::onFocusReceived()
@@ -1351,13 +1315,13 @@ void LLPanelMainInventory::initListCommandsHandlers()
 	mCommitCallbackRegistrar.add("Inventory.GearDefault.Custom.Action", boost::bind(&LLPanelMainInventory::onCustomAction, this, _2));
 	mEnableCallbackRegistrar.add("Inventory.GearDefault.Check", boost::bind(&LLPanelMainInventory::isActionChecked, this, _2));
 	mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2));
-	mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-	mGearMenuButton->setMenu(mMenuGearDefault, LLMenuButton::MP_TOP_LEFT, true);
-	LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-	mMenuAddHandle = menu->getHandle();
+	//mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+	//mGearMenuButton->setMenu(mMenuGearDefault, LLMenuButton::MP_TOP_LEFT, true);
+	//LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+	//mMenuAddHandle = menu->getHandle();
 
-	mMenuVisibility = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_search_visibility.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-	mVisibilityMenuButton->setMenu(mMenuVisibility, LLMenuButton::MP_BOTTOM_LEFT, true);
+	//mMenuVisibility = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_search_visibility.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+	//mVisibilityMenuButton->setMenu(mMenuVisibility, LLMenuButton::MP_BOTTOM_LEFT, true);
 
 	// Update the trash button when selected item(s) get worn or taken off.
 	LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLPanelMainInventory::updateListCommands, this));
@@ -1709,11 +1673,6 @@ void LLPanelMainInventory::setUploadCostIfNeeded()
 	}
 }
 
-bool LLPanelMainInventory::hasSettingsInventory()
-{
-    return LLEnvironment::instance().isInventoryEnabled();
-}
-
 bool LLPanelMainInventory::hasMaterialsInventory()
 {
     std::string agent_url = gAgent.getRegionCapability("UpdateMaterialAgentInventory");
diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h
index e0743d9270e07614b48bdf1a43cb892543175fe0..051a4ed2b2e85c0ceeba7e36376eb1e8164cc036 100644
--- a/indra/newview/llpanelmaininventory.h
+++ b/indra/newview/llpanelmaininventory.h
@@ -29,6 +29,7 @@
 #define LL_LLPANELMAININVENTORY_H
 
 #include "llpanel.h"
+#include "llinventoryobserver.h"
 #include "lldndbutton.h"
 
 #include "llfolderview.h"
@@ -53,7 +54,7 @@ class LLFloater;
 //
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //BD
-class LLPanelMainInventory : public LLPanel
+class LLPanelMainInventory : public LLPanel, LLInventoryObserver
 {
 public:
 	friend class LLFloaterInventoryFinder;
@@ -71,6 +72,7 @@ class LLPanelMainInventory : public LLPanel
 									   void* cargo_data,
 									   EAcceptance* accept,
 									   std::string& tooltip_msg);
+	/*virtual*/ void changed(U32) {};
 	/*virtual*/ void draw();
 	/*virtual*/ void 	onVisibilityChange ( BOOL new_visibility );
 
@@ -100,7 +102,6 @@ class LLPanelMainInventory : public LLPanel
 	void toggleFindOptions();
 
     void resetFilters();
-    void resetAllItemsFilters();
 
 protected:
 	//
@@ -192,7 +193,6 @@ class LLPanelMainInventory : public LLPanel
 	void setUploadCostIfNeeded();
 private:
 	LLDragAndDropButton*		mTrashButton;
-	LLHandle<LLView>			mMenuAddHandle;
 
 	bool						mNeedUploadCost;
 	// List Commands                                                              //
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index 07505e696b2ad993cacf83836d648973b2dbe392..87e2a95d952cdf1b71c21e47578c94eb91c268fa 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -34,7 +34,6 @@
 #include "llbutton.h"
 #include "lltabcontainer.h"
 #include "llfloater.h"
-#include "llfloaterperformance.h"
 #include "llfloaterreg.h"
 #include "llpresetsmanager.h"
 #include "llsliderctrl.h"
@@ -57,7 +56,6 @@ LLPanelPresetsPulldown::LLPanelPresetsPulldown()
 	mHoverTimer.stop();
 
 	mCommitCallbackRegistrar.add("Presets.GoGraphicsPrefs", boost::bind(&LLPanelPresetsPulldown::onGraphicsButtonClick, this));
-    mCommitCallbackRegistrar.add("Presets.GoAutofpsPrefs", boost::bind(&LLPanelPresetsPulldown::onAutofpsButtonClick, this, _2));
 	mCommitCallbackRegistrar.add("Presets.RowClick", boost::bind(&LLPanelPresetsPulldown::onRowClick, this, _2));
 
 	buildFromFile( "panel_presets_pulldown.xml");
@@ -193,14 +191,4 @@ void LLPanelPresetsPulldown::onGraphicsButtonClick()
 
 	// bring up the prefs floater
 	gDragonLibrary.openPreferences("display");
-}
-
-void LLPanelPresetsPulldown::onAutofpsButtonClick(const LLSD& user_data)
-{
-    setVisible(FALSE);
-    LLFloaterPerformance* performance_floater = LLFloaterReg::showTypedInstance<LLFloaterPerformance>("performance");
-    if (performance_floater)
-    {
-        performance_floater->showAutoadjustmentsPanel();
-    }
-}
+}
\ No newline at end of file
diff --git a/indra/newview/llpanelpresetspulldown.h b/indra/newview/llpanelpresetspulldown.h
index 1897b9d3c276378e3e3993ef9764d1e51abe921f..9c3aa3207c927ae37286894fbc78015713690817 100644
--- a/indra/newview/llpanelpresetspulldown.h
+++ b/indra/newview/llpanelpresetspulldown.h
@@ -42,7 +42,6 @@ class LLPanelPresetsPulldown : public LLPanelPulldown
 	
  private:
 	void onGraphicsButtonClick();
-    void onAutofpsButtonClick(const LLSD& user_data);
 	void onRowClick(const LLSD& user_data);
 
 	std::list<std::string> mPresetNames;
diff --git a/indra/newview/llsearchableui.cpp b/indra/newview/llsearchableui.cpp
index 06d834c4ffe5602652bcfdfea11a3a17d193f365..7f2dbdfc228e079cf21513a3e9ed1da45787eff1 100644
--- a/indra/newview/llsearchableui.cpp
+++ b/indra/newview/llsearchableui.cpp
@@ -191,4 +191,4 @@ bool LLSearchableEntry::hightlightAndHide(LLWString const &aFilter, bool hide)
 		mMenu->setVisible(FALSE);
 	}
 	return bVisible || bHighlighted;
-}
+}
\ No newline at end of file
diff --git a/indra/newview/llsearchableui.h b/indra/newview/llsearchableui.h
index 7530c8f7ede36c1eb2d8ad22a97e827c89fa7b95..c60bac44c67d89f5641c257b3f7d7edf72d1da4c 100644
--- a/indra/newview/llsearchableui.h
+++ b/indra/newview/llsearchableui.h
@@ -27,6 +27,8 @@
 #define LL_SEARCHABLE_UI_H
 
 #include "llsearchablecontrol.h"
+#include "llmenugl.h"
+#include "llview.h"
 
 class LLMenuItemGL;
 class LLView;
@@ -104,6 +106,15 @@ class LLSearchableItem : public LLSearchableControl
 
 	void setNotHighlighted();
 	virtual bool hightlightAndHide(LLWString const &aFilter);
+
+	virtual std::string _getSearchText() const
+	{
+		return 0;
+	}
+
+	virtual void onSetHighlight() const // When highlight, really do highlight the label
+	{
+	}
 };
 
 class LLSearchableEntry : public LLSearchableControl
@@ -120,6 +131,17 @@ class LLSearchableEntry : public LLSearchableControl
 
 	void setNotHighlighted();
 	virtual bool hightlightAndHide(LLWString const &aFilter, bool hide = true);
+
+	virtual std::string _getSearchText() const
+	{
+		return mMenu->getLabel() + mMenu->getToolTip();
+	}
+
+	virtual void onSetHighlight() const // When highlight, really do highlight the label
+	{
+		if (mMenu)
+			mMenu->setHighlighted(getHighlighted());
+	}
 };
 
 #endif
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index bd9721f22283aeefa5a9c75b978b7173dcfa077b..87ec3437d0103a2addf0026f3be78d0e6d0d4863 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -1277,7 +1277,7 @@ void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryT
     }
     else
     {
-        S32 index = mModeSelector->getValue().asInteger();
+        S32 index = mTabModes->getCurrentPanelIndex();
         getChild<LLButton>("Pipette")->setVisible(index == 0);
     }
 
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index a5d7b528ee78881404f94322de1b7bfcf351c8e8..4e11b785b343631f383c4ddd62692654b8058190 100644
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -510,13 +510,7 @@ void LLGLTexMemBar::draw()
 	U32 texFetchLatMin = U32(recording.getMin(LLTextureFetch::sTexFetchLatency).value() * 1000.0f);
 	U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f);
 	U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f);
-
-	//BD
-	S32Megabytes bound_mem = LLViewerTexture::sBoundTextureMemory;
-	S32Megabytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMemory;
-	S32Megabytes total_mem = LLViewerTexture::sTotalTextureMemory;
-	S32Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
-
+	
 	F32Bytes total_texture_downloaded = gTotalTextureData;
 	F32Bytes total_object_downloaded = gTotalObjectData;
 
@@ -541,12 +535,12 @@ void LLGLTexMemBar::draw()
 	U32 total_objects = gObjectList.getNumObjects();
 	U32 fbo = LLRenderTarget::sBytesAllocated / (1024 * 1024);
 
-	if (gGLManager.mHasNVXMemInfo)
+	if (gGLManager.mIsNVIDIA)
 	{
 		glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_vram);
 		free_vram = (free_vram / 1024);
 	}
-	else if (gGLManager.mHasATIMemInfo)
+	else if (gGLManager.mIsAMD)
 	{
 		S32 meminfo[4];
 		glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo);
@@ -579,7 +573,7 @@ void LLGLTexMemBar::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 681, top,
 		text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
-	S32 available_vram = free_vram + total_mem.value() + bound_mem.value();
+	S32 available_vram = free_vram;
 	data_progress = (F32)available_vram / (F32)max_vram;
 
 	//BD - Render a multi-segmented multi-colored bar showing where our memory goes.
@@ -606,7 +600,7 @@ void LLGLTexMemBar::draw()
 		}
 
 		//BD - Render the system memory bar.
-		data_progress = ((F32)total_mem.value() - (F32)fbo) / (F32)max_vram;
+		data_progress = ((F32)available_vram - (F32)fbo) / (F32)max_vram;
 		left = right;
 		right = llfloor(llclamp(left + (bar_width * data_progress), (F32)left, bar_right));
 		if (right >= left)
@@ -616,20 +610,20 @@ void LLGLTexMemBar::draw()
 		}
 
 		//BD - Render the scene memory bar.
-		data_progress = (F32)bound_mem.value() / (F32)max_vram;
+		/*data_progress = (F32)bound_mem.value() / (F32)max_vram;
 		left = right;
 		right = llfloor(llclamp(left + (bar_width * data_progress), (F32)left, bar_right));
 		if (right >= left)
 		{
 			gGL.color4f(0.f, 0.75f, 0.75f, 0.75f);
 			gl_rect_2d(left, top - 9, right, top - 3);
-		}
+		}*/
 	}
 
 	//----------------------------------------------------------------------------
 	//BD - Total System (Viewer) Memory
 
-	text = llformat("System+FBO:  %5d MB", total_mem.value());
+	/*text = llformat("System+FBO:  %5d MB", total_mem.value());
 
 	top = v_offset + line_height * 9;
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, top,
@@ -698,7 +692,7 @@ void LLGLTexMemBar::draw()
 			gGL.color4f(0.f, 0.75f, 0.75f, 0.75f);
 			gl_rect_2d(left, top - 9, right, top - 3);
 		}
-	}
+	}*/
 
 	//----------------------------------------------------------------------------
 	//BD - Memory
@@ -709,7 +703,7 @@ void LLGLTexMemBar::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, top,
 		text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
-	text = llformat("Raw Total: %15d MB", LLImageRaw::sGlobalRawMemory >> 20);
+	//text = llformat("Raw Total: %15d MB", LLImageRaw::sGlobalRawMemory >> 20);
 
     /*text = llformat("GL Free: %d MB Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB",
                     gViewerWindow->getWindow()->getAvailableVRAMMegabytes(),
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index 7b01f7b57f5dbb16d313f39d92a4439d34edbc44..1ec8f231d4c7c70c889f8ce42c306f4202ac4028 100644
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -57,6 +57,7 @@
 
 //BD - Right Click Steering
 #include "lltoolpie.h"
+#include "llviewerinput.h"
 
 // Globals
 BOOL gCameraBtnZoom = TRUE;
@@ -401,8 +402,10 @@ BOOL LLToolCamera::handleRightMouseUp(S32 x, S32 y, MASK mask)
 	LLCoordGL pos;
 	pos.mX = x * gViewerWindow->getDisplayScale().mV[VX];
 	pos.mY = y * gViewerWindow->getDisplayScale().mV[VY];
-	gViewerWindow->handleAnyMouseClick(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, TRUE);
-	return gViewerWindow->handleAnyMouseClick(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, FALSE);
+	//gViewerWindow->handleAnyMouseClick(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, TRUE);
+	//return gViewerWindow->handleAnyMouseClick(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, FALSE);
+	gViewerInput.handleMouse(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, TRUE);
+	return gViewerInput.handleMouse(gViewerWindow->getWindow(), pos, mask, CLICK_RIGHT, FALSE);
 }
 
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index d1fe9aa62932ed0949a0db3a594235bc4be5a9fd..6ba7b819a9a80ce84cef8f9cd6454dead5d45f39 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -875,7 +875,7 @@ static bool handleTerrainScaleChanged(const LLSD& inputvalue)
 	return true;
 }
 
-static bool handleWaterResolutionChanged(const LLSD& newvalue)
+/*static bool handleWaterResolutionChanged(const LLSD& newvalue)
 {
 	gPipeline.handleReflectionChanges();
 	return true;
@@ -947,7 +947,7 @@ static bool handleShadowsChanged(const LLSD& newvalue)
 		gPipeline.allocateShadowMaps(newvalue);
 	}
 	return success;
-}
+}*/
 
 static bool handleTimeFactorChanged(const LLSD& newvalue)
 {
@@ -1000,7 +1000,7 @@ static bool handleAutomaticMemoryManagement(const LLSD& newvalue)
 {
 	if (!newvalue.asBoolean())
 	{
-		gTextureList.updateMaxResidentTexMem((S32Megabytes)0);
+		//gTextureList.updateMaxResidentTexMem((S32Megabytes)0);
 	}
 	gTextureList.mAutomaticMemoryManagement = newvalue.asBoolean();
 	return true;
@@ -1278,7 +1278,7 @@ void settings_setup_listeners()
 
 	//BD - System
 	gSavedSettings.getControl("SlowMotionTimeFactor")->getSignal()->connect(boost::bind(&handleTimeFactorChanged, _2));
-	gSavedSettings.getControl("SystemMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
+	//gSavedSettings.getControl("SystemMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
 	//BD - Automatic Memory Management
 	gSavedSettings.getControl("AutomaticMemoryManagement")->getSignal()->connect(boost::bind(&handleAutomaticMemoryManagement, _2));
 //	//BD - Catznip's Borderless Window Mode
@@ -1289,41 +1289,41 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("MachinimaSidebar")->getSignal()->connect(boost::bind(&handleMachinimaSidebar, _2));
 
 	//BD - Rendering (Lights)
-	gSavedSettings.getControl("RenderSpotLightReflections")->getSignal()->connect(boost::bind(&handleSpotlightsChanged, _2));
-	gSavedSettings.getControl("RenderSpotLightImages")->getSignal()->connect(boost::bind(&handleSpotlightsChanged, _2));
+	//gSavedSettings.getControl("RenderSpotLightReflections")->getSignal()->connect(boost::bind(&handleSpotlightsChanged, _2));
+	//gSavedSettings.getControl("RenderSpotLightImages")->getSignal()->connect(boost::bind(&handleSpotlightsChanged, _2));
 	gSavedSettings.getControl("RenderOtherAttachedLights")->getSignal()->connect(boost::bind(&handleRenderOtherAttachedLightsChanged, _2));
 	gSavedSettings.getControl("RenderOwnAttachedLights")->getSignal()->connect(boost::bind(&handleRenderOwnAttachedLightsChanged, _2));
 	gSavedSettings.getControl("RenderDeferredLights")->getSignal()->connect(boost::bind(&handleRenderDeferredLightsChanged, _2));
 
 	//BD - Rendering (Quality)
 	gSavedSettings.getControl("RenderTerrainScale")->getSignal()->connect(boost::bind(&handleTerrainScaleChanged, _2));
-	gSavedSettings.getControl("RenderWaterRefResolution")->getSignal()->connect(boost::bind(&handleWaterResolutionChanged, _2));
-	gSavedSettings.getControl("RenderNormalMapScale")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
-	gSavedSettings.getControl("RenderProjectorShadowResolution")->getSignal()->connect(boost::bind(&handleShadowMapsChanged, _2));
-	gSavedSettings.getControl("RenderShadowResolution")->getSignal()->connect(boost::bind(&handleShadowMapsChanged, _2));
-	gSavedSettings.getControl("RenderDepthOfFieldHighQuality")->getSignal()->connect(boost::bind(&handleDepthOfFieldChanged, _2));
-	gSavedSettings.getControl("RenderDeferredEnvironmentMap")->getSignal()->connect(boost::bind(&handleEnvironmentMapChanged, _2));
+	//gSavedSettings.getControl("RenderWaterRefResolution")->getSignal()->connect(boost::bind(&handleWaterResolutionChanged, _2));
+	//gSavedSettings.getControl("RenderNormalMapScale")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
+	//gSavedSettings.getControl("RenderProjectorShadowResolution")->getSignal()->connect(boost::bind(&handleShadowMapsChanged, _2));
+	//gSavedSettings.getControl("RenderShadowResolution")->getSignal()->connect(boost::bind(&handleShadowMapsChanged, _2));
+	//gSavedSettings.getControl("RenderDepthOfFieldHighQuality")->getSignal()->connect(boost::bind(&handleDepthOfFieldChanged, _2));
+	//gSavedSettings.getControl("RenderDeferredEnvironmentMap")->getSignal()->connect(boost::bind(&handleEnvironmentMapChanged, _2));
 	gSavedSettings.getControl("RenderHighPrecisionNormals")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 
 	//BD - Rendering (Main Toggles)
-	gSavedSettings.getControl("RenderScreenSpaceReflections")->getSignal()->connect(boost::bind(&handleSSRChanged, _2));
-	gSavedSettings.getControl("RenderSSRRoughness")->getSignal()->connect(boost::bind(&handleSSRChanged, _2));
-	gSavedSettings.getControl("RenderGodrays")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
+	//gSavedSettings.getControl("RenderScreenSpaceReflections")->getSignal()->connect(boost::bind(&handleSSRChanged, _2));
+	//gSavedSettings.getControl("RenderSSRRoughness")->getSignal()->connect(boost::bind(&handleSSRChanged, _2));
+	//gSavedSettings.getControl("RenderGodrays")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
 	//gSavedSettings.getControl("RenderDeferredBlurLight")->getSignal()->connect(boost::bind(&handleBlurLightChanged, _2));
-	gSavedSettings.getControl("RenderDeferredBlurLight")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
+	//gSavedSettings.getControl("RenderDeferredBlurLight")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
 	//gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleShadowsChanged, _2));
 	//gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSSAOChanged, _2));
-	gSavedSettings.getControl("RenderDepthOfField")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
+	//gSavedSettings.getControl("RenderDepthOfField")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
 //	//BD - Motion Blur
-	gSavedSettings.getControl("RenderMotionBlur")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	//gSavedSettings.getControl("RenderMotionBlur")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 //	//BD - Depth of Field
-	gSavedSettings.getControl("RenderDepthOfFieldFront")->getSignal()->connect(boost::bind(&handleDepthOfFieldChanged, _2));
+	//gSavedSettings.getControl("RenderDepthOfFieldFront")->getSignal()->connect(boost::bind(&handleDepthOfFieldChanged, _2));
 
 	//BD - Rendering (General)
 	gSavedSettings.getControl("RenderAttachedParticles")->getSignal()->connect(boost::bind(&handleRenderAttachedParticlesChanged, _2));
 	gSavedSettings.getControl("RenderEnableFullbright")->getSignal()->connect(boost::bind(&handleFullbrightChanged, _2));
 	gSavedSettings.getControl("RenderEnableAlpha")->getSignal()->connect(boost::bind(&handleAlphaChanged, _2));
-	gSavedSettings.getControl("RenderGodraysDirectional")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
+	//gSavedSettings.getControl("RenderGodraysDirectional")->getSignal()->connect(boost::bind(&handleGodraysChanged, _2));
 	gSavedSettings.getControl("RenderWaterHeightFudge")->getSignal()->connect(boost::bind(&handleWaterHeightChanged, _2));
 	gSavedSettings.getControl("RenderImpostors")->getSignal()->connect(boost::bind(&handleRenderImpostorsChanged, _2));
 
@@ -1487,8 +1487,8 @@ void settings_setup_listeners()
     setting_setup_signal_listener(gSavedSettings, "QAMode", show_debug_menus);
     setting_setup_signal_listener(gSavedSettings, "UseDebugMenus", show_debug_menus);
     setting_setup_signal_listener(gSavedSettings, "AgentPause", toggle_agent_pause);
-    setting_setup_signal_listener(gSavedSettings, "ShowNavbarNavigationPanel", toggle_show_navigation_panel);
-    setting_setup_signal_listener(gSavedSettings, "ShowMiniLocationPanel", toggle_show_mini_location_panel);
+    //setting_setup_signal_listener(gSavedSettings, "ShowNavbarNavigationPanel", toggle_show_navigation_panel);
+    //setting_setup_signal_listener(gSavedSettings, "ShowMiniLocationPanel", toggle_show_mini_location_panel);
     setting_setup_signal_listener(gSavedSettings, "ShowObjectRenderingCost", toggle_show_object_render_cost);
     setting_setup_signal_listener(gSavedSettings, "ForceShowGrid", handleForceShowGrid);
     setting_setup_signal_listener(gSavedSettings, "RenderTransparentWater", handleRenderTransparentWaterChanged);
diff --git a/indra/newview/llviewercontrol.h b/indra/newview/llviewercontrol.h
index d7191f5c8d5d8703ec7d76b80fdb8ab9a2c49259..43587bc1894a26ca625d4b7b877c7c99c525ccd8 100644
--- a/indra/newview/llviewercontrol.h
+++ b/indra/newview/llviewercontrol.h
@@ -37,16 +37,10 @@
 extern BOOL gHackGodmode;
 #endif
 
-bool toggle_show_navigation_panel(const LLSD& newvalue);
-bool toggle_show_favorites_panel(const LLSD& newvalue);
-
 // These functions found in llcontroldef.cpp *TODO: clean this up!
 //setting variables are declared in this function
 void settings_setup_listeners();
 
-// for the graphics settings
-void create_graphics_group(LLControlGroup& group);
-
 // saved at end of session
 extern LLControlGroup gSavedSettings;
 extern LLControlGroup gSavedPerAccountSettings;
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 30b40bbb883b570d4e03c9a66da8cdf7a74412aa..8e0139c26ecbff075946913dad0d4ea6358087d1 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -106,7 +106,6 @@
 #include "llfloaterpathfindingconsole.h"
 #include "llfloaterpathfindinglinksets.h"
 #include "llfloaterpay.h"
-#include "llfloaterperformance.h"
 #include "llfloaterperms.h"
 #include "llfloaterpostprocess.h"
 #include "llfloaterpreference.h"
@@ -419,7 +418,6 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>);
 	LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>);
 	LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("performance", "floater_performance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPerformance>);
 	LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>);
 	LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 2d089d693ae11ccaa46f09a17efec9e653318ae2..87972dc9b69ffd3124846782a1f20c4ce80f4e08 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -191,7 +191,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 		{
 			LLGLSLShader::sCurBoundShaderPtr->uniform4fv(LLViewerShaderMgr::AVATAR_MATRIX, 45, mat);
 //			//BD - Motion Blur
-			if (LLGLSLShader::sCurBoundShaderPtr == &gAvatarVelocityProgram)
+			/*if (LLGLSLShader::sCurBoundShaderPtr == &gAvatarVelocityProgram)
 			{
 				if (!mLastMatrixPalette)
 				{
@@ -207,7 +207,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 
 				memcpy(mLastMatrixPalette, mat, sizeof(F32) * 45 * 4);
 				mLastMatrixPaletteUpdated = gFrameCount;
-			}
+			}*/
 		}
 		stop_glerror();
 	}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 4445aa63683beb4cb1297100bbbad9de38c60356..c6bfaf62cec0ffd885839453ebd951437b3c7069 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1294,8 +1294,6 @@ void set_use_wireframe(bool useWireframe)
 			initial_deferred = LLPipeline::sRenderDeferred;
 		}
 
-		gPipeline.resetVertexBuffers();
-
 		if (!gUseWireframe && !initial_deferred && LLPipeline::sRenderDeferred != bool(initial_deferred) && gPipeline.isInit())
 		{
 			LLPipeline::refreshCachedSettings();
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index dc019371a2cfc113e0aa8dab6b1d216378f059ff..b96934efc520c3e659dc60d2d9db5a6fd111761a 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -770,6 +770,9 @@ class LLViewerObject
     static const S32 CO_FLAG_CONTROL_AVATAR = 1 << 0;
     static const S32 CO_FLAG_UI_AVATAR = 1 << 1;
 
+	//BD
+	LLPointer<LLViewerPartSourceScript>& getParticleSource() { return mPartSourcep; };
+
 protected:
     LLPointer<LLControlAvatar> mControlAvatar;
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 81097e5602bdc77cf48bbe41f64f44ddc7df3632..90cce51122c29b15273136d0b2d63b86ad0cf2d0 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -796,7 +796,7 @@ void LLViewerObjectList::setAllObjectDefaultTextures(U32 nChannel, bool fShowDef
 			}
 
 			if (LLVOVolume* pVoVolume = pDrawable->getVOVolume())
-				pVoVolume->markForUpdate(true);
+				pVoVolume->markForUpdate();
 		}
 	}
 }
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index f7b1f43e612cbb35bb36df55e24cb0082118e247..82b16d67bd62d1be2d00b79002f292b78f80799c 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -227,30 +227,6 @@ LLGLSLShader            gDeferredSkinnedPBRAlphaProgram;
 LLGLSLShader            gDeferredPBRAlphaWaterProgram;
 LLGLSLShader            gDeferredSkinnedPBRAlphaWaterProgram;
 
-//BD - Exodus Post Process
-LLGLSLShader            gColorGradePost;
-LLGLSLShader            gLinearToneMapping;
-LLGLSLShader            gReinhardToneMapping;
-LLGLSLShader            gFilmicToneMapping;
-LLGLSLShader            gVignettePost;
-LLGLSLShader            gColorGradePostLegacy;
-LLGLSLShader            gFilmicToneMappingAdv;
-
-//BD
-LLGLSLShader            gSpecialPost;
-LLGLSLShader            gLensFlare;
-
-//BD - Volumetric Lighting
-LLGLSLShader			gVolumetricLightProgram;
-
-//BD - Motion Blur
-LLGLSLShader			gVelocityProgram;
-LLGLSLShader			gVelocityAlphaProgram;
-LLGLSLShader			gAvatarVelocityProgram;
-LLGLSLShader			gSkinnedVelocityProgram;
-LLGLSLShader			gSkinnedVelocityAlphaProgram;
-LLGLSLShader			gMotionBlurProgram;
-
 //helper for making a rigged variant of a given shader
 bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader)
 {
@@ -329,8 +305,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
     mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma
     mShaderList.push_back(&gNoPostGammaCorrectProgram);
     mShaderList.push_back(&gLegacyPostGammaCorrectProgram);
-//	//BD - Volumetric Lighting
-	mShaderList.push_back(&gVolumetricLightProgram);
+
 }
 
 LLViewerShaderMgr::~LLViewerShaderMgr()
@@ -455,6 +430,7 @@ void LLViewerShaderMgr::setShaders()
 
     llassert((gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10));
 
+    
     S32 light_class = 3;
     S32 interface_class = 2;
     S32 env_class = 2;
@@ -653,8 +629,6 @@ std::string LLViewerShaderMgr::loadBasicShaders()
 	if (gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)
 	{
 		shaders.push_back( make_pair( "objects/indexedTextureV.glsl",           1 ) );
-//		//BD - Motion Blur
-		shaders.push_back(make_pair("deferred/velocityFuncV.glsl", 1));
 	}
 	shaders.push_back( make_pair( "objects/nonindexedTextureV.glsl",        1 ) );
 
@@ -945,9 +919,6 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
 		}
 	}
 	
-//	//BD - Exodus Post Process
-	success = loadExodusPostShaders();
-
 	return success;
 
 }
@@ -1055,6 +1026,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 			gDeferredMaterialProgram[i].unload();
 			gDeferredMaterialWaterProgram[i].unload();
 		}
+
         gHUDPBROpaqueProgram.unload();
         gPBRGlowProgram.unload();
         gDeferredPBROpaqueProgram.unload();
@@ -1064,20 +1036,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredPBRAlphaWaterProgram.unload();
         gDeferredSkinnedPBRAlphaWaterProgram.unload();
 
-//		//BD - Exodus Post Process
-		unloadExodusPostShaders();
-
-//		//BD - Volumetric Lighting
-		gVolumetricLightProgram.unload();
-
-//		//BD - Motion Blur
-		gVelocityProgram.unload();
-		gVelocityAlphaProgram.unload();
-		gAvatarVelocityProgram.unload();
-		gSkinnedVelocityProgram.unload();
-		gSkinnedVelocityAlphaProgram.unload();
-		gMotionBlurProgram.unload();
-
 		return TRUE;
 	}
 
@@ -2257,10 +2215,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredSoftenProgram.clearPermutations();
 		gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER));
 		gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER));
-		//BD - Screen Space Reflections
-		gDeferredSoftenProgram.addPermutation("USE_SSR", (bool)gSavedSettings.getBOOL("RenderScreenSpaceReflections") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_RAND", (bool)gSavedSettings.getBOOL("RenderSSRRoughness") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_ENV_MAP", (bool)gSavedSettings.getBOOL("RenderDeferredEnvironmentMap") ? "1" : "0");
 
 		gDeferredSoftenProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
 
@@ -2319,11 +2273,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
             gDeferredSoftenWaterProgram.addPermutation("HAS_SUN_SHADOW", "1");
         }
 
-		//BD - Screen Space Reflections
-		gDeferredSoftenProgram.addPermutation("USE_SSR", (bool)gSavedSettings.getBOOL("RenderScreenSpaceReflections") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_RAND", (bool)gSavedSettings.getBOOL("RenderSSRRoughness") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_ENV_MAP", (bool)gSavedSettings.getBOOL("RenderDeferredEnvironmentMap") ? "1" : "0");
-
         if (ambient_kill)
         {
             gDeferredSoftenWaterProgram.addPermutation("AMBIENT_KILL", "1");
@@ -2682,36 +2631,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 	if (success)
 	{
-		string fragment = "deferred/postDeferredF.glsl";
-		if (gSavedSettings.getBOOL("RenderDepthOfFieldHighQuality"))
-		{
-			fragment = "deferred/postDeferredHQDoFF.glsl";
-		}
 		gDeferredPostProgram.mName = "Deferred Post Shader";
         gDeferredPostProgram.mFeatures.isDeferred = true;
 		gDeferredPostProgram.mShaderFiles.clear();
 		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
-		gDeferredPostProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER));
-		gDeferredPostProgram.addPermutation("FRONT_BLUR", (bool)gSavedSettings.getBOOL("RenderDepthOfFieldFront") ? "1" : "0");
+		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER));
 		gDeferredPostProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
 		success = gDeferredPostProgram.createShader(NULL, NULL);
 		llassert(success);
 	}
 
-//	//BD - Volumetric Lighting
-	if (success)
-	{
-		gVolumetricLightProgram.mName = "Volumetric Light Shader";
-		gVolumetricLightProgram.mShaderFiles.clear();
-		gVolumetricLightProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
-		gVolumetricLightProgram.mShaderFiles.push_back(make_pair("deferred/volumetricLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gVolumetricLightProgram.addPermutation("GODRAYS_FADE", (bool)gSavedSettings.getBOOL("RenderGodraysDirectional") ? "1" : "0");
-		gVolumetricLightProgram.addPermutation("HAS_NO_DOF", (bool)gSavedSettings.getBOOL("RenderDepthOfField") ? "0" : "1");
-		gVolumetricLightProgram.mFeatures.hasAtmospherics = true;
-		gVolumetricLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gVolumetricLightProgram.createShader(NULL, NULL);
-	}
-
 	if (success)
 	{
 		gDeferredCoFProgram.mName = "Deferred CoF Shader";
@@ -2748,82 +2677,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		llassert(success);
 	}
 
-//	//BD - Motion Blur
-	if (success)
-	{
-		gVelocityProgram.mName = "Velocity Shader";
-		gVelocityProgram.mFeatures.isDeferred = true;
-		gVelocityProgram.mFeatures.hasMotionBlur = true;
-		gVelocityProgram.mShaderFiles.clear();
-		gVelocityProgram.mShaderFiles.push_back(make_pair("deferred/velocityV.glsl", GL_VERTEX_SHADER_ARB));
-		gVelocityProgram.mShaderFiles.push_back(make_pair("deferred/velocityF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gVelocityProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gVelocityProgram.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gVelocityAlphaProgram.mName = "Velocity Alpha Shader";
-		gVelocityAlphaProgram.mFeatures.isDeferred = true;
-		gVelocityAlphaProgram.mFeatures.hasMotionBlur = true;
-		gVelocityAlphaProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
-		gVelocityAlphaProgram.mShaderFiles.clear();
-		gVelocityAlphaProgram.mShaderFiles.push_back(make_pair("deferred/velocityAlphaV.glsl", GL_VERTEX_SHADER_ARB));
-		gVelocityAlphaProgram.mShaderFiles.push_back(make_pair("deferred/velocityAlphaF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gVelocityAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gVelocityAlphaProgram.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gAvatarVelocityProgram.mName = "Avatar Velocity Shader";
-		gAvatarVelocityProgram.mFeatures.isDeferred = true;
-		gAvatarVelocityProgram.mFeatures.hasSkinning = true;
-		gAvatarVelocityProgram.mFeatures.hasMotionBlur = true;
-		gAvatarVelocityProgram.mShaderFiles.clear();
-		gAvatarVelocityProgram.mShaderFiles.push_back(make_pair("deferred/avatarVelocityV.glsl", GL_VERTEX_SHADER_ARB));
-		gAvatarVelocityProgram.mShaderFiles.push_back(make_pair("deferred/avatarVelocityF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gAvatarVelocityProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gAvatarVelocityProgram.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gSkinnedVelocityProgram.mName = "Skinned Velocity Shader";
-		gSkinnedVelocityProgram.mFeatures.isDeferred = true;
-		gSkinnedVelocityProgram.mFeatures.hasMotionBlur = true;
-		gSkinnedVelocityProgram.mFeatures.hasObjectSkinning = true;
-		gSkinnedVelocityProgram.mShaderFiles.clear();
-		gSkinnedVelocityProgram.mShaderFiles.push_back(make_pair("deferred/skinnedVelocityV.glsl", GL_VERTEX_SHADER_ARB));
-		gSkinnedVelocityProgram.mShaderFiles.push_back(make_pair("deferred/velocityF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gSkinnedVelocityProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gSkinnedVelocityProgram.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gSkinnedVelocityAlphaProgram.mName = "Skinned Velocity Alpha Shader";
-		gSkinnedVelocityAlphaProgram.mFeatures.isDeferred = true;
-		gSkinnedVelocityAlphaProgram.mFeatures.hasMotionBlur = true;
-		gSkinnedVelocityAlphaProgram.mFeatures.hasObjectSkinning = true;
-		gSkinnedVelocityAlphaProgram.mShaderFiles.clear();
-		gSkinnedVelocityAlphaProgram.mShaderFiles.push_back(make_pair("deferred/skinnedVelocityAlphaV.glsl", GL_VERTEX_SHADER_ARB));
-		gSkinnedVelocityAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarVelocityF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gSkinnedVelocityAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gSkinnedVelocityAlphaProgram.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gMotionBlurProgram.mName = "Motion Blur Shader";
-		gMotionBlurProgram.mFeatures.isDeferred = true;
-		gMotionBlurProgram.mShaderFiles.clear();
-		gMotionBlurProgram.mShaderFiles.push_back(make_pair("deferred/motionBlurV.glsl", GL_VERTEX_SHADER_ARB));
-		gMotionBlurProgram.mShaderFiles.push_back(make_pair("deferred/motionBlurF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gMotionBlurProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gMotionBlurProgram.createShader(NULL, NULL);
-	}
-
 	if (success)
 	{
 		gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader";
@@ -3455,974 +3308,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
 	return TRUE;
 }
 
-//BD - Exodus Post Process
-void LLViewerShaderMgr::unloadExodusPostShaders()
-{
-	gColorGradePost.unload();
-	gLinearToneMapping.unload();
-	gReinhardToneMapping.unload();
-	gFilmicToneMapping.unload();
-	gVignettePost.unload();
-	gFilmicToneMappingAdv.unload();
-
-	gSpecialPost.unload();
-	gLensFlare.unload();
-}
-
-BOOL LLViewerShaderMgr::loadExodusPostShaders()
-{
-	BOOL success = TRUE;
-	//We only ever want to load these in deferred (as we'll probably never use floating point buffers in classic rendering)
-	if (LLPipeline::sRenderDeferred)
-	{
-		if (success)
-		{
-			gFilmicToneMapping.mName = "Exodus Filmic Tonemapping Post";
-			gFilmicToneMapping.mShaderFiles.clear();
-			gFilmicToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-			gFilmicToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoFilmicToneF.glsl", GL_FRAGMENT_SHADER_ARB));
-			gFilmicToneMapping.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-			success = gFilmicToneMapping.createShader(NULL, NULL);
-		}
-
-		if (success)
-		{
-			gFilmicToneMappingAdv.mName = "Exodus Advanced Filmic Tonemapping";
-			gFilmicToneMappingAdv.mShaderFiles.clear();
-			gFilmicToneMappingAdv.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-			gFilmicToneMappingAdv.mShaderFiles.push_back(make_pair("exoshade/post/exoFilmicToneAdvancedF.glsl", GL_FRAGMENT_SHADER_ARB));
-			gFilmicToneMappingAdv.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-			success = gFilmicToneMappingAdv.createShader(NULL, NULL);
-		}
-	}
-
-	if (success)
-	{
-		gVignettePost.mName = "Exodus Vignette Post";
-		gVignettePost.mShaderFiles.clear();
-		gVignettePost.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gVignettePost.mShaderFiles.push_back(make_pair("exoshade/post/exoVignetteF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gVignettePost.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gVignettePost.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gLensFlare.mName = "Lens Flare";
-		gLensFlare.mShaderFiles.clear();
-		gLensFlare.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gLensFlare.mShaderFiles.push_back(make_pair("exoshade/post/exoLensF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gLensFlare.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gLensFlare.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gSpecialPost.mName = "Special Post";
-		gSpecialPost.mShaderFiles.clear();
-		gSpecialPost.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gSpecialPost.mShaderFiles.push_back(make_pair("exoshade/post/exoSpecialF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gSpecialPost.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gSpecialPost.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gColorGradePost.mName = "Exodus Color Grading Post";
-		gColorGradePost.mShaderFiles.clear();
-		gColorGradePost.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gColorGradePost.mShaderFiles.push_back(make_pair("exoshade/post/exoColorGradeF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gColorGradePost.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gColorGradePost.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gLinearToneMapping.mName = "Exodus Linear Tonemapping Post";
-		gLinearToneMapping.mShaderFiles.clear();
-		gLinearToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gLinearToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoLinearToneF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gLinearToneMapping.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gLinearToneMapping.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gReinhardToneMapping.mName = "Exodus Reinhard Tonemapping Post";
-		gReinhardToneMapping.mShaderFiles.clear();
-		gReinhardToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gReinhardToneMapping.mShaderFiles.push_back(make_pair("exoshade/post/exoReinhardToneF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gReinhardToneMapping.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gReinhardToneMapping.createShader(NULL, NULL);
-	}
-
-	if (success)
-	{
-		gColorGradePostLegacy.mName = "Exodus Legacy Color Grading Post";
-		gColorGradePostLegacy.mShaderFiles.clear();
-		gColorGradePostLegacy.mShaderFiles.push_back(make_pair("exoshade/post/exoPostBaseV.glsl", GL_VERTEX_SHADER_ARB));
-		gColorGradePostLegacy.mShaderFiles.push_back(make_pair("exoshade/post/exoColorGradeLegacyF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gColorGradePostLegacy.mShaderLevel = mShaderLevel[SHADER_EFFECT];
-		success = gColorGradePostLegacy.createShader(NULL, NULL);
-	}
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersGodrays(bool success)
-{
-	//BD - Volumetric Lighting
-	gVolumetricLightProgram.unload();
-
-	if (success)
-	{
-		gVolumetricLightProgram.mName = "Volumetric Light Shader";
-		gVolumetricLightProgram.mShaderFiles.clear();
-		gVolumetricLightProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
-		gVolumetricLightProgram.mShaderFiles.push_back(make_pair("deferred/volumetricLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gVolumetricLightProgram.addPermutation("GODRAYS_FADE", (bool)gSavedSettings.getBOOL("RenderGodraysDirectional") ? "1" : "0");
-		gVolumetricLightProgram.addPermutation("HAS_NO_DOF", (bool)gSavedSettings.getBOOL("RenderDepthOfField") ? "0" : "1");
-		gVolumetricLightProgram.mFeatures.hasAtmospherics = true;
-		gVolumetricLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gVolumetricLightProgram.createShader(NULL, NULL);
-	}
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersBlurLight(bool success)
-{
-	//BD - Soften Light
-	gDeferredBlurLightProgram.unload();
-	if (success)
-	{
-		gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader";
-		gDeferredBlurLightProgram.mFeatures.isDeferred = true;
-
-		gDeferredBlurLightProgram.mShaderFiles.clear();
-		gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gDeferredBlurLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		success = gDeferredBlurLightProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersSSR(bool success)
-{
-	bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1;
-
-	BOOL ambient_kill = gSavedSettings.getBOOL("AmbientDisable");
-	BOOL sunlight_kill = gSavedSettings.getBOOL("SunlightDisable");
-	BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable");
-
-	//BD - Screen Space Reflections
-	gDeferredSoftenProgram.unload();
-	gDeferredSoftenWaterProgram.unload();
-
-	if (success)
-	{
-		gDeferredSoftenProgram.mName = "Deferred Soften Shader";
-		gDeferredSoftenProgram.mShaderFiles.clear();
-		gDeferredSoftenProgram.mFeatures.hasSrgb = true;
-		gDeferredSoftenProgram.mFeatures.calculatesAtmospherics = true;
-		gDeferredSoftenProgram.mFeatures.hasAtmospherics = true;
-		gDeferredSoftenProgram.mFeatures.hasTransport = true;
-		gDeferredSoftenProgram.mFeatures.hasGamma = true;
-		gDeferredSoftenProgram.mFeatures.isDeferred = true;
-		gDeferredSoftenProgram.mFeatures.hasShadows = use_sun_shadow;
-
-		gDeferredSoftenProgram.clearPermutations();
-		gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		//BD - Screen Space Reflections
-		gDeferredSoftenProgram.addPermutation("USE_SSR", (bool)gSavedSettings.getBOOL("RenderScreenSpaceReflections") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_RAND", (bool)gSavedSettings.getBOOL("RenderSSRRoughness") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_ENV_MAP", (bool)gSavedSettings.getBOOL("RenderDeferredEnvironmentMap") ? "1" : "0");
-
-		gDeferredSoftenProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		if (ambient_kill)
-		{
-			gDeferredSoftenProgram.addPermutation("AMBIENT_KILL", "1");
-		}
-
-		if (sunlight_kill)
-		{
-			gDeferredSoftenProgram.addPermutation("SUNLIGHT_KILL", "1");
-		}
-
-		if (local_light_kill)
-		{
-			gDeferredSoftenProgram.addPermutation("LOCAL_LIGHT_KILL", "1");
-		}
-
-		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
-		{ //if using SSAO, take screen space light map into account as if shadows are enabled
-			gDeferredSoftenProgram.mShaderLevel = llmax(gDeferredSoftenProgram.mShaderLevel, 2);
-		}
-
-		success = gDeferredSoftenProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	if (success)
-	{
-		gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader";
-		gDeferredSoftenWaterProgram.mShaderFiles.clear();
-		gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-
-		gDeferredSoftenWaterProgram.clearPermutations();
-		gDeferredSoftenWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		gDeferredSoftenWaterProgram.addPermutation("WATER_FOG", "1");
-		gDeferredSoftenWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
-		gDeferredSoftenWaterProgram.mFeatures.hasWaterFog = true;
-		gDeferredSoftenWaterProgram.mFeatures.hasSrgb = true;
-		gDeferredSoftenWaterProgram.mFeatures.calculatesAtmospherics = true;
-		gDeferredSoftenWaterProgram.mFeatures.hasAtmospherics = true;
-		gDeferredSoftenWaterProgram.mFeatures.hasTransport = true;
-		gDeferredSoftenWaterProgram.mFeatures.hasGamma = true;
-		gDeferredSoftenWaterProgram.mFeatures.isDeferred = true;
-		gDeferredSoftenWaterProgram.mFeatures.hasShadows = use_sun_shadow;
-
-		//BD - Screen Space Reflections
-		gDeferredSoftenProgram.addPermutation("USE_SSR", (bool)gSavedSettings.getBOOL("RenderScreenSpaceReflections") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_RAND", (bool)gSavedSettings.getBOOL("RenderSSRRoughness") ? "1" : "0");
-		gDeferredSoftenProgram.addPermutation("USE_ENV_MAP", (bool)gSavedSettings.getBOOL("RenderDeferredEnvironmentMap") ? "1" : "0");
-
-		if (ambient_kill)
-		{
-			gDeferredSoftenWaterProgram.addPermutation("AMBIENT_KILL", "1");
-		}
-
-		if (sunlight_kill)
-		{
-			gDeferredSoftenWaterProgram.addPermutation("SUNLIGHT_KILL", "1");
-		}
-
-		if (local_light_kill)
-		{
-			gDeferredSoftenWaterProgram.addPermutation("LOCAL_LIGHT_KILL", "1");
-		}
-
-		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
-		{ //if using SSAO, take screen space light map into account as if shadows are enabled
-			gDeferredSoftenWaterProgram.mShaderLevel = llmax(gDeferredSoftenWaterProgram.mShaderLevel, 2);
-		}
-
-		success = gDeferredSoftenWaterProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersMaterials(bool success)
-{
-	bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1;
-
-	BOOL ambient_kill = gSavedSettings.getBOOL("AmbientDisable");
-	BOOL sunlight_kill = gSavedSettings.getBOOL("SunlightDisable");
-	BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable");
-
-	gDeferredBumpProgram.unload();
-
-	gDeferredHighlightProgram.unload();
-	gDeferredHighlightNormalProgram.unload();
-	gDeferredHighlightSpecularProgram.unload();
-
-	gNormalMapGenProgram.unload();
-	for (U32 i = 0; i < LLMaterial::SHADER_COUNT * 2; ++i)
-	{
-		gDeferredMaterialProgram[i].unload();
-		gDeferredMaterialWaterProgram[i].unload();
-	}
-
-	if (success)
-	{
-		gDeferredBumpProgram.mName = "Deferred Bump Shader";
-		gDeferredBumpProgram.mFeatures.encodesNormal = true;
-		gDeferredBumpProgram.mShaderFiles.clear();
-		gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gDeferredBumpProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = make_rigged_variant(gDeferredBumpProgram, gDeferredSkinnedBumpProgram);
-		success = success && gDeferredBumpProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	gDeferredMaterialProgram[1].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[5].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[9].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[13].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[1 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[5 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[9 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialProgram[13 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-
-	gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[1 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[5 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[9 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-	gDeferredMaterialWaterProgram[13 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = false;
-
-	for (U32 i = 0; i < LLMaterial::SHADER_COUNT * 2; ++i)
-	{
-		if (success)
-		{
-			mShaderList.push_back(&gDeferredMaterialProgram[i]);
-
-			gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i);
-
-			U32 alpha_mode = i & 0x3;
-
-			gDeferredMaterialProgram[i].mShaderFiles.clear();
-			gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
-			gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
-			gDeferredMaterialProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-			gDeferredMaterialProgram[i].clearPermutations();
-
-			bool has_normal_map = (i & 0x8) > 0;
-			bool has_specular_map = (i & 0x4) > 0;
-
-			if (has_normal_map)
-			{
-				gDeferredMaterialProgram[i].addPermutation("HAS_NORMAL_MAP", "1");
-			}
-
-			if (has_specular_map)
-			{
-				gDeferredMaterialProgram[i].addPermutation("HAS_SPECULAR_MAP", "1");
-			}
-
-			if (ambient_kill)
-			{
-				gDeferredMaterialProgram[i].addPermutation("AMBIENT_KILL", "1");
-			}
-
-			if (sunlight_kill)
-			{
-				gDeferredMaterialProgram[i].addPermutation("SUNLIGHT_KILL", "1");
-			}
-
-			if (local_light_kill)
-			{
-				gDeferredMaterialProgram[i].addPermutation("LOCAL_LIGHT_KILL", "1");
-			}
-
-			gDeferredMaterialProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode));
-
-			if (use_sun_shadow)
-			{
-				gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", "1");
-			}
-
-			bool has_skin = i & 0x10;
-			gDeferredMaterialProgram[i].mFeatures.hasSrgb = true;
-			gDeferredMaterialProgram[i].mFeatures.hasTransport = true;
-			gDeferredMaterialProgram[i].mFeatures.encodesNormal = true;
-			gDeferredMaterialProgram[i].mFeatures.calculatesAtmospherics = true;
-			gDeferredMaterialProgram[i].mFeatures.hasAtmospherics = true;
-			gDeferredMaterialProgram[i].mFeatures.hasGamma = true;
-			gDeferredMaterialProgram[i].mFeatures.hasShadows = use_sun_shadow;
-
-			if (has_skin)
-			{
-				gDeferredMaterialProgram[i].addPermutation("HAS_SKIN", "1");
-				gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true;
-			}
-			else
-			{
-				gDeferredMaterialProgram[i].mRiggedVariant = &gDeferredMaterialProgram[i + 0x10];
-			}
-
-			success = gDeferredMaterialProgram[i].createShader(NULL, NULL);
-			llassert(success);
-		}
-
-		if (success)
-		{
-			mShaderList.push_back(&gDeferredMaterialWaterProgram[i]);
-
-			gDeferredMaterialWaterProgram[i].mName = llformat("Deferred Underwater Material Shader %d", i);
-
-			U32 alpha_mode = i & 0x3;
-
-			gDeferredMaterialWaterProgram[i].mShaderFiles.clear();
-			gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB));
-			gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB));
-			gDeferredMaterialWaterProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-			gDeferredMaterialWaterProgram[i].mShaderGroup = LLGLSLShader::SG_WATER;
-
-			gDeferredMaterialWaterProgram[i].clearPermutations();
-
-			bool has_normal_map = (i & 0x8) > 0;
-			bool has_specular_map = (i & 0x4) > 0;
-
-			if (has_normal_map)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", "1");
-			}
-
-			if (has_specular_map)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", "1");
-			}
-
-			gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode));
-			if (use_sun_shadow)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", "1");
-			}
-
-			bool has_skin = i & 0x10;
-			if (has_skin)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN", "1");
-			}
-			else
-			{
-				gDeferredMaterialWaterProgram[i].mRiggedVariant = &(gDeferredMaterialWaterProgram[i + 0x10]);
-			}
-			gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG", "1");
-
-			if (ambient_kill)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("AMBIENT_KILL", "1");
-			}
-
-			if (sunlight_kill)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("SUNLIGHT_KILL", "1");
-			}
-
-			if (local_light_kill)
-			{
-				gDeferredMaterialWaterProgram[i].addPermutation("LOCAL_LIGHT_KILL", "1");
-			}
-
-			gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.hasSrgb = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.encodesNormal = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.calculatesAtmospherics = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.hasAtmospherics = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.hasGamma = true;
-
-			gDeferredMaterialWaterProgram[i].mFeatures.hasTransport = true;
-			gDeferredMaterialWaterProgram[i].mFeatures.hasShadows = use_sun_shadow;
-
-			if (has_skin)
-			{
-				gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true;
-			}
-
-			success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);//&mWLUniforms);
-			llassert(success);
-		}
-	}
-
-	gDeferredMaterialProgram[1].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[5].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[9].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[13].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[1 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[5 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[9 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialProgram[13 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-
-	gDeferredMaterialWaterProgram[1].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[5].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[9].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[13].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[1 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[5 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[9 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-	gDeferredMaterialWaterProgram[13 + LLMaterial::SHADER_COUNT].mFeatures.hasLighting = true;
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersDOF(bool success)
-{
-	//BD - Depth Of Field
-	gDeferredPostProgram.unload();
-
-	if (success)
-	{
-		string fragment = "deferred/postDeferredF.glsl";
-		if (gSavedSettings.getBOOL("RenderDepthOfFieldHighQuality"))
-		{
-			fragment = "deferred/postDeferredHQDoFF.glsl";
-		}
-		gDeferredPostProgram.mName = "Deferred Post Shader";
-		gFXAAProgram.mFeatures.isDeferred = true;
-		gDeferredPostProgram.mShaderFiles.clear();
-		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredPostProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
-		gDeferredPostProgram.addPermutation("FRONT_BLUR", (bool)gSavedSettings.getBOOL("RenderDepthOfFieldFront") ? "1" : "0");
-		gDeferredPostProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-		success = gDeferredPostProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersSpotlights(bool success)
-{
-	BOOL ambient_kill = gSavedSettings.getBOOL("AmbientDisable");
-	BOOL sunlight_kill = gSavedSettings.getBOOL("SunlightDisable");
-	BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable");
-
-	//BD - Deferred Spotlights
-	gDeferredSpotLightProgram.unload();
-	gDeferredMultiSpotLightProgram.unload();
-	if (success)
-	{
-		gDeferredSpotLightProgram.mName = "Deferred SpotLight Shader";
-		gDeferredSpotLightProgram.mShaderFiles.clear();
-		gDeferredSpotLightProgram.mFeatures.hasSrgb = true;
-		gDeferredSpotLightProgram.mFeatures.isDeferred = true;
-		gDeferredSpotLightProgram.mFeatures.hasShadows = true;
-
-		gDeferredSpotLightProgram.clearPermutations();
-		gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gDeferredSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		if (ambient_kill)
-		{
-			gDeferredSpotLightProgram.addPermutation("AMBIENT_KILL", "1");
-		}
-
-		if (sunlight_kill)
-		{
-			gDeferredSpotLightProgram.addPermutation("SUNLIGHT_KILL", "1");
-		}
-
-		if (local_light_kill)
-		{
-			gDeferredSpotLightProgram.addPermutation("LOCAL_LIGHT_KILL", "1");
-		}
-
-		success = gDeferredSpotLightProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	if (success)
-	{
-		gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader";
-		gDeferredMultiSpotLightProgram.mFeatures.hasSrgb = true;
-		gDeferredMultiSpotLightProgram.mFeatures.isDeferred = true;
-		gDeferredMultiSpotLightProgram.mFeatures.hasShadows = true;
-
-		gDeferredMultiSpotLightProgram.clearPermutations();
-		gDeferredMultiSpotLightProgram.mShaderFiles.clear();
-		gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gDeferredMultiSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		if (local_light_kill)
-		{
-			gDeferredMultiSpotLightProgram.addPermutation("LOCAL_LIGHT_KILL", "1");
-		}
-
-		success = gDeferredMultiSpotLightProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersSSAO(bool success)
-{
-	gDeferredSunProgram.unload();
-
-	if (success)
-	{
-		std::string fragment;
-		std::string vertex = "deferred/sunLightV.glsl";
-
-		bool use_ao = gSavedSettings.getBOOL("RenderDeferredSSAO");
-
-		if (use_ao)
-		{
-			fragment = "deferred/sunLightSSAOF.glsl";
-		}
-		else
-		{
-			fragment = "deferred/sunLightF.glsl";
-			if (mShaderLevel[SHADER_DEFERRED] == 1)
-			{ //no shadows, no SSAO, no frag coord
-				vertex = "deferred/sunLightNoFragCoordV.glsl";
-			}
-		}
-
-		gDeferredSunProgram.mName = "Deferred Sun Shader";
-		gDeferredSunProgram.mFeatures.isDeferred = true;
-		gDeferredSunProgram.mFeatures.hasShadows = true;
-		gDeferredSunProgram.mFeatures.hasAmbientOcclusion = use_ao;
-
-		gDeferredSunProgram.mName = "Deferred Sun Shader";
-		gDeferredSunProgram.mShaderFiles.clear();
-		gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER_ARB));
-		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
-		gDeferredSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		success = gDeferredSunProgram.createShader(NULL, NULL);
-		llassert(success);
-	}
-
-	return success;
-}
-
-BOOL LLViewerShaderMgr::loadShadersShadows(bool success)
-{
-	bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1;
-
-	BOOL ambient_kill = gSavedSettings.getBOOL("AmbientDisable");
-	BOOL sunlight_kill = gSavedSettings.getBOOL("SunlightDisable");
-	BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable");
-
-	//BD - Shadows
-	gDeferredSkinnedAlphaProgram.unload();
-	gDeferredAlphaProgram.unload();
-	gDeferredAlphaImpostorProgram.unload();
-	gDeferredSkinnedAlphaImpostorProgram.unload();
-	gDeferredAlphaWaterProgram.unload();
-	gDeferredSkinnedAlphaWaterProgram.unload();
-	gDeferredAvatarAlphaProgram.unload();
-
-	if (success)
-	{
-		for (int i = 0; i < 2 && success; ++i)
-		{
-			LLGLSLShader* shader = nullptr;
-			bool rigged = i == 1;
-			if (!rigged)
-			{
-				shader = &gDeferredAlphaProgram;
-				shader->mName = "Deferred Alpha Shader";
-				shader->mRiggedVariant = &gDeferredSkinnedAlphaProgram;
-			}
-			else
-			{
-				shader = &gDeferredSkinnedAlphaProgram;
-				shader->mName = "Skinned Deferred Alpha Shader";
-				shader->mFeatures.hasObjectSkinning = true;
-			}
-
-			shader->mFeatures.calculatesLighting = false;
-			shader->mFeatures.hasLighting = false;
-			shader->mFeatures.isAlphaLighting = true;
-			shader->mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
-			shader->mFeatures.hasSrgb = true;
-			shader->mFeatures.encodesNormal = true;
-			shader->mFeatures.calculatesAtmospherics = true;
-			shader->mFeatures.hasAtmospherics = true;
-			shader->mFeatures.hasGamma = true;
-			shader->mFeatures.hasTransport = true;
-			shader->mFeatures.hasShadows = use_sun_shadow;
-
-			if (mShaderLevel[SHADER_DEFERRED] < 1)
-			{
-				shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
-			}
-			else
-			{ //shave off some texture units for shadow maps
-				shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1);
-			}
-
-			shader->mShaderFiles.clear();
-			shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
-			shader->mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
-
-			shader->clearPermutations();
-			shader->addPermutation("USE_VERTEX_COLOR", "1");
-			shader->addPermutation("HAS_ALPHA_MASK", "1");
-			shader->addPermutation("USE_INDEXED_TEX", "1");
-			if (use_sun_shadow)
-			{
-				shader->addPermutation("HAS_SHADOW", "1");
-			}
-
-			if (ambient_kill)
-			{
-				shader->addPermutation("AMBIENT_KILL", "1");
-			}
-
-			if (sunlight_kill)
-			{
-				shader->addPermutation("SUNLIGHT_KILL", "1");
-			}
-
-			if (local_light_kill)
-			{
-				shader->addPermutation("LOCAL_LIGHT_KILL", "1");
-			}
-
-			if (rigged)
-			{
-				shader->addPermutation("HAS_SKIN", "1");
-			}
-
-			shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-			success = shader->createShader(NULL, NULL);
-			llassert(success);
-
-			// Hack
-			shader->mFeatures.calculatesLighting = true;
-			shader->mFeatures.hasLighting = true;
-		}
-	}
-
-	if (success)
-	{
-		LLGLSLShader* shaders[] = {
-			&gDeferredAlphaImpostorProgram,
-			&gDeferredSkinnedAlphaImpostorProgram
-		};
-
-		for (int i = 0; i < 2 && success; ++i)
-		{
-			bool rigged = i == 1;
-			LLGLSLShader* shader = shaders[i];
-
-			shader->mName = rigged ? "Skinned Deferred Alpha Impostor Shader" : "Deferred Alpha Impostor Shader";
-
-			// Begin Hack
-			shader->mFeatures.calculatesLighting = false;
-			shader->mFeatures.hasLighting = false;
-
-			shader->mFeatures.hasSrgb = true;
-			shader->mFeatures.isAlphaLighting = true;
-			shader->mFeatures.encodesNormal = true;
-			shader->mFeatures.hasShadows = use_sun_shadow;
-
-			if (mShaderLevel[SHADER_DEFERRED] < 1)
-			{
-				shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
-			}
-			else
-			{ //shave off some texture units for shadow maps
-				shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1);
-			}
-
-			shader->mShaderFiles.clear();
-			shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
-			shader->mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
-
-			shader->clearPermutations();
-			shader->addPermutation("USE_INDEXED_TEX", "1");
-			shader->addPermutation("FOR_IMPOSTOR", "1");
-			shader->addPermutation("HAS_ALPHA_MASK", "1");
-			shader->addPermutation("USE_VERTEX_COLOR", "1");
-			if (rigged)
-			{
-				shader->mFeatures.hasObjectSkinning = true;
-				shader->addPermutation("HAS_SKIN", "1");
-			}
-
-			if (use_sun_shadow)
-			{
-				shader->addPermutation("HAS_SHADOW", "1");
-			}
-
-			shader->mRiggedVariant = &gDeferredSkinnedAlphaImpostorProgram;
-			shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-			if (!rigged)
-			{
-				shader->mRiggedVariant = shaders[1];
-			}
-			success = shader->createShader(NULL, NULL);
-			llassert(success);
-
-			// End Hack
-			shader->mFeatures.calculatesLighting = true;
-			shader->mFeatures.hasLighting = true;
-		}
-	}
-
-	if (success)
-	{
-		LLGLSLShader* shader[] = {
-			&gDeferredAlphaWaterProgram,
-			&gDeferredSkinnedAlphaWaterProgram
-		};
-
-		gDeferredAlphaWaterProgram.mRiggedVariant = &gDeferredSkinnedAlphaWaterProgram;
-
-		gDeferredAlphaWaterProgram.mName = "Deferred Alpha Underwater Shader";
-		gDeferredSkinnedAlphaWaterProgram.mName = "Deferred Skinned Alpha Underwater Shader";
-
-		for (int i = 0; i < 2 && success; ++i)
-		{
-			shader[i]->mFeatures.calculatesLighting = false;
-			shader[i]->mFeatures.hasLighting = false;
-			shader[i]->mFeatures.isAlphaLighting = true;
-			shader[i]->mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
-			shader[i]->mFeatures.hasWaterFog = true;
-			shader[i]->mFeatures.hasSrgb = true;
-			shader[i]->mFeatures.encodesNormal = true;
-			shader[i]->mFeatures.calculatesAtmospherics = true;
-			shader[i]->mFeatures.hasAtmospherics = true;
-			shader[i]->mFeatures.hasGamma = true;
-			shader[i]->mFeatures.hasTransport = true;
-			shader[i]->mFeatures.hasShadows = use_sun_shadow;
-
-			if (mShaderLevel[SHADER_DEFERRED] < 1)
-			{
-				shader[i]->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
-			}
-			else
-			{ //shave off some texture units for shadow maps
-				shader[i]->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1);
-			}
-			shader[i]->mShaderGroup = LLGLSLShader::SG_WATER;
-			shader[i]->mShaderFiles.clear();
-			shader[i]->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
-			shader[i]->mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
-
-			shader[i]->clearPermutations();
-			shader[i]->addPermutation("USE_INDEXED_TEX", "1");
-			shader[i]->addPermutation("WATER_FOG", "1");
-			shader[i]->addPermutation("USE_VERTEX_COLOR", "1");
-			shader[i]->addPermutation("HAS_ALPHA_MASK", "1");
-			if (use_sun_shadow)
-			{
-				shader[i]->addPermutation("HAS_SHADOW", "1");
-			}
-
-			if (ambient_kill)
-			{
-				shader[i]->addPermutation("AMBIENT_KILL", "1");
-			}
-
-			if (sunlight_kill)
-			{
-				shader[i]->addPermutation("SUNLIGHT_KILL", "1");
-			}
-
-			if (local_light_kill)
-			{
-				shader[i]->addPermutation("LOCAL_LIGHT_KILL", "1");
-			}
-
-			if (i == 1)
-			{ // rigged variant
-				shader[i]->mFeatures.hasObjectSkinning = true;
-				shader[i]->addPermutation("HAS_SKIN", "1");
-			}
-			else
-			{
-				shader[i]->mRiggedVariant = shader[1];
-			}
-			shader[i]->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-			success = shader[i]->createShader(NULL, NULL);
-			llassert(success);
-
-			// Hack
-			shader[i]->mFeatures.calculatesLighting = true;
-			shader[i]->mFeatures.hasLighting = true;
-		}
-	}
-
-	if (success)
-	{
-		gDeferredAvatarAlphaProgram.mName = "Avatar Alpha Shader";
-		gDeferredAvatarAlphaProgram.mFeatures.hasSkinning = true;
-		gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = false;
-		gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false;
-		gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
-		gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasSrgb = true;
-		gDeferredAvatarAlphaProgram.mFeatures.encodesNormal = true;
-		gDeferredAvatarAlphaProgram.mFeatures.calculatesAtmospherics = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasTransport = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true;
-		gDeferredAvatarAlphaProgram.mFeatures.isDeferred = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasShadows = true;
-
-		gDeferredAvatarAlphaProgram.mShaderFiles.clear();
-		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
-
-		gDeferredAvatarAlphaProgram.clearPermutations();
-		gDeferredAvatarAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1");
-		gDeferredAvatarAlphaProgram.addPermutation("IS_AVATAR_SKIN", "1");
-		if (use_sun_shadow)
-		{
-			gDeferredAvatarAlphaProgram.addPermutation("HAS_SHADOW", "1");
-		}
-
-		if (ambient_kill)
-		{
-			gDeferredAvatarAlphaProgram.addPermutation("AMBIENT_KILL", "1");
-		}
-
-		if (sunlight_kill)
-		{
-			gDeferredAvatarAlphaProgram.addPermutation("SUNLIGHT_KILL", "1");
-		}
-
-		if (local_light_kill)
-		{
-			gDeferredAvatarAlphaProgram.addPermutation("LOCAL_LIGHT_KILL", "1");
-		}
-		gDeferredAvatarAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
-
-		success = gDeferredAvatarAlphaProgram.createShader(NULL, NULL);
-		llassert(success);
-
-		gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true;
-		gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
-	}
-
-	return success;
-}
-
-//BD
-BOOL LLViewerShaderMgr::resetDeferredShaders()
-{
-	bool canRenderDeferred = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
-	S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail");
-	bool useRenderDeferred = canRenderDeferred && gSavedSettings.getBOOL("RenderDeferred");
-
-	S32 deferred_class = 0;
-
-	if (useRenderDeferred)
-	{
-		//shadows
-		switch (shadow_detail)
-		{
-		case 1:
-			deferred_class = 2; // PCF shadows
-			break;
-
-		case 2:
-			deferred_class = 2; // PCF shadows
-			break;
-
-		case 0:
-		default:
-			deferred_class = 1; // no shadows
-			break;
-		}
-	}
-
-	// Load deferred shaders
-	mShaderLevel[SHADER_DEFERRED] = deferred_class;
-	return deferred_class;
-}
 
 std::string LLViewerShaderMgr::getShaderDirPrefix(void)
 {
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index e7918d14fbb621310697a193bccece1644220ea5..b0b9719d76fcc4cdb3c966c4f7025c4a35dd9ffe 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -61,25 +61,6 @@ class LLViewerShaderMgr: public LLShaderMgr
 	BOOL loadShadersWater();
 	BOOL loadShadersInterface();
 
-//	//BD - Fast Shader Toggles
-	BOOL resetDeferredShaders();
-	BOOL loadShadersMaterials(bool success);
-	BOOL loadShadersDOF(bool success);
-	BOOL loadShadersSpotlights(bool success);
-	BOOL loadShadersSSAO(bool success);
-	BOOL loadShadersShadows(bool success);
-	BOOL loadShadersBlurLight(bool success);
-
-//	//BD - Screen Space Reflections
-	BOOL loadShadersSSR(bool success);
-
-//	//BD - Exodus Post Process
-	void unloadExodusPostShaders();
-	BOOL loadExodusPostShaders();
-
-	//BD - Volumetric Lighting
-	BOOL loadShadersGodrays(bool success);
-
 	std::vector<S32> mShaderLevel;
 	S32	mMaxAvatarShaderLevel;
 
@@ -277,7 +258,6 @@ extern LLGLSLShader			gDeferredFullbrightAlphaMaskWaterProgram;
 extern LLGLSLShader			gDeferredEmissiveProgram;
 extern LLGLSLShader			gDeferredAvatarEyesProgram;
 extern LLGLSLShader			gDeferredAvatarAlphaProgram;
-extern LLGLSLShader			gDeferredAvatarAlphaWaterProgram;
 extern LLGLSLShader			gDeferredWLSkyProgram;
 extern LLGLSLShader			gDeferredWLCloudProgram;
 extern LLGLSLShader			gDeferredWLSunProgram;
@@ -299,27 +279,4 @@ extern LLGLSLShader         gDeferredPBROpaqueProgram;
 extern LLGLSLShader         gDeferredPBRAlphaProgram;
 extern LLGLSLShader         gDeferredPBRAlphaWaterProgram;
 extern LLGLSLShader         gHUDPBRAlphaProgram;
-
-//BD - Exodus Post Process
-extern LLGLSLShader         gColorGradePost;
-extern LLGLSLShader         gLinearToneMapping;
-extern LLGLSLShader         gReinhardToneMapping;
-extern LLGLSLShader         gFilmicToneMapping;
-extern LLGLSLShader         gVignettePost;
-extern LLGLSLShader         gColorGradePostLegacy;
-extern LLGLSLShader         gFilmicToneMappingAdv;
-
-extern LLGLSLShader         gLensFlare;
-extern LLGLSLShader         gSpecialPost;
-
-//BD - Volumetric Lighting
-extern LLGLSLShader			gVolumetricLightProgram;
-
-//BD - Motion Blur
-extern LLGLSLShader			gVelocityProgram;
-extern LLGLSLShader			gVelocityAlphaProgram;
-extern LLGLSLShader			gAvatarVelocityProgram;
-extern LLGLSLShader			gSkinnedVelocityProgram;
-extern LLGLSLShader			gSkinnedVelocityAlphaProgram;
-extern LLGLSLShader			gMotionBlurProgram;
 #endif
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index f3b449618356aa47d8fe3e70049f506add749f15..22a889ed6336a906d3c20d7f6298657724746cee 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -401,7 +401,7 @@ void update_statistics()
 
 	record(LLStatViewer::TRIANGLES_DRAWN_PER_FRAME, last_frame_recording.getSum(LLStatViewer::TRIANGLES_DRAWN));
 
-	sample(LLStatViewer::ENABLE_VBO,      (F64)LLVertexBuffer::sEnableVBOs);
+	sample(LLStatViewer::ENABLE_VBO,	  (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
 	sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	sample(LLStatViewer::DRAW_DISTANCE,   (F64)LLPipeline::RenderFarClip);
 
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 109e70300b507690181ef89e42ce4ae0f9441179..84a431cd878f089bfe991e6c2b422b1bca173ac6 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -80,6 +80,8 @@ LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultIrradiancePBRp;
+//BD - Optimizations
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sPixieSmallImagep = NULL;
 // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0)
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultDiffuseImagep = NULL;
 // [/SL:KB]
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 13b6599a79d20e17e3bb06161ce90ec6f463d161..4b3a6bb7037e2ddb27232181b8f71f238e769529 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -533,6 +533,9 @@ class LLViewerFetchedTexture : public LLViewerTexture
     static LLPointer<LLViewerFetchedTexture> sSmokeImagep; // Old "Default" translucent texture
     static LLViewerFetchedTexture* getSmokeImage();
 
+	//BD - Optimizations
+	static LLPointer<LLViewerFetchedTexture> sPixieSmallImagep; // Small pixmap for default particle tex
+
 // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0)
 	static LLPointer<LLViewerFetchedTexture> sDefaultDiffuseImagep;
 // [/SL:KB]
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index a4a1bebb2c08f8e9ce6311047642482cfe62646f..9f463dee0fa25d260cc2dfb3ceef076ea81e77fc 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -124,6 +124,8 @@ void LLViewerTextureList::doPreloadImages()
 	// Set the default flat normal map
 	LLViewerFetchedTexture::sFlatNormalImagep = LLViewerTextureManager::getFetchedTextureFromFile("flatnormal.tga", FTT_LOCAL_FILE, MIPMAP_NO, LLViewerFetchedTexture::BOOST_BUMP);
 
+	LLViewerFetchedTexture::sPixieSmallImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI);
+
 	// PBR: irradiance
 	LLViewerFetchedTexture::sDefaultIrradiancePBRp = LLViewerTextureManager::getFetchedTextureFromFile("default_irradiance.png", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI);
 
@@ -1338,7 +1340,7 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
 
 const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM(12);
 const S32Megabytes MIN_MEM_FOR_NON_TEXTURE(512);
-void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem)
+/*void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
 	// Initialize the image pipeline VRAM settings
@@ -1398,7 +1400,7 @@ void LLViewerTextureList::idleUpdateMaxResidentTexMem()
 
 	mMaxResidentTexMemInMegaBytes = new_cur_mem;
 	mMaxTotalTextureMemInMegaBytes = new_sys_mem;
-}
+}*/
 
 ///////////////////////////////////////////////////////////////////////////////
 
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 818209f58e59d71180a7238aac3eab0f4f767308..681208a7e4b29fd5f45335d7ebdb8d96dd317957 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -126,8 +126,8 @@ class LLViewerTextureList
 	void handleIRCallback(void **data, const S32 number);
 
 	//BD - Automatic Memory Management
-	void updateMaxResidentTexMem(S32Megabytes mem);
-	void idleUpdateMaxResidentTexMem();
+	//void updateMaxResidentTexMem(S32Megabytes mem);
+	//void idleUpdateMaxResidentTexMem();
 
 	S32 getNumImages()					{ return mImageList.size(); }
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 92c2b662b7422ae39a612c6201653d3d3451771b..98299086e22ce8af164ddb65157e8c3f4f4efe07 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1261,7 +1261,7 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window,  LLCoordGL pos, MASK m
 	//     case we didn't move outside the right-click slope threshold.
 	if(gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
 	{
-		return handleAnyMouseClick(window,pos,mask,CLICK_RIGHT,FALSE);
+		return gViewerInput.handleMouse(window,pos,mask,CLICK_RIGHT,FALSE);
 	}
 	else
 	{
@@ -5125,10 +5125,10 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 			//     Hence why we pulled the view rect update out of this section and made it always apply.
 			if (type == LLSnapshotModel::SNAPSHOT_TYPE_COLOR)
 			{
-				if (scratch_space.allocate(image_width, image_height, GL_RGBA, true, true))
+				if (scratch_space.allocate(image_width, image_height, GL_RGBA, true))
 				{
-					original_width = gPipeline.mDeferredScreen.getWidth();
-					original_height = gPipeline.mDeferredScreen.getHeight();
+					original_width = gPipeline.mRT->deferredScreen.getWidth();
+					original_height = gPipeline.mRT->deferredScreen.getHeight();
 
 					if (gPipeline.allocateScreenBuffer(image_width, image_height))
 					{
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 2a9de14c614f13c983186f2efd3df329c892ec68..02f1e2575bb266179334dacea97ffefe80ee855c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -11021,18 +11021,20 @@ void LLVOAvatar::updateVisualComplexity()
 // Account for the complexity of a single top-level object associated
 // with an avatar. This will be either an attached object or an animated
 // object.
-void LLVOAvatar::accountRenderOriginalComplexityForObject(
-	const LLViewerObject *attached_object,
-	/*const F32 max_attachment_complexity,*/
+void LLVOAvatar::accountRenderComplexityForObject(
+	LLViewerObject* attached_object,
+	const F32 max_attachment_complexity,
 	LLVOVolume::texture_cost_t& textures,
 	U32& cost,
-	hud_complexity_list_t& hud_complexity_list)
+	hud_complexity_list_t& hud_complexity_list,
+	object_complexity_list_t& object_complexity_list)
 {
+	LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
 	if (attached_object && !attached_object->isHUDAttachment())
 	{
-		//mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount();
-		//mAttachmentEstTriangleCount += attached_object->recursiveGetEstTrianglesMax();
-		//mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
+		mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount();
+		mAttachmentEstTriangleCount += attached_object->recursiveGetEstTrianglesMax();
+		mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
 
 		textures.clear();
 		const LLDrawable* drawable = attached_object->mDrawable;
@@ -11047,11 +11049,11 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 				F32 attachment_children_cost = 0;
 				const F32 animated_object_attachment_surcharge = 1000;
 
-				if (attached_object->isAnimatedObject())
+				if (volume->isAnimatedObjectFast())
 				{
 					attachment_volume_cost += animated_object_attachment_surcharge;
 				}
-				attachment_volume_cost += volume->getOriginalRenderCost(textures);
+				attachment_volume_cost += volume->getRenderCost(textures);
 
 				const_child_list_t children = volume->getChildren();
 				for (const_child_list_t::const_iterator child_iter = children.begin();
@@ -11059,10 +11061,10 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 					++child_iter)
 				{
 					LLViewerObject* child_obj = *child_iter;
-					LLVOVolume *child = dynamic_cast<LLVOVolume*>(child_obj);
+					LLVOVolume* child = dynamic_cast<LLVOVolume*>(child_obj);
 					if (child)
 					{
-						attachment_children_cost += child->getOriginalRenderCost(textures);
+						attachment_children_cost += child->getRenderCost(textures);
 					}
 				}
 
@@ -11071,18 +11073,28 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 					++volume_texture)
 				{
 					// add the cost of each individual texture in the linkset
-					attachment_texture_cost += volume_texture->second;
+					attachment_texture_cost += LLVOVolume::getTextureCost(*volume_texture);
 				}
 				attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost;
-				/*LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID()
+				LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID()
 					<< " total: " << attachment_total_cost
 					<< ", volume: " << attachment_volume_cost
-					<< ", textures: " << attachment_texture_cost
+					<< ", " << textures.size()
+					<< " textures: " << attachment_texture_cost
 					<< ", " << volume->numChildren()
 					<< " children: " << attachment_children_cost
-					<< LL_ENDL;*/
+					<< LL_ENDL;
 				// Limit attachment complexity to avoid signed integer flipping of the wearer's ACI
-				cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, MAX_ATTACHMENT_COMPLEXITY);
+				cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, max_attachment_complexity);
+
+				if (isSelf())
+				{
+					LLObjectComplexity object_complexity;
+					object_complexity.objectName = attached_object->getAttachmentItemName();
+					object_complexity.objectId = attached_object->getAttachmentItemID();
+					object_complexity.objectCost = attachment_total_cost;
+					object_complexity_list.push_back(object_complexity);
+				}
 			}
 		}
 	}
@@ -11093,12 +11105,12 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 		&& attached_object->mDrawable)
 	{
 		textures.clear();
-
 		mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
 
 		const LLVOVolume* volume = attached_object->mDrawable->getVOVolume();
 		if (volume)
 		{
+			BOOL is_rigged_mesh = volume->isRiggedMeshFast();
 			LLHUDComplexity hud_object_complexity;
 			hud_object_complexity.objectName = attached_object->getAttachmentItemName();
 			hud_object_complexity.objectId = attached_object->getAttachmentItemID();
@@ -11106,7 +11118,7 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 			gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name);
 			hud_object_complexity.jointName = joint_name;
 			// get cost and individual textures
-			hud_object_complexity.objectsCost += volume->getOriginalRenderCost(textures);
+			hud_object_complexity.objectsCost += volume->getRenderCost(textures);
 			hud_object_complexity.objectsCount++;
 
 			LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
@@ -11117,11 +11129,22 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 				const LLVOVolume* chld_volume = dynamic_cast<LLVOVolume*>(childp);
 				if (chld_volume)
 				{
+					is_rigged_mesh = is_rigged_mesh || chld_volume->isRiggedMeshFast();
 					// get cost and individual textures
-					hud_object_complexity.objectsCost += chld_volume->getOriginalRenderCost(textures);
+					hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures);
 					hud_object_complexity.objectsCount++;
 				}
 			}
+			if (is_rigged_mesh && !attached_object->mRiggedAttachedWarned)
+			{
+				LLSD args;
+				LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID());
+				args["NAME"] = itemp ? itemp->getName() : LLTrans::getString("Unknown");
+				args["POINT"] = LLTrans::getString(getTargetAttachmentPoint(attached_object)->getName());
+				LLNotificationsUtil::add("RiggedMeshAttachedToHUD", args);
+
+				attached_object->mRiggedAttachedWarned = true;
+			}
 
 			hud_object_complexity.texturesCount += textures.size();
 
@@ -11130,11 +11153,11 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 				++volume_texture)
 			{
 				// add the cost of each individual texture (ignores duplicates)
-				hud_object_complexity.texturesCost += volume_texture->second;
-				LLViewerFetchedTexture *tex = LLViewerTextureManager::getFetchedTexture(volume_texture->first);
-				if (tex)
-
+				hud_object_complexity.texturesCost += LLVOVolume::getTextureCost(*volume_texture);
+				const LLViewerTexture* img = *volume_texture;
+				if (img->getType() == LLViewerTexture::FETCHED_TEXTURE)
 				{
+					LLViewerFetchedTexture* tex = (LLViewerFetchedTexture*)img;
 					// Note: Texture memory might be incorect since texture might be still loading.
 					hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory();
 					if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE)
@@ -11148,148 +11171,8 @@ void LLVOAvatar::accountRenderOriginalComplexityForObject(
 	}
 }
 
-//BD - Altered Complexity Calculation
-void LLVOAvatar::accountRenderComplexityForObject(
-    const LLViewerObject *attached_object,
-    LLVOVolume::texture_cost_t& textures,
-    U32& cost,
-    hud_complexity_list_t& hud_complexity_list,
-    object_complexity_list_t& object_complexity_list)
-{
-    LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
-    if (attached_object && !attached_object->isHUDAttachment())
-    {
-        mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount();
-        mAttachmentEstTriangleCount += attached_object->recursiveGetEstTrianglesMax();
-        mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
-
-		mPerfPolyCount += attached_object->recursiveGetTriangleCount();
-
-		textures.clear();
-		const LLDrawable* drawable = attached_object->mDrawable;
-		if (drawable)
-		{
-			const LLVOVolume* volume = drawable->getVOVolume();
-			if (volume)
-			{
-                F32 attachment_total_cost = 0;
-                F32 attachment_volume_cost = 0;
-                F32 attachment_texture_cost = 0;
-                F32 attachment_children_cost = 0;
-				const F32 animated_object_attachment_surcharge = 1000;
-
-				if (attached_object->isAnimatedObject())
-				{
-					attachment_volume_cost += animated_object_attachment_surcharge;
-				}
-				attachment_volume_cost += volume->getRenderCost(textures);
-				mPerfObjectCount++;
-				mPerfLightCount += volume->getIsLight();
-
-				const_child_list_t children = volume->getChildren();
-				for (const_child_list_t::const_iterator child_iter = children.begin();
-						child_iter != children.end();
-						++child_iter)
-				{
-					LLViewerObject* child_obj = *child_iter;
-					LLVOVolume *child = child_obj ? child_obj->asVolume() : nullptr;
-					if (child)
-					{
-						attachment_children_cost += child->getRenderCost(textures);
-						mPerfLightCount += child->getIsLight();
-					}
-				}
-				mPerfObjectCount += children.size();
-
-				mPerfTextureCount += textures.size();
-				for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
-						volume_texture != textures.end();
-						++volume_texture)
-				{
-					// add the cost of each individual texture in the linkset
-					attachment_texture_cost += volume_texture->second;
-
-					//BD - Count the texture impact and memory usage here now that we got all textures collected.
-					/*LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(volume_texture->first);
-					if (texture)
-					{
-						mTextureMemoryUsage += (texture->getTextureMemory() / 1024);
-					}*/
-				}
-                attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost;
-                /*// _LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID()
-                                        << " total: " << attachment_total_cost
-                                        << ", volume: " << attachment_volume_cost
-                                        << ", textures: " << attachment_texture_cost
-                                        << ", " << volume->numChildren()
-                                        << " children: " << attachment_children_cost
-                                        << LL_ENDL;*/
-                // Limit attachment complexity to avoid signed integer flipping of the wearer's ACI
-				cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, MAX_ATTACHMENT_COMPLEXITY);
-			}
-		}
-	}
-    if (isSelf()
-        && attached_object
-        && attached_object->isHUDAttachment()
-        && !attached_object->isTempAttachment()
-        && attached_object->mDrawable)
-    {
-        textures.clear();
-
-		mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
-
-        const LLVOVolume* volume = attached_object->mDrawable->getVOVolume();
-        if (volume)
-        {
-            LLHUDComplexity hud_object_complexity;
-            hud_object_complexity.objectName = attached_object->getAttachmentItemName();
-            hud_object_complexity.objectId = attached_object->getAttachmentItemID();
-            std::string joint_name;
-            gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name);
-            hud_object_complexity.jointName = joint_name;
-            // get cost and individual textures
-            hud_object_complexity.objectsCost += volume->getRenderCost(textures);
-            hud_object_complexity.objectsCount++;
-
-            LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
-            for (LLViewerObject* childp : child_list)
-            {
-                const LLVOVolume* chld_volume = childp ? childp->asVolume() : nullptr;
-                if (chld_volume)
-                {
-                    // get cost and individual textures
-                    hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures);
-                    hud_object_complexity.objectsCount++;
-                }
-            }
-
-            hud_object_complexity.texturesCount += textures.size();
-
-            for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
-                volume_texture != textures.end();
-                ++volume_texture)
-            {
-                // add the cost of each individual texture (ignores duplicates)
-                hud_object_complexity.texturesCost += volume_texture->second;
-                LLViewerFetchedTexture *tex = LLViewerTextureManager::getFetchedTexture(volume_texture->first);
-                if (tex)
-                {
-                    // Note: Texture memory might be incorect since texture might be still loading.
-                    hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory();
-                    if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE)
-                    {
-                        hud_object_complexity.largeTexturesCount++;
-                    }
-                }
-            }
-            hud_complexity_list.push_back(hud_object_complexity);
-        }
-    }
-}
-
-// Calculations for mOriginalVisualComplexity value
-void LLVOAvatar::calculateUpdateOriginalRenderComplexity()
+// Calculations for mVisualComplexity value
+void LLVOAvatar::calculateUpdateRenderComplexity()
 {
 	/*****************************************************************
 	 * This calculation should not be modified by third party viewers,
@@ -11297,259 +11180,9 @@ void LLVOAvatar::calculateUpdateOriginalRenderComplexity()
 	 * everyone. If you have suggested improvements, submit them to
 	 * the official viewer for consideration.
 	 *****************************************************************/
-	static const U32 COMPLEXITY_BODY_PART_COST = 200;
-
-	// Diagnostic list of all textures on our avatar
-	static std::set<LLUUID> all_textures;
-
-	U32 cost = VISUAL_COMPLEXITY_UNKNOWN;
-	LLVOVolume::texture_cost_t textures;
-	hud_complexity_list_t hud_complexity_list;
-
-	for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
-	{
-		const LLAvatarAppearanceDictionary::BakedEntry *baked_dict
-			= LLAvatarAppearance::getDictionary()->getBakedTexture((EBakedTextureIndex)baked_index);
-		ETextureIndex tex_index = baked_dict->mTextureIndex;
-		if ((tex_index != TEX_SKIRT_BAKED) || (isWearingWearableType(LLWearableType::WT_SKIRT)))
-		{
-			if (isTextureVisible(tex_index))
-			{
-				cost += COMPLEXITY_BODY_PART_COST;
-			}
-		}
-	}
-	// _LL_DEBUGS("ARCdetail") << "Avatar body parts complexity: " << cost << LL_ENDL;
-
-	// A standalone animated object needs to be accounted for
-	// using its associated volume. Attached animated objects
-	// will be covered by the subsequent loop over attachments.
-	LLControlAvatar *control_av = dynamic_cast<LLControlAvatar*>(this);
-	if (control_av)
-	{
-		LLVOVolume *volp = control_av->mRootVolp;
-		if (volp && !volp->isAttachment())
-		{
-			accountRenderOriginalComplexityForObject(volp, /*max_attachment_complexity,*/
-				textures, cost, hud_complexity_list);
-		}
-	}
-
-	// Account for complexity of all attachments.
-	for (attachment_map_t::const_iterator attachment_point = mAttachmentPoints.begin();
-		attachment_point != mAttachmentPoints.end();
-		++attachment_point)
-	{
-		LLViewerJointAttachment* attachment = attachment_point->second;
-		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-			attachment_iter != attachment->mAttachedObjects.end();
-			++attachment_iter)
-		{
-			const LLViewerObject* attached_object = attachment_iter->get();
-			accountRenderOriginalComplexityForObject(attached_object, /*max_attachment_complexity,*/
-				textures, cost, hud_complexity_list);
-		}
-	}
-
-	// Diagnostic output to identify all avatar-related textures.
-	// Does not affect rendering cost calculation.
-	// Could be wrapped in a debug option if output becomes problematic.
-	if (isSelf())
+	if (mVisualComplexityStale)
 	{
-		// print any attachment textures we didn't already know about.
-		for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it)
-		{
-			LLUUID image_id = it->first;
-			if (!(image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
-				&& (all_textures.find(image_id) == all_textures.end()))
-			{
-				// attachment texture not previously seen.
-				// _LL_DEBUGS("ARCdetail") << "attachment_texture: " << image_id.asString() << LL_ENDL;
-				all_textures.insert(image_id);
-			}
-		}
-
-		// print any avatar textures we didn't already know about
-		for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearance::getDictionary()->getTextures().begin();
-			iter != LLAvatarAppearance::getDictionary()->getTextures().end();
-			++iter)
-		{
-			//const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second;
-			// TODO: MULTI-WEARABLE: handle multiple textures for self
-			const LLViewerTexture* te_image = getImage(iter->first, 0);
-			if (!te_image)
-				continue;
-			LLUUID image_id = te_image->getID();
-			if (image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
-				continue;
-			if (all_textures.find(image_id) == all_textures.end())
-			{
-				// _LL_DEBUGS("ARCdetail") << "local_texture: " << texture_dict->mName << ": " << image_id << LL_ENDL;
-				all_textures.insert(image_id);
-			}
-		}
-	}
-
-	/*if (cost != mOriginalVisualComplexity)
-	{
-		LL_DEBUGS("AvatarRender") << "Avatar " << getID()
-			<< " complexity updated was " << mVisualComplexity << " now " << cost
-			<< " reported " << mReportedVisualComplexity
-			<< LL_ENDL;
-	}
-	else
-	{
-		LL_DEBUGS("AvatarRender") << "Avatar " << getID()
-			<< " complexity updated no change " << mVisualComplexity
-			<< " reported " << mReportedVisualComplexity
-			<< LL_ENDL;
-	}*/
-	mOriginalVisualComplexity = cost;
-
-                attachment_volume_cost += volume->getRenderCost(textures);
-
-                const_child_list_t children = volume->getChildren();
-                for (const_child_list_t::const_iterator child_iter = children.begin();
-                    child_iter != children.end();
-                    ++child_iter)
-                {
-                    LLViewerObject* child_obj = *child_iter;
-                    LLVOVolume* child = dynamic_cast<LLVOVolume*>(child_obj);
-                    if (child)
-                    {
-                        attachment_children_cost += child->getRenderCost(textures);
-                    }
-                }
-
-                for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
-                    volume_texture != textures.end();
-                    ++volume_texture)
-                {
-                    // add the cost of each individual texture in the linkset
-                    attachment_texture_cost += LLVOVolume::getTextureCost(*volume_texture);
-                }
-                attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost;
-                LL_DEBUGS("ARCdetail") << "Attachment costs " << attached_object->getAttachmentItemID()
-                    << " total: " << attachment_total_cost
-                    << ", volume: " << attachment_volume_cost
-                    << ", " << textures.size()
-                    << " textures: " << attachment_texture_cost
-                    << ", " << volume->numChildren()
-                    << " children: " << attachment_children_cost
-                    << LL_ENDL;
-                // Limit attachment complexity to avoid signed integer flipping of the wearer's ACI
-                cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, max_attachment_complexity);
-
-                if (isSelf())
-                {
-                    LLObjectComplexity object_complexity;
-                    object_complexity.objectName = attached_object->getAttachmentItemName();
-                    object_complexity.objectId = attached_object->getAttachmentItemID();
-                    object_complexity.objectCost = attachment_total_cost;
-                    object_complexity_list.push_back(object_complexity);
-                }
-            }
-        }
-    }
-    if (isSelf()
-        && attached_object
-        && attached_object->isHUDAttachment()
-        && !attached_object->isTempAttachment()
-        && attached_object->mDrawable)
-    {
-        textures.clear();
-        mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
-
-        const LLVOVolume* volume = attached_object->mDrawable->getVOVolume();
-        if (volume)
-        {
-            BOOL is_rigged_mesh = volume->isRiggedMeshFast();
-            LLHUDComplexity hud_object_complexity;
-            hud_object_complexity.objectName = attached_object->getAttachmentItemName();
-            hud_object_complexity.objectId = attached_object->getAttachmentItemID();
-            std::string joint_name;
-            gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name);
-            hud_object_complexity.jointName = joint_name;
-            // get cost and individual textures
-            hud_object_complexity.objectsCost += volume->getRenderCost(textures);
-            hud_object_complexity.objectsCount++;
-
-            LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
-            for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
-                iter != child_list.end(); ++iter)
-            {
-                LLViewerObject* childp = *iter;
-                const LLVOVolume* chld_volume = dynamic_cast<LLVOVolume*>(childp);
-                if (chld_volume)
-                {
-                    is_rigged_mesh = is_rigged_mesh || chld_volume->isRiggedMeshFast();
-                    // get cost and individual textures
-                    hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures);
-                    hud_object_complexity.objectsCount++;
-                }
-            }
-            if (is_rigged_mesh && !attached_object->mRiggedAttachedWarned)
-            {
-                LLSD args;
-                LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID());
-                args["NAME"] = itemp ? itemp->getName() : LLTrans::getString("Unknown");
-                args["POINT"] = LLTrans::getString(getTargetAttachmentPoint(attached_object)->getName());
-                LLNotificationsUtil::add("RiggedMeshAttachedToHUD", args);
-
-                attached_object->mRiggedAttachedWarned = true;
-            }
-
-            hud_object_complexity.texturesCount += textures.size();
-
-            for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
-                volume_texture != textures.end();
-                ++volume_texture)
-            {
-                // add the cost of each individual texture (ignores duplicates)
-                hud_object_complexity.texturesCost += LLVOVolume::getTextureCost(*volume_texture);
-                const LLViewerTexture* img = *volume_texture;
-                if (img->getType() == LLViewerTexture::FETCHED_TEXTURE)
-                {
-                    LLViewerFetchedTexture* tex = (LLViewerFetchedTexture*)img;
-                    // Note: Texture memory might be incorect since texture might be still loading.
-                    hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory();
-                    if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE)
-                    {
-                        hud_object_complexity.largeTexturesCount++;
-                    }
-                }
-            }
-            hud_complexity_list.push_back(hud_object_complexity);
-        }
-    }
-}
-
-//BD - Altered Complexity Calculation
-// Calculations for mVisualComplexity value
-void LLVOAvatar::calculateUpdateRenderComplexity()
-{
-    /*****************************************************************
-     * This calculation should not be modified by third party viewers,
-     * since it is used to limit rendering and should be uniform for
-     * everyone. If you have suggested improvements, submit them to
-     * the official viewer for consideration.
-     *****************************************************************/
-	static const U32 COMPLEXITY_BODY_PART_COST = 200;
-	//BD
-	//static LLCachedControl<F32> max_complexity_setting(gSavedSettings,"MaxAttachmentComplexity");
-	//F32 max_attachment_complexity = max_complexity_setting;
-	//max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY);
-
-	// Diagnostic list of all textures on our avatar
-	static std::set<LLUUID> all_textures;
-
-    if (mVisualComplexityStale)
-	{
-		const F64 now = LLFrameTimer::getTotalSeconds();
-		if (now < mVisualComplexityUpdateTime)
-		{
-			return;
-		}
+		LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
 
 		static const U32 COMPLEXITY_BODY_PART_COST = 200;
 		static LLCachedControl<F32> max_complexity_setting(gSavedSettings, "MaxAttachmentComplexity");
@@ -11557,187 +11190,118 @@ void LLVOAvatar::calculateUpdateRenderComplexity()
 		max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY);
 
 		// Diagnostic list of all textures on our avatar
-		static std::set<LLUUID> all_textures;
+		static std::unordered_set<const LLViewerTexture*> all_textures;
 
 		U32 cost = VISUAL_COMPLEXITY_UNKNOWN;
 		LLVOVolume::texture_cost_t textures;
 		hud_complexity_list_t hud_complexity_list;
-        object_complexity_list_t object_complexity_list;
+		object_complexity_list_t object_complexity_list;
 
 		for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
 		{
-		    const LLAvatarAppearanceDictionary::BakedEntry *baked_dict
+			const LLAvatarAppearanceDictionary::BakedEntry* baked_dict
 				= LLAvatarAppearance::getDictionary()->getBakedTexture((EBakedTextureIndex)baked_index);
 			ETextureIndex tex_index = baked_dict->mTextureIndex;
 			if ((tex_index != TEX_SKIRT_BAKED) || (isWearingWearableType(LLWearableType::WT_SKIRT)))
 			{
-                // Same as isTextureVisible(), but doesn't account for isSelf to ensure identical numbers for all avatars
-                if (isIndexLocalTexture(tex_index))
-                {
-                    if (isTextureDefined(tex_index, 0))
-                    {
-                        cost += COMPLEXITY_BODY_PART_COST;
-                    }
-                }
-                else
-                {
-                    // baked textures can use TE images directly
-                    if (isTextureDefined(tex_index)
-                        && (getTEImage(tex_index)->getID() != IMG_INVISIBLE || LLDrawPoolAlpha::sShowDebugAlpha))
-                    {
-                        cost += COMPLEXITY_BODY_PART_COST;
-                    }
-                }
+				// Same as isTextureVisible(), but doesn't account for isSelf to ensure identical numbers for all avatars
+				if (isIndexLocalTexture(tex_index))
+				{
+					if (isTextureDefined(tex_index, 0))
+					{
+						cost += COMPLEXITY_BODY_PART_COST;
+					}
+				}
+				else
+				{
+					// baked textures can use TE images directly
+					if (isTextureDefined(tex_index)
+						&& (getTEImage(tex_index)->getID() != IMG_INVISIBLE || LLDrawPoolAlpha::sShowDebugAlpha))
+					{
+						cost += COMPLEXITY_BODY_PART_COST;
+					}
+				}
 			}
 		}
-        // _LL_DEBUGS("ARCdetail") << "Avatar body parts complexity: " << cost << LL_ENDL;
+		LL_DEBUGS("ARCdetail") << "Avatar body parts complexity: " << cost << LL_ENDL;
 
-        mAttachmentVisibleTriangleCount = 0;
-        mAttachmentEstTriangleCount = 0.f;
-        mAttachmentSurfaceArea = 0.f;
+		mAttachmentVisibleTriangleCount = 0;
+		mAttachmentEstTriangleCount = 0.f;
+		mAttachmentSurfaceArea = 0.f;
 
-		mPerfTextureCount = 0;
-		mPerfLightCount = 0;
-		mPerfPolyCount = 0;
-		mPerfObjectCount = 0;
-		mPerfRank = PERF_UNKNOWN;
-        
-        // A standalone animated object needs to be accounted for
-        // using its associated volume. Attached animated objects
-        // will be covered by the subsequent loop over attachments.
-        if (isControlAvatar())
-        {
-			LLControlAvatar* control_av = static_cast<LLControlAvatar*>(this);
-			LLVOVolume *volp = control_av->mRootVolp;
-            if (volp && !volp->isAttachment())
-            {
-				//BD
-                accountRenderComplexityForObject(volp, /*max_attachment_complexity,*/
-                                                 textures, cost, hud_complexity_list);
-            }
-        }
-
-        // Account for complexity of all attachments.
-		for (attachment_map_t::const_iterator attachment_point = mAttachmentPoints.begin(); 
-			 attachment_point != mAttachmentPoints.end();
-			 ++attachment_point)
+		// A standalone animated object needs to be accounted for
+		// using its associated volume. Attached animated objects
+		// will be covered by the subsequent loop over attachments.
+		LLControlAvatar* control_av = dynamic_cast<LLControlAvatar*>(this);
+		if (control_av)
 		{
-			LLViewerJointAttachment* attachment = attachment_point->second;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
+			LLVOVolume* volp = control_av->mRootVolp;
+			if (volp && !volp->isAttachment())
 			{
-                const LLViewerObject* attached_object = attachment_iter->get();
-				//BD
-                accountRenderComplexityForObject(attached_object, /*max_attachment_complexity,*/
-                                                 textures, cost, hud_complexity_list);
+				accountRenderComplexityForObject(volp, max_attachment_complexity,
+					textures, cost, hud_complexity_list, object_complexity_list);
 			}
 		}
 
-		//BD - Count the texture impact and memory usage here now that we got all textures collected.
-		/*for (auto volume_texture : textures)
+		// Account for complexity of all attachments.
+		for (attachment_map_t::const_iterator attachment_point = mAttachmentPoints.begin();
+			attachment_point != mAttachmentPoints.end();
+			++attachment_point)
 		{
-			LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(volume_texture.first);
-			if (texture)
+			LLViewerJointAttachment* attachment = attachment_point->second;
+			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+				attachment_iter != attachment->mAttachedObjects.end();
+				++attachment_iter)
 			{
-				mTextureMemoryUsage += (texture->getTextureMemory() / 1024);
+				LLViewerObject* attached_object = attachment_iter->get();
+				accountRenderComplexityForObject(attached_object, max_attachment_complexity,
+					textures, cost, hud_complexity_list, object_complexity_list);
 			}
-		}*/
+		}
 
-		// Diagnostic output to identify all avatar-related textures.
-		// Does not affect rendering cost calculation.
-		if (isSelf() && debugLoggingEnabled("ARCdetail"))
+		if (cost != mVisualComplexity)
 		{
-			// print any attachment textures we didn't already know about.
-			for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it)
-			{
-				LLUUID image_id = it->first;
-				if( ! (image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
-				   && (all_textures.find(image_id) == all_textures.end()))
-				{
-					// attachment texture not previously seen.
-					// _LL_DEBUGS("ARCdetail") << "attachment_texture: " << image_id.asString() << LL_ENDL;
-					all_textures.insert(image_id);
-				}
-			}
-
-			// print any avatar textures we didn't already know about
-		    for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearance::getDictionary()->getTextures().begin();
-			 iter != LLAvatarAppearance::getDictionary()->getTextures().end();
-				 ++iter)
-			{
-			    //const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second;
-				// TODO: MULTI-WEARABLE: handle multiple textures for self
-				const LLViewerTexture* te_image = getImage(iter->first,0);
-				if (!te_image)
-					continue;
-				LLUUID image_id = te_image->getID();
-				if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
-					continue;
-				if (all_textures.find(image_id) == all_textures.end())
-				{
-					// _LL_DEBUGS("ARCdetail") << "local_texture: " << texture_dict->mName << ": " << image_id << LL_ENDL;
-					all_textures.insert(image_id);
-				
-			}
+			LL_DEBUGS("AvatarRender") << "Avatar " << getID()
+				<< " complexity updated was " << mVisualComplexity << " now " << cost
+				<< " reported " << mReportedVisualComplexity
+				<< LL_ENDL;
+		}
+		else
+		{
+			LL_DEBUGS("AvatarRender") << "Avatar " << getID()
+				<< " complexity updated no change " << mVisualComplexity
+				<< " reported " << mReportedVisualComplexity
+				<< LL_ENDL;
 		}
-
-        /*if ( cost != mVisualComplexity )
-        {
-            LL_DEBUGS("AvatarRender") << "Avatar "<< getID()
-                                      << " complexity updated was " << mVisualComplexity << " now " << cost
-                                      << " reported " << mReportedVisualComplexity
-                                      << LL_ENDL;
-        }
-        else
-        {
-            LL_DEBUGS("AvatarRender") << "Avatar "<< getID()
-                                      << " complexity updated no change " << mVisualComplexity
-                                      << " reported " << mReportedVisualComplexity
-                                      << LL_ENDL;
-        }*/
 		mVisualComplexity = cost;
 		mVisualComplexityStale = false;
-		static const F64 SECONDS_BETWEEN_COMPLEXITY_RECALC = 1.f;
-		mVisualComplexityUpdateTime = now + SECONDS_BETWEEN_COMPLEXITY_RECALC;
 
-        static LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 20);
+		static LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 20);
 
-        if (isSelf() && show_my_complexity_changes)
-        {
-            // Avatar complexity
-            LLAvatarRenderNotifier::getInstance()->updateNotificationAgent(mVisualComplexity);
-            LLAvatarRenderNotifier::getInstance()->setObjectComplexityList(object_complexity_list);
-            // HUD complexity
-            LLHUDRenderNotifier::getInstance()->updateNotificationHUD(hud_complexity_list);
-        }
-
-		if (cost > 500000)
-			mPerfRank = PERF_VERYPOOR;
-		else if (cost > 250000)
-			mPerfRank = PERF_POOR;
-		else if (cost > 125000)
-			mPerfRank = PERF_MEDIUM;
-		else if (cost > 48000)
-			mPerfRank = PERF_GOOD;
-		else
-			mPerfRank = PERF_EXCELLENT;
+		if (isSelf() && show_my_complexity_changes)
+		{
+			// Avatar complexity
+			LLAvatarRenderNotifier::getInstance()->updateNotificationAgent(mVisualComplexity);
+			LLAvatarRenderNotifier::getInstance()->setObjectComplexityList(object_complexity_list);
+			// HUD complexity
+			LLHUDRenderNotifier::getInstance()->updateNotificationHUD(hud_complexity_list);
+		}
 
-        //schedule an update to ART next frame if needed
-        if (LLPerfStats::tunables.userAutoTuneEnabled && 
-            LLPerfStats::tunables.userFPSTuningStrategy != LLPerfStats::TUNE_SCENE_ONLY &&
-            !isVisuallyMuted())
-        {
-            LLUUID id = getID(); // <== use id to make sure this avatar didn't get deleted between frames
-            LL::WorkQueue::getInstance("mainloop")->post([this, id]()
-                {
-                    if (gObjectList.findObject(id) != nullptr)
-                    {
-                        gPipeline.profileAvatar(this);
-                    }
-                });
-        }
-    }
+		//schedule an update to ART next frame if needed
+		if (LLPerfStats::tunables.userAutoTuneEnabled &&
+			LLPerfStats::tunables.userFPSTuningStrategy != LLPerfStats::TUNE_SCENE_ONLY &&
+			!isVisuallyMuted())
+		{
+			LLUUID id = getID(); // <== use id to make sure this avatar didn't get deleted between frames
+			LL::WorkQueue::getInstance("mainloop")->post([this, id]()
+			{
+				if (gObjectList.findObject(id) != nullptr)
+				{
+					gPipeline.profileAvatar(this);
+				}
+			});
+		}
+	}
 }
 
 void LLVOAvatar::setVisualMuteSettings(VisualMuteSettings set)
@@ -12199,3 +11763,297 @@ F32 LLVOAvatar::getAverageGPURenderTime()
 }
 
 
+//BD - Altered Complexity Calculation
+/*void LLVOAvatar::accountBDRenderComplexityForObject(
+	const LLViewerObject* attached_object,
+	LLVOVolume::texture_cost_t& textures,
+	U32& cost,
+	hud_complexity_list_t& hud_complexity_list,
+	object_complexity_list_t& object_complexity_list)
+{
+	LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
+	if (attached_object && !attached_object->isHUDAttachment())
+	{
+		mAttachmentVisibleTriangleCount += attached_object->recursiveGetTriangleCount();
+		mAttachmentEstTriangleCount += attached_object->recursiveGetEstTrianglesMax();
+		mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
+
+		mPerfPolyCount += attached_object->recursiveGetTriangleCount();
+
+		textures.clear();
+		const LLDrawable* drawable = attached_object->mDrawable;
+		if (drawable)
+		{
+			const LLVOVolume* volume = drawable->getVOVolume();
+			if (volume)
+			{
+				F32 attachment_total_cost = 0;
+				F32 attachment_volume_cost = 0;
+				F32 attachment_texture_cost = 0;
+				F32 attachment_children_cost = 0;
+				const F32 animated_object_attachment_surcharge = 1000;
+
+				if (attached_object->isAnimatedObject())
+				{
+					attachment_volume_cost += animated_object_attachment_surcharge;
+				}
+				attachment_volume_cost += volume->getRenderCost(textures);
+				mPerfObjectCount++;
+				mPerfLightCount += volume->getIsLight();
+
+				const_child_list_t children = volume->getChildren();
+				for (const_child_list_t::const_iterator child_iter = children.begin();
+					child_iter != children.end();
+					++child_iter)
+				{
+					LLViewerObject* child_obj = *child_iter;
+					LLVOVolume* child = child_obj ? child_obj->asVolume() : nullptr;
+					if (child)
+					{
+						attachment_children_cost += child->getRenderCost(textures);
+						mPerfLightCount += child->getIsLight();
+					}
+				}
+				mPerfObjectCount += children.size();
+
+				mPerfTextureCount += textures.size();
+				for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
+					volume_texture != textures.end();
+					++volume_texture)
+				{
+					// add the cost of each individual texture in the linkset
+					attachment_texture_cost += volume_texture->second;
+				}
+				attachment_total_cost = attachment_volume_cost + attachment_texture_cost + attachment_children_cost;
+				cost += (U32)llclamp(attachment_total_cost, MIN_ATTACHMENT_COMPLEXITY, MAX_ATTACHMENT_COMPLEXITY);
+			}
+		}
+	}
+	if (isSelf()
+		&& attached_object
+		&& attached_object->isHUDAttachment()
+		&& !attached_object->isTempAttachment()
+		&& attached_object->mDrawable)
+	{
+		textures.clear();
+
+		mAttachmentSurfaceArea += attached_object->recursiveGetScaledSurfaceArea();
+
+		const LLVOVolume* volume = attached_object->mDrawable->getVOVolume();
+		if (volume)
+		{
+			LLHUDComplexity hud_object_complexity;
+			hud_object_complexity.objectName = attached_object->getAttachmentItemName();
+			hud_object_complexity.objectId = attached_object->getAttachmentItemID();
+			std::string joint_name;
+			gAgentAvatarp->getAttachedPointName(attached_object->getAttachmentItemID(), joint_name);
+			hud_object_complexity.jointName = joint_name;
+			// get cost and individual textures
+			hud_object_complexity.objectsCost += volume->getRenderCost(textures);
+			hud_object_complexity.objectsCount++;
+
+			LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
+			for (LLViewerObject* childp : child_list)
+			{
+				const LLVOVolume* chld_volume = childp ? childp->asVolume() : nullptr;
+				if (chld_volume)
+				{
+					// get cost and individual textures
+					hud_object_complexity.objectsCost += chld_volume->getRenderCost(textures);
+					hud_object_complexity.objectsCount++;
+				}
+			}
+
+			hud_object_complexity.texturesCount += textures.size();
+
+			for (LLVOVolume::texture_cost_t::iterator volume_texture = textures.begin();
+				volume_texture != textures.end();
+				++volume_texture)
+			{
+				// add the cost of each individual texture (ignores duplicates)
+				hud_object_complexity.texturesCost += volume_texture->second;
+				LLViewerFetchedTexture* tex = LLViewerTextureManager::getFetchedTexture(volume_texture->first);
+				if (tex)
+				{
+					// Note: Texture memory might be incorect since texture might be still loading.
+					hud_object_complexity.texturesMemoryTotal += tex->getTextureMemory();
+					if (tex->getOriginalHeight() * tex->getOriginalWidth() >= HUD_OVERSIZED_TEXTURE_DATA_SIZE)
+					{
+						hud_object_complexity.largeTexturesCount++;
+					}
+				}
+			}
+			hud_complexity_list.push_back(hud_object_complexity);
+		}
+	}
+}
+
+//BD - Altered Complexity Calculation
+// Calculations for mVisualComplexity value
+void LLVOAvatar::calculateBDUpdateRenderComplexity()
+{
+	static const U32 COMPLEXITY_BODY_PART_COST = 200;
+
+	// Diagnostic list of all textures on our avatar
+	static std::set<LLUUID> all_textures;
+
+	if (mVisualComplexityStale)
+	{
+		const F64 now = LLFrameTimer::getTotalSeconds();
+		if (now < mVisualComplexityUpdateTime)
+		{
+			return;
+		}
+
+		static const U32 COMPLEXITY_BODY_PART_COST = 200;
+		static LLCachedControl<F32> max_complexity_setting(gSavedSettings, "MaxAttachmentComplexity");
+		F32 max_attachment_complexity = max_complexity_setting;
+		max_attachment_complexity = llmax(max_attachment_complexity, DEFAULT_MAX_ATTACHMENT_COMPLEXITY);
+
+		// Diagnostic list of all textures on our avatar
+		static std::set<LLUUID> all_textures;
+
+		U32 cost = VISUAL_COMPLEXITY_UNKNOWN;
+		LLVOVolume::texture_cost_t textures;
+		hud_complexity_list_t hud_complexity_list;
+		object_complexity_list_t object_complexity_list;
+
+		for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
+		{
+			const LLAvatarAppearanceDictionary::BakedEntry* baked_dict
+				= LLAvatarAppearance::getDictionary()->getBakedTexture((EBakedTextureIndex)baked_index);
+			ETextureIndex tex_index = baked_dict->mTextureIndex;
+			if ((tex_index != TEX_SKIRT_BAKED) || (isWearingWearableType(LLWearableType::WT_SKIRT)))
+			{
+				// Same as isTextureVisible(), but doesn't account for isSelf to ensure identical numbers for all avatars
+				if (isIndexLocalTexture(tex_index))
+				{
+					if (isTextureDefined(tex_index, 0))
+					{
+						cost += COMPLEXITY_BODY_PART_COST;
+					}
+				}
+				else
+				{
+					// baked textures can use TE images directly
+					if (isTextureDefined(tex_index)
+						&& (getTEImage(tex_index)->getID() != IMG_INVISIBLE || LLDrawPoolAlpha::sShowDebugAlpha))
+					{
+						cost += COMPLEXITY_BODY_PART_COST;
+					}
+				}
+			}
+		}
+		// _LL_DEBUGS("ARCdetail") << "Avatar body parts complexity: " << cost << LL_ENDL;
+
+		mAttachmentVisibleTriangleCount = 0;
+		mAttachmentEstTriangleCount = 0.f;
+		mAttachmentSurfaceArea = 0.f;
+
+		mPerfTextureCount = 0;
+		mPerfLightCount = 0;
+		mPerfPolyCount = 0;
+		mPerfObjectCount = 0;
+		mPerfRank = PERF_UNKNOWN;
+
+		// A standalone animated object needs to be accounted for
+		// using its associated volume. Attached animated objects
+		// will be covered by the subsequent loop over attachments.
+		if (isControlAvatar())
+		{
+			LLControlAvatar* control_av = static_cast<LLControlAvatar*>(this);
+			LLVOVolume* volp = control_av->mRootVolp;
+			if (volp && !volp->isAttachment())
+			{
+				//BD
+				accountRenderComplexityForObject(volp, textures, cost, hud_complexity_list);
+			}
+		}
+
+		// Account for complexity of all attachments.
+		for (attachment_map_t::const_iterator attachment_point = mAttachmentPoints.begin();
+			attachment_point != mAttachmentPoints.end();
+			++attachment_point)
+		{
+			LLViewerJointAttachment* attachment = attachment_point->second;
+			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+				attachment_iter != attachment->mAttachedObjects.end();
+				++attachment_iter)
+			{
+				const LLViewerObject* attached_object = attachment_iter->get();
+				//BD
+				accountRenderComplexityForObject(attached_object, textures, cost, hud_complexity_list);
+			}
+		}
+
+		// Diagnostic output to identify all avatar-related textures.
+		// Does not affect rendering cost calculation.
+		if (isSelf() && debugLoggingEnabled("ARCdetail"))
+		{
+			// print any attachment textures we didn't already know about.
+			for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it)
+			{
+				LLUUID image_id = it->first;
+				if (!(image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
+					&& (all_textures.find(image_id) == all_textures.end()))
+				{
+					// attachment texture not previously seen.
+					// _LL_DEBUGS("ARCdetail") << "attachment_texture: " << image_id.asString() << LL_ENDL;
+					all_textures.insert(image_id);
+				}
+			}
+
+			// print any avatar textures we didn't already know about
+			for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearance::getDictionary()->getTextures().begin();
+				iter != LLAvatarAppearance::getDictionary()->getTextures().end();
+				++iter)
+			{
+				//const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second;
+				// TODO: MULTI-WEARABLE: handle multiple textures for self
+				const LLViewerTexture* te_image = getImage(iter->first, 0);
+				if (!te_image)
+					continue;
+				LLUUID image_id = te_image->getID();
+				if (image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
+					continue;
+				if (all_textures.find(image_id) == all_textures.end())
+				{
+					all_textures.insert(image_id);
+
+				}
+			}
+
+			mVisualComplexity = cost;
+			mVisualComplexityStale = false;
+			static const F64 SECONDS_BETWEEN_COMPLEXITY_RECALC = 1.f;
+			mVisualComplexityUpdateTime = now + SECONDS_BETWEEN_COMPLEXITY_RECALC;
+
+			static LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 20);
+
+			if (cost > 500000)
+				mPerfRank = PERF_VERYPOOR;
+			else if (cost > 250000)
+				mPerfRank = PERF_POOR;
+			else if (cost > 125000)
+				mPerfRank = PERF_MEDIUM;
+			else if (cost > 48000)
+				mPerfRank = PERF_GOOD;
+			else
+				mPerfRank = PERF_EXCELLENT;
+
+			//schedule an update to ART next frame if needed
+			if (LLPerfStats::tunables.userAutoTuneEnabled &&
+				LLPerfStats::tunables.userFPSTuningStrategy != LLPerfStats::TUNE_SCENE_ONLY &&
+				!isVisuallyMuted())
+			{
+				LLUUID id = getID(); // <== use id to make sure this avatar didn't get deleted between frames
+				LL::WorkQueue::getInstance("mainloop")->post([this, id]()
+				{
+					if (gObjectList.findObject(id) != nullptr)
+					{
+						gPipeline.profileAvatar(this);
+					}
+				});
+			}
+		}
+	}*/
\ No newline at end of file
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 7c77683e81fc32597a8a9c5fec76e7dfa8550478..ae9f0a309768e2f864897fa0f18b292c967ecaf0 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -299,19 +299,20 @@ class LLVOAvatar :
 	void			addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font, const bool use_ellipses = false);
 	void 			idleUpdateRenderComplexity();
 	void 			idleUpdateDebugInfo();
-    void 			accountRenderOriginalComplexityForObject(const LLViewerObject *attached_object,
-                                                     /*const F32 max_attachment_complexity,*/
-                                                     LLVOVolume::texture_cost_t& textures,
-                                                     U32& cost,
-                                                     hud_complexity_list_t& hud_complexity_list);
-	void			calculateUpdateOriginalRenderComplexity();
+	void 			accountRenderComplexityForObject(LLViewerObject* attached_object,
+													const F32 max_attachment_complexity,
+													LLVOVolume::texture_cost_t& textures,
+													U32& cost,
+													hud_complexity_list_t& hud_complexity_list,
+													object_complexity_list_t& object_complexity_list);
+	void			calculateUpdateRenderComplexity();
 	//BD - Altered Complexity Calculation
-	void 			accountRenderComplexityForObject(const LLViewerObject *attached_object,
-													/*const F32 max_attachment_complexity,*/
+	/*void 			accountBDRenderComplexityForObject(const LLViewerObject* attached_object,
 													LLVOVolume::texture_cost_t& textures,
 													U32& cost,
 													hud_complexity_list_t& hud_complexity_list);
-	void			calculateUpdateRenderComplexity();
+	void			calculateBDUpdateRenderComplexity();*/
+
 	static const U32 VISUAL_COMPLEXITY_UNKNOWN;
 	void			updateVisualComplexity();
 	
@@ -336,11 +337,12 @@ class LLVOAvatar :
     // return 0.f if this avatar has not been profiled using gPipeline.mProfileAvatar
     F32             getCPURenderTime() { return mCPURenderTime; }
 
-
-	//BD - Altered Complexity Calculation
-	U32				getOriginalVisualComplexity() { return mOriginalVisualComplexity; };		// Numbers calculated here by rendering AV
 	U32				getVisualComplexity() { return mVisualComplexity; };		// Numbers calculated here by rendering AV
+	//BD - Altered Complexity Calculation
+	U32				getBDVisualComplexity() { return mBDVisualComplexity; };		// Numbers calculated here by rendering AV
+
 	F32				getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; };		// estimated surface area of attachments
+
 //	//BD - Performance Indicator
 	U32				getAvatarPerfRank() { return mPerfRank; };							// performance rank of this avatar
 
@@ -595,9 +597,6 @@ class LLVOAvatar :
     // CPU render time in ms
     F32 mCPURenderTime = 0.f;
 
-	//BD - Altered Complexity Calculation
-	mutable U32  mOriginalVisualComplexity;
-
 	// the isTooComplex method uses these mutable values to avoid recalculating too frequently
     // DEPRECATED -- obsolete avatar render cost values
 	mutable U32  mVisualComplexity;
@@ -605,7 +604,8 @@ class LLVOAvatar :
 	mutable F64  mVisualComplexityUpdateTime = 0.f;
 	U32          mReportedVisualComplexity; // from other viewers through the simulator
 
-	//BD
+	//BD - Altered Complexity Calculation
+	mutable U32			mBDVisualComplexity;
 	mutable U32			mTotalTriangleCount;
 	mutable U32			mTotalVerticeCount;
 	//mutable S32Megabytes  mTextureMemoryUsage;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index e84b2ec0b1c7e5c5309ba76d71c3e4bbb60c342c..0810052a98a29417d532bad5122f4114faa6d6ed 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2791,11 +2791,11 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
 	}
 
 	const F32 final_time = mDebugSelfLoadTimer.getElapsedTimeF32();
-	// _LL_DEBUGS("Avatar") << "REZTIME: Myself rez stats:" << LL_ENDL;
-	// _LL_DEBUGS("Avatar") << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << LL_ENDL;
-	// _LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud: " << (S32)mDebugTimeAvatarVisible << LL_ENDL;
-	// _LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud for others: " << (S32)final_time << LL_ENDL;
-	// _LL_DEBUGS("Avatar") << "\t Load time for each texture: " << LL_ENDL;
+	LL_DEBUGS("Avatar") << "REZTIME: Myself rez stats:" << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud: " << (S32)mDebugTimeAvatarVisible << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud for others: " << (S32)final_time << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Load time for each texture: " << LL_ENDL;
 	for (U32 i = 0; i < LLAvatarAppearanceDefines::TEX_NUM_INDICES; ++i)
 	{
 		std::stringstream out;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 65e1cf68eedd03a54e5a36eb1bb38104e868b6b6..d1bf6f080f47ca6e7d5e8506270917ef399e739a 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4045,7 +4045,7 @@ S32 LLVOVolume::getTextureCost(const LLViewerTexture* img)
 // total cost is returned value + 5 * size of the resulting set.
 // Cannot include cost of textures, as they may be re-used in linked
 // children, and cost should only be increased for unique textures  -Nyx
-U32 LLVOVolume::getOriginalRenderCost(texture_cost_t &textures) const
+U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
     /*****************************************************************
@@ -4317,536 +4317,6 @@ U32 LLVOVolume::getOriginalRenderCost(texture_cost_t &textures) const
 	return (U32)shame;
 }
 
-//BD - Altered Complexity Calculation
-// Returns a base cost and adds textures to passed in set.
-// total cost is returned value + 5 * size of the resulting set.
-// Cannot include cost of textures, as they may be re-used in linked
-// children, and cost should only be increased for unique textures  -Nyx
-U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
-{
-	/*****************************************************************
-	 * This calculation should not be modified by third party viewers,
-	 * since it is used to limit rendering and should be uniform for
-	 * everyone. If you have suggested improvements, submit them to
-	 * the official viewer for consideration.
-	 *****************************************************************/
-
-	 // Get access to params we'll need at various points.  
-	 // Skip if this is object doesn't have a volume (e.g. is an avatar).
-	LLVolumeParams volume_params;
-	LLPathParams path_params;
-	LLProfileParams profile_params;
-
-	U32 num_triangles = 0;
-
-	//BD - Experimental new ARC
-	// per-prim costs
-	//BD - Particles need to be punished extremely harsh, they are besides all other features, the single biggest
-	//     performance hog in Second Life. Just having them enabled and a tiny bunch around drops the framerate
-	//     noticeably.
-	static const U32 ARC_PARTICLE_COST = 4; //16
-	//BD - Textures don't directly influence performance impact on a large scale but allocating a lot of textures
-	//     and filling the Viewer memory as well as texture memory grinds at the Viewer's overall performance, the
-	//     lost performance does not fully recover when leaving the area in question, textures overall have a lingering
-	//     performance impact that slowly drives down the Viewer's performance, we should punish them much harder.
-	//     Textures are not free after all and not everyone can have 2+GB texture memory for SL.
-	static const U32 ARC_TEXTURE_COST = 1.25; //5
-	//BD - Lights are an itchy thing. They don't have any impact if used carefully. They do however have an
-	//     increasingly bigger impact above a certain threshold at which they will significantly drop your average
-	//     FPS. We should punish them slightly but not too hard otherwise Avatars with a few lights get overpunished.
-	static const U32 ARC_LIGHT_COST = 128; //512
-	//BD - Projectors have a huge impact, whether or not they cast a shadow or not, multiple of these will make quick
-	//     work of any good framerate.
-	static const U32 ARC_PROJECTOR_COST = 4096; //16384
-	//BD - Media faces have a huge impact on performance, they should never ever be attached and should be used
-	//     carefully. Punish them with extreme measure, besides, by default we can only have 6-8 active at any time
-	//     those alone will significantly draw resources both RAM and FPS.
-	static const U32 ARC_MEDIA_FACE_COST = 25000; //100000 - static cost per media-enabled face 
-
-	// per-prim multipliers
-	//BD - Glow has nearly no impact, the impact is already there due to the omnipresent ambient glow Black Dragon
-	//     uses, putting up hundreds of glowing prims does nothing, it's a global post processing effect.
-	static const F32 ARC_GLOW_MULT = 0.05f;
-	//BD - Bump has nearly no impact, it's biggest impact is texture memory which we really shouldn't be including.
-	static const F32 ARC_BUMP_MULT = 0.05f;
-	//BD - I'm unsure about flexi, on one side its very efficient but if huge amounts of flexi are active at the same
-	//     time they can quickly become extremely slow which is hardly ever the case.
-	static const F32 ARC_FLEXI_MULT = 0.15f;
-	//BD - Shiny has nearly no impact, it's basically a global post process effect.
-	static const F32 ARC_SHINY_MULT = 0.05f;
-	//BD - Invisible prims are not rendered anymore in Black Dragon.
-	//static const F32 ARC_INVISI_COST = 1.0f;
-	//BD - Weighted mesh does have quite some impact and it only gets worse with more triangles to transform.
-	static const F32 ARC_WEIGHTED_MESH = 2.0f; //4.0
-
-	//BD - Animated textures hit quite hard, not as hard as quick alpha state changes.
-	static const F32 ARC_ANIM_TEX_COST = 1.f;
-	//BD - Alpha's are bad.
-	static const F32 ARC_ALPHA_COST = 1.0f;
-	//BD - Alpha's aren't that bad as normal alphas if they are rigged and worn, static ones are evil.
-	//     Besides, as long as they are fully invisible Black Dragon won't render them anyway.
-	static const F32 ARC_RIGGED_ALPHA_COST = 0.25f;
-	//BD - In theory animated mesh are pretty limited and they are rendering wise not different to normal avatars.
-	//     Thus they should not be weighted differently, however, since they are just basic dummy avatars with no
-	//     super extensive information, relations, name tag and so on they deserve a tiny complexity discount.
-	static const F32 ARC_ANIMATED_MESH_COST = -0.05f;
-
-	F32 shame = 0;
-
-	U32 shiny = 0;
-	U32 glow = 0;
-	U32 alpha = 0;
-	U32 animtex = 0;
-	U32 bump = 0;
-	U32 weighted_mesh = 0;
-	U32 animated_mesh = 0;
-	U32 media_faces = 0;
-
-	const LLDrawable* drawablep = mDrawable;
-	U32 num_faces = drawablep->getNumFaces();
-	//BD
-	LLVOVolume* vovolume = drawablep->getVOVolume();
-
-	vovolume->mRenderComplexityTextures = 0;
-
-	if (isMeshFast() && getVolume())
-	{
-		volume_params = getVolume()->getParams();
-		path_params = volume_params.getPathParams();
-		profile_params = volume_params.getProfileParams();
-
-		//BD - Punish high triangle counts.
-		num_triangles = drawablep->getVOVolume()->getHighLODTriangleCount();
-	}
-
-	if (num_triangles <= 0)
-	{
-		num_triangles = 4;
-	}
-
-	if (isSculpted())
-	{
-		if (isMesh())
-		{
-			// base cost is dependent on mesh complexity
-			// note that 3 is the highest LOD as of the time of this coding.
-			S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(), getLOD());
-			if (size > 0)
-			{
-				if (isRiggedMesh())
-				{
-					// weighted attachment - 1 point for every 3 bytes
-					weighted_mesh = 1;
-				}
-			}
-			else
-			{
-				// something went wrong - user should know their content isn't render-free
-				return 0;
-			}
-
-			if (isAnimatedObject())
-			{
-				animated_mesh = 1;
-			}
-		}
-		else
-		{
-			const LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
-			LLUUID sculpt_id = sculpt_params->getSculptTexture();
-			if (textures.find(sculpt_id) == textures.end())
-			{
-				LLViewerFetchedTexture *texture = LLViewerTextureManager::getFetchedTexture(sculpt_id);
-				if (texture)
-				{
-					//BD - Punish sculpt usage compared to normal prims or the much faster mesh.
-					S32 texture_cost = 256 + (S32)(((ARC_TEXTURE_COST * 2) * (texture->getFullHeight() * texture->getFullWidth())) / 1024);
-					textures.insert(texture_cost_t::value_type(sculpt_id, texture_cost));
-					vovolume->mRenderComplexityTextures += texture_cost;
-				}
-			}
-		}
-	}
-
-	for (S32 i = 0; i < num_faces; ++i)
-	{
-		const LLFace* face = drawablep->getFace(i);
-		if (!face) continue;
-		const LLTextureEntry* te = face->getTextureEntry();
-
-		S32 j = 0;
-		while (j < LLRender::NUM_TEXTURE_CHANNELS)
-		{
-			const LLViewerTexture* img = face->getTexture(j);
-			if (img)
-			{
-				if (textures.find(img->getID()) == textures.end())
-				{
-					S32 texture_cost = 256 + (S32)((ARC_TEXTURE_COST * (img->getFullHeight() * img->getFullWidth())) / 1024);
-					textures.insert(texture_cost_t::value_type(img->getID(), texture_cost));
-					vovolume->mRenderComplexityTextures += texture_cost;
-				}
-			}
-			++j;
-		}
-
-		if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
-		{
-			alpha = 1;
-		}
-
-		if (face->hasMedia())
-		{
-			media_faces++;
-		}
-
-		if (te)
-		{
-			if (te->getBumpmap())
-			{
-				// bump is a multiplier, don't add per-face
-				bump = 1;
-			}
-			if (te->getShiny())
-			{
-				// shiny is a multiplier, don't add per-face
-				shiny = 1;
-				//BD
-				vovolume->setHasShiny(true);
-			}
-			if (te->getGlow() > 0.f)
-			{
-				// glow is a multiplier, don't add per-face
-				glow = 1;
-				//BD
-				vovolume->setHasGlow(true);
-			}
-			if (face->mTextureMatrix != NULL)
-			{
-				animtex = 1;
-				//BD
-				vovolume->setIsAnimated(true);
-			}
-		}
-	}
-
-	//BD - shame currently has the "base" cost of 1 point per 5 triangles, min 2.
-	shame = num_triangles / 10; //5
-	shame = shame < 2.f ? 2.f : shame;
-
-	vovolume->setRenderComplexityBase((S32)shame);
-	F32 extra_shame = 0.f;
-	if (animtex)
-	{
-		extra_shame += (shame * ARC_ANIM_TEX_COST);
-	}
-
-	if (glow)
-	{
-		extra_shame += (shame * ARC_GLOW_MULT);
-	}
-
-	if (bump)
-	{
-		extra_shame += (shame * ARC_BUMP_MULT);
-	}
-
-	if (shiny)
-	{
-		extra_shame += (shame * ARC_SHINY_MULT);
-	}
-
-	if (weighted_mesh)
-	{
-		extra_shame += (shame * ARC_WEIGHTED_MESH);
-
-		if (alpha)
-		{
-			extra_shame += (shame * ARC_ALPHA_COST);
-		}
-	}
-	else
-	{
-		if (alpha)
-		{
-			extra_shame += (shame * ARC_RIGGED_ALPHA_COST);
-		}
-	}
-
-	if (animated_mesh)
-	{
-		extra_shame += (shame * ARC_ANIMATED_MESH_COST);
-	}
-
-	// multiply shame by multipliers
-	if (isFlexible())
-	{
-		extra_shame += (shame * ARC_FLEXI_MULT);
-	}
-
-	// Streaming cost for animated objects includes a fixed cost
-	// per linkset. Add a corresponding charge here translated into
-	// triangles, but not weighted by any graphics properties.
-	/*if (isAnimatedObject() && isRootEdit())
-	{
-		shame += (ANIMATED_OBJECT_BASE_COST / 0.06) * 5.0f;
-	}*/
-
-	// add additional costs
-	if (isParticleSource())
-	{
-		const LLPartSysData *part_sys_data = &(mPartSourcep->mPartSysData);
-		const LLPartData *part_data = &(part_sys_data->mPartData);
-		U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil(part_data->mMaxAge / part_sys_data->mBurstRate));
-		//BD
-		F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f;
-		shame += num_particles * part_size * ARC_PARTICLE_COST;
-	}
-
-	shame += extra_shame;
-
-	if (getIsLight())
-	{
-		shame += ARC_LIGHT_COST;
-	}
-
-	if (getHasShadow())
-	{
-		shame += ARC_PROJECTOR_COST;
-	}
-
-	if (media_faces)
-	{
-		shame += (media_faces * ARC_MEDIA_FACE_COST);
-	}
-
-	vovolume->mRenderComplexityTotal = (S32)shame;
-
-	if (shame > mRenderComplexity_current)
-	{
-		mRenderComplexity_current = (S32)shame;
-	}
-
-	return (U32)shame;
-}
-
-void LLVOVolume::getRenderCostValues(U32 &flexible_cost, U32 &particle_cost, U32 &light_cost, U32 &projector_cost,
-	U32 &alpha_cost, U32 &rigged_cost, U32 &animesh_cost, U32 &media_cost, U32 &bump_cost,
-	U32 &shiny_cost, U32 &glow_cost, U32 &animated_cost) const
-{
-	/*****************************************************************
-	* This calculation should not be modified by third party viewers,
-	* since it is used to limit rendering and should be uniform for
-	* everyone. If you have suggested improvements, submit them to
-	* the official viewer for consideration.
-	*****************************************************************/
-
-	// Get access to params we'll need at various points.  
-	// Skip if this is object doesn't have a volume (e.g. is an avatar).
-	BOOL has_volume = (getVolume() != NULL);
-	LLVolumeParams volume_params;
-	LLPathParams path_params;
-	LLProfileParams profile_params;
-
-	U32 num_triangles = 0;
-
-	//BD - Experimental new ARC
-	// per-prim costs
-	//BD - Particles need to be punished extremely harsh, they are besides all other features, the single biggest
-	//     performance hog in Second Life. Just having them enabled and a tiny bunch around drops the framerate
-	//     noticeably.
-	static const U32 ARC_PARTICLE_COST = 8; //16
-	//BD - Lights are an itchy thing. They don't have any impact if used carefully. They do however have an
-	//     increasingly bigger impact above a certain threshold at which they will significantly drop your average
-	//     FPS. We should punish them slightly but not too hard otherwise Avatars with a few lights get overpunished.
-	static const U32 ARC_LIGHT_COST = 256; //512
-	//BD - Projectors have a huge impact, whether or not they cast a shadow or not, multiple of these will make quick
-	//     work of any good framerate.
-	static const U32 ARC_PROJECTOR_COST = 8192; //16384
-	//BD - Media faces have a huge impact on performance, they should never ever be attached and should be used
-	//     carefully. Punish them with extreme measure, besides, by default we can only have 6-8 active at any time
-	//     those alone will significantly draw resources both RAM and FPS.
-	static const U32 ARC_MEDIA_FACE_COST = 50000; //100000 - static cost per media-enabled face 
-
-	// per-prim multipliers
-	//BD - Glow has nearly no impact, the impact is already there due to the omnipresent ambient glow Black Dragon
-	//     uses, putting up hundreds of glowing prims does nothing, it's a global post processing effect.
-	static const F32 ARC_GLOW_MULT = 0.05f;
-	//BD - Bump has nearly no impact, it's biggest impact is texture memory which we really shouldn't be including.
-	static const F32 ARC_BUMP_MULT = 0.05f;
-	//BD - I'm unsure about flexi, on one side its very efficient but if huge amounts of flexi are active at the same
-	//     time they can quickly become extremely slow which is hardly ever the case.
-	static const F32 ARC_FLEXI_MULT = 0.15f;
-	//BD - Shiny has nearly no impact, it's basically a global post process effect.
-	static const F32 ARC_SHINY_MULT = 0.05f;
-	//BD - Invisible prims are not rendered anymore in Black Dragon.
-	//static const F32 ARC_INVISI_COST = 1.0f;
-	//BD - Weighted mesh does have quite some impact and it only gets worse with more triangles to transform.
-	static const F32 ARC_WEIGHTED_MESH = 2.0f; //4.0
-
-	//BD - Animated textures hit quite hard, not as hard as quick alpha state changes.
-	static const F32 ARC_ANIM_TEX_COST = 1.f;
-	//BD - Alpha's are bad.
-	static const F32 ARC_ALPHA_COST = 1.0f;
-	//BD - Alpha's aren't that bad as normal alphas if they are rigged and worn, static ones are evil.
-	//     Besides, as long as they are fully invisible Black Dragon won't render them anyway.
-	static const F32 ARC_RIGGED_ALPHA_COST = 0.25f;
-	//BD - In theory animated mesh are pretty limited and they are rendering wise not different to normal avatars.
-	//     Thus they should not be weighted differently, however, since they are just basic dummy avatars with no
-	//     super extensive information, relations, name tag and so on they deserve a tiny complexity discount.
-	static const F32 ARC_ANIMATED_MESH_COST = -0.05f;
-
-	U32 shiny = 0;
-	U32 glow = 0;
-	U32 alpha = 0;
-	U32 animtex = 0;
-	U32 bump = 0;
-	U32 weighted_mesh = 0;
-	U32 media_faces = 0;
-
-	const LLDrawable* drawablep = mDrawable;
-	U32 num_faces = drawablep->getNumFaces();
-	LLVOVolume* vovolume = drawablep->getVOVolume();
-
-	if (has_volume)
-	{
-		volume_params = getVolume()->getParams();
-		num_triangles = drawablep->getVOVolume()->getHighLODTriangleCount();
-	}
-
-	if (num_triangles == 0)
-	{
-		num_triangles = 4;
-	}
-
-	if (isSculpted())
-	{
-		if (isMesh())
-		{
-			S32 size = gMeshRepo.getMeshSize(volume_params.getSculptID(), getLOD());
-			if (size > 0)
-			{
-				if (mSkinInfo)
-				{
-					weighted_mesh = 1;
-				}
-			}
-		}
-	}
-
-	for (S32 i = 0; i < num_faces; ++i)
-	{
-		const LLFace* face = drawablep->getFace(i);
-		if (!face) continue;
-		const LLTextureEntry* te = face->getTextureEntry();
-
-		if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
-		{
-			alpha = 1;
-		}
-
-		if (face->hasMedia())
-		{
-			media_faces++;
-		}
-
-		if (te)
-		{
-			if (te->getBumpmap())
-			{
-				bump = 1;
-			}
-			if (te->getShiny())
-			{
-				shiny = 1;
-			}
-			if (te->getGlow() > 0.f)
-			{
-				glow = 1;
-			}
-			if (face->mTextureMatrix != NULL)
-			{
-				animtex = 1;
-			}
-		}
-	}
-
-	//BD - shame currently has the "base" cost of 1 point per 5 triangles, min 2.
-	U32 shame = vovolume->mRenderComplexityBase;
-
-	if (animtex)
-	{
-		animated_cost += (shame * ARC_ANIM_TEX_COST);
-	}
-
-	if (glow)
-	{
-		glow_cost += (shame * ARC_GLOW_MULT);
-	}
-
-	if (bump)
-	{
-		bump_cost += (shame * ARC_BUMP_MULT);
-	}
-
-	if (shiny)
-	{
-		shiny_cost += (shame * ARC_SHINY_MULT);
-	}
-
-	if (weighted_mesh)
-	{
-		rigged_cost += (shame * ARC_WEIGHTED_MESH);
-
-		if (alpha)
-		{
-			alpha_cost += (shame * ARC_ALPHA_COST);
-		}
-	}
-	else
-	{
-		if (alpha)
-		{
-			alpha_cost += (shame * ARC_RIGGED_ALPHA_COST);
-		}
-	}
-
-	if (isAnimatedObject())
-	{
-		animesh_cost += (shame * ARC_ANIMATED_MESH_COST);
-	}
-
-	// multiply shame by multipliers
-	if (isFlexible())
-	{
-		flexible_cost += (shame * ARC_FLEXI_MULT);
-	}
-
-	// add additional costs
-	if (isParticleSource())
-	{
-		const LLPartSysData *part_sys_data = &(mPartSourcep->mPartSysData);
-		const LLPartData *part_data = &(part_sys_data->mPartData);
-		U32 num_particles = (U32)(part_sys_data->mBurstPartCount * llceil(part_data->mMaxAge / part_sys_data->mBurstRate));
-		//BD
-		F32 part_size = (llmax(part_data->mStartScale[0], part_data->mEndScale[0]) + llmax(part_data->mStartScale[1], part_data->mEndScale[1])) / 2.f;
-		particle_cost += num_particles * part_size * ARC_PARTICLE_COST;
-	}
-
-	if (getIsLight())
-	{
-		light_cost += ARC_LIGHT_COST;
-	}
-	else if (getHasShadow())
-	{
-		projector_cost += ARC_PROJECTOR_COST;
-	}
-
-	if (media_faces)
-	{
-		media_cost += media_faces * ARC_MEDIA_FACE_COST;
-	}
-}
 
 F32 LLVOVolume::getEstTrianglesMax() const
 {
@@ -4982,40 +4452,11 @@ void LLVOVolume::forceLOD(S32 lod)
 	// [/SL:KB]
 
 	mLOD = lod;
-	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
+	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME);
 	mLODChanged = true;
 }
 // [/FS]
 
-U64 LLVOVolume::getHighLODTriangleCount64()
-{
-	U64 ret = 0;
-	LLVolume* volume = getVolume();
-
-	if (!isSculpted())
-	{
-		LLVolume* ref = LLPrimitive::getVolumeManager()->refVolume(volume->getParams(), 3);
-		ret = ref->getNumTriangles64();
-		LLPrimitive::getVolumeManager()->unrefVolume(ref);
-	}
-	else if (isMesh())
-	{
-		LLVolume* ref = LLPrimitive::getVolumeManager()->refVolume(volume->getParams(), 3);
-		if (!ref->isMeshAssetLoaded() || ref->getNumVolumeFaces() == 0)
-		{
-			gMeshRepo.loadMesh(this, volume->getParams(), LLModel::LOD_HIGH);
-		}
-		ret = ref->getNumTriangles64();
-		LLPrimitive::getVolumeManager()->unrefVolume(ref);
-	}
-	else
-	{ //default sculpts have a constant number of triangles
-		ret = 31 * 2 * 31;  //31 rows of 31 columns of quads for a 32x32 vertex patch
-	}
-
-	return ret;
-}
-
 //static
 void LLVOVolume::preUpdateGeom()
 {
@@ -5862,14 +5303,14 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	//	bool selected = facep->getViewerObject()->isSelected();
 	//
 	//	if (selected && LLSelectMgr::getInstance()->mHideSelectedObjects)
-	// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
+// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
 	const LLViewerObject* pObj = facep->getViewerObject();
-	bool selected = pObj->isSelected();
+	//bool selected = pObj->isSelected();
 	if ((pObj->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects) &&
 		((!RlvActions::isRlvEnabled()) ||
 		(((!pObj->isHUDAttachment()) || (!gRlvAttachmentLocks.isLockedAttachment(pObj->getRootEdit()))) &&
 			(RlvActions::canEdit(pObj)))))
-		// [/RVLa:KB]
+// [/RVLa:KB]
 	{
 		return;
 	}
@@ -5927,19 +5368,19 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	{
 		model_mat = &drawable->getWorldMatrix();
 		//		//BD - Motion Blur
-		if (gPipeline.RenderMotionBlur)
+		/*if (gPipeline.RenderMotionBlur)
 		{
 			last_model_mat = &drawable->getLastRenderMatrix();
-		}
+		}*/
 	}
 	else if (drawable->isActive())
 	{
 		model_mat = &drawable->getRenderMatrix();
 		//		//BD - Motion Blur
-		if (gPipeline.RenderMotionBlur)
+		/*if (gPipeline.RenderMotionBlur)
 		{
 			last_model_mat = &drawable->getLastRenderMatrix();
-		}
+		}*/
 	}
 	else
 	{
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 00ee330bfd64327c7b4baee426e105768a7b0abb..08080f1fa53ed23d5749c95788e34c9da21e14c0 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1426,6 +1426,34 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector<LLVector3d>* positi
 	}
 }
 
+// [RLVa:KB] - Checked: RLVa-2.0.1
+bool LLWorld::getAvatar(const LLUUID& idAvatar, LLVector3d& posAvatar) const
+{
+	for (const LLCharacter* pCharacter : LLCharacter::sInstances)
+	{
+		const LLVOAvatar* pAvatar = static_cast<const LLVOAvatar*>(pCharacter);
+		if ((!pAvatar->isDead()) && (!pAvatar->mIsDummy) && (!pAvatar->isOrphaned()) && (idAvatar == pAvatar->getID()))
+		{
+			posAvatar = pAvatar->getPositionGlobal();
+			return true;
+		}
+	}
+
+	for (const LLViewerRegion* pRegion : LLWorld::getInstance()->getRegionList())
+	{
+		for (S32 idxAgent = 0, cntAgent = pRegion->mMapAvatarIDs.size(); idxAgent < cntAgent; ++idxAgent)
+		{
+			if (idAvatar == pRegion->mMapAvatarIDs[idxAgent])
+			{
+				posAvatar = unpackLocalToGlobalPosition(pRegion->mMapAvatars[idxAgent], pRegion->getOriginGlobal());
+				return true;
+			}
+		}
+	}
+	return false;
+}
+// [/RLVa:KB]
+
 F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector<LLCharacter*> &valid_nearby_avs)
 {
     static LLCachedControl<F32> render_far_clip(gSavedSettings, "RenderFarClip", 64);
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index ec8bccd1171dac3ffa1413c60662a0658eef62c6..e5b7e7ecec704fb24fc08825d3c7878af3ce6ce0 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -121,7 +121,7 @@
 #include "llsettingsvo.h"
 
 //BD - Exodus Post Process
-#include "exopostprocess.h"
+//#include "exopostprocess.h"
 
 bool gShiftFrame = false;
 
@@ -216,7 +216,6 @@ BOOL LLPipeline::RenderDeferredBlurLight;
 BOOL LLPipeline::RenderSnapshotAutoAdjustMultiplier;
 BOOL LLPipeline::RenderHighPrecisionNormals;
 BOOL LLPipeline::RenderShadowAutomaticDistance;
-BOOL LLPipeline::RenderScreenSpaceReflections;
 U32 LLPipeline::RenderSSRResolution;
 F32 LLPipeline::RenderSSRBrightness;
 F32 LLPipeline::RenderSSAOBlurSize;
@@ -241,9 +240,9 @@ F32 LLPipeline::RenderGodraysMultiplier;
 F32 LLPipeline::RenderGodraysFalloffMultiplier;
 
 //    //BD - Motion Blur
-BOOL LLPipeline::RenderMotionBlur;
+/*BOOL LLPipeline::RenderMotionBlur;
 U32 LLPipeline::RenderMotionBlurStrength;
-U32 LLPipeline::RenderMotionBlurQuality;
+U32 LLPipeline::RenderMotionBlurQuality;*/
 
 
 const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
@@ -674,9 +673,9 @@ void LLPipeline::init()
 	connectRefreshCachedSettingsSafe("RenderProjectorShadowResolution");
 
 //	//BD - Motion Blur
-	connectRefreshCachedSettingsSafe("RenderMotionBlur");
+	/*connectRefreshCachedSettingsSafe("RenderMotionBlur");
 	connectRefreshCachedSettingsSafe("RenderMotionBlurStrength");
-	connectRefreshCachedSettingsSafe("RenderRiggedMotionBlurQuality");
+	connectRefreshCachedSettingsSafe("RenderRiggedMotionBlurQuality");*/
 }
 
 LLPipeline::~LLPipeline()
@@ -981,7 +980,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 	//allocateShadowMaps(true);
 
 //	//BD - Motion Blur
-	if (RenderMotionBlur)
+	/*if (RenderMotionBlur)
 	{
 		//allocate velocity map
 		mVelocityMap.allocate(resX, resY, GL_RGB, FALSE, LLTexUnit::TT_RECT_TEXTURE);
@@ -990,7 +989,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 	else
 	{
 		mVelocityMap.release();
-	}
+	}*/
 
     if (!gCubeSnapshot && RenderScreenSpaceReflections) // hack to not allocate mSceneMap for cube snapshots
     {
@@ -1015,7 +1014,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 }
 
 //BD - Refresh reflections on the fly.
-void LLPipeline::handleReflectionChanges()
+/*void LLPipeline::handleReflectionChanges()
 {
 	mWaterRef.release();
 	mWaterDis.release();
@@ -1026,13 +1025,13 @@ void LLPipeline::handleReflectionChanges()
 		mWaterRef.allocate(res, res, GL_RGBA, TRUE, FALSE);
 		mWaterDis.allocate(res, res, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE);
 	}
-}
+}*/
 
 // must be even to avoid a stripe in the horizontal shadow blur
 inline U32 BlurHappySize(U32 x, F32 scale) { return U32(x * scale + 16.0f) & ~0xF; }
 
 //BD - Shadow Map Allocation
-void LLPipeline::allocateShadowMaps(bool allocate)
+/*void LLPipeline::allocateShadowMaps(bool allocate)
 {
 	LLVector4 scale = gSavedSettings.getVector4("RenderShadowResolution");
 	LLVector2 proj_scale = gSavedSettings.getVector2("RenderProjectorShadowResolution");
@@ -1099,7 +1098,7 @@ void LLPipeline::allocateShadowMaps(bool allocate)
 			mShadowOcclusion[i].release();
 		}
 	}
-}
+}*/
 
 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY)
 {
@@ -1212,7 +1211,6 @@ void LLPipeline::refreshCachedSettings()
 			&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 
 			&& gSavedSettings.getBOOL("UseOcclusion")) ? 2 : 0;
 	
-    WindLightUseAtmosShaders = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("WindLightUseAtmosShaders");
     RenderDeferred = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderDeferred");
 	RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash");
 	RenderFSAASamples = LLFeatureManager::getInstance()->isFeatureAvailable("RenderFSAASamples") ? gSavedSettings.getU32("RenderFSAASamples") : 0;
@@ -1334,12 +1332,12 @@ void LLPipeline::refreshCachedSettings()
 	RenderNumColors = gSavedSettings.getU32("RenderPostPosterizationSamples");
 
 //	//BD - Exodus Post Process
-	exoPostProcess::instance().ExodusRenderPostSettingsUpdate();
+	//exoPostProcess::instance().ExodusRenderPostSettingsUpdate();
 
 	//	//BD - Motion Blur
-	RenderMotionBlur = gSavedSettings.getBOOL("RenderMotionBlur");
+	/*RenderMotionBlur = gSavedSettings.getBOOL("RenderMotionBlur");
 	RenderMotionBlurStrength = gSavedSettings.getU32("RenderMotionBlurStrength");
-	RenderMotionBlurQuality = gSavedSettings.getU32("RenderRiggedMotionBlurQuality");
+	RenderMotionBlurQuality = gSavedSettings.getU32("RenderRiggedMotionBlurQuality");*/
 
 	if (gNonInteractive)
 	{
@@ -1414,7 +1412,7 @@ void LLPipeline::releaseScreenBuffers()
     mRT->deferredScreen.release();
     mRT->deferredLight.release();
 //	//BD - Motion Blur
-	mRT->velocity.release();
+	//mRT->velocity.release();
 }
 
 void LLPipeline::releaseSunShadowTarget(U32 index)
@@ -1506,7 +1504,7 @@ void LLPipeline::createGLBuffers()
 	}
 
 //	//BD - Exodus Post Process
-	exoPostProcess::instance().ExodusGenerateLUT();
+	//exoPostProcess::instance().ExodusGenerateLUT();
 
 	createLUTBuffers();
 
@@ -3833,7 +3831,7 @@ void LLPipeline::postSort(LLCamera &camera)
 
         if (!gNonInteractive)
         {
-            LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit());
+            LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->mPanelFace->getTextureChannelToEdit());
         }
 
         // Draw face highlights for selected faces.
@@ -6829,7 +6827,7 @@ void LLPipeline::renderObjects(U32 type, bool texture, bool batch_texture, bool
 }
 
 //BD - Motion Blur
-void LLPipeline::renderMotionBlur(U32 type)
+/*void LLPipeline::renderMotionBlur(U32 type)
 {
 	//draw motion blurred primitives
 	for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i)
@@ -6842,17 +6840,17 @@ void LLPipeline::renderMotionBlur(U32 type)
 			{
 				LLRenderPass::applyModelMatrix(*params);
 
-				if (params->mGroup)
-				{
-					params->mGroup->rebuildMesh();
-				}
+				//if (params->mGroup)
+				//{
+				//	params->mGroup->rebuildMesh();
+				//}
 
 				LLGLSLShader::sCurBoundShaderPtr->uniformMatrix4fv(LLShaderMgr::LAST_OBJECT_MATRIX, 1, GL_FALSE, (F32*)params->mLastModelMatrix->mMatrix);
 				LLGLSLShader::sCurBoundShaderPtr->uniformMatrix4fv(LLShaderMgr::CURRENT_OBJECT_MATRIX, 1, GL_FALSE, (F32*)params->mModelMatrix->mMatrix);
 
-				params->mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
-				params->mVertexBuffer->drawRange(params->mDrawMode, params->mStart, params->mEnd, params->mCount, params->mOffset);
-				gPipeline.addTrianglesDrawn(params->mCount, params->mDrawMode);
+				params->mVertexBuffer->setBuffer();
+				params->mVertexBuffer->drawRange(LLRender::TRIANGLE_FAN, params->mStart, params->mEnd, params->mCount, params->mOffset);
+				gPipeline.addTrianglesDrawn(params->mCount);
 			}
 		}
 	}
@@ -6889,7 +6887,7 @@ void LLPipeline::renderMotionBlurWithTexture(U32 type)
 				{ //not batching textures or batch has only 1 texture -- might need a texture matrix
 					if (params->mTexture.notNull())
 					{
-						params->mTexture->addTextureStats(params->mVSize);
+						params->mTexture->addTextureStats(params->mTexture->getMaxVirtualSize());
 						gGL.getTexUnit(0)->bind(params->mTexture, TRUE);
 						if (params->mTextureMatrix)
 						{
@@ -6906,17 +6904,17 @@ void LLPipeline::renderMotionBlurWithTexture(U32 type)
 					}
 				}
 
-				if (params->mGroup)
-				{
-					params->mGroup->rebuildMesh();
-				}
+				//if (params->mGroup)
+				//{
+				//	params->mGroup->rebuildMesh();
+				//}
 
 				LLGLSLShader::sCurBoundShaderPtr->uniformMatrix4fv(LLShaderMgr::LAST_OBJECT_MATRIX, 1, GL_FALSE, (F32*)params->mLastModelMatrix->mMatrix);
 				LLGLSLShader::sCurBoundShaderPtr->uniformMatrix4fv(LLShaderMgr::CURRENT_OBJECT_MATRIX, 1, GL_FALSE, (F32*)params->mModelMatrix->mMatrix);
 
-				params->mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD0);
-				params->mVertexBuffer->drawRange(params->mDrawMode, params->mStart, params->mEnd, params->mCount, params->mOffset);
-				gPipeline.addTrianglesDrawn(params->mCount, params->mDrawMode);
+				params->mVertexBuffer->setBuffer();
+				params->mVertexBuffer->drawRange(LLRender::TRIANGLE_FAN, params->mStart, params->mEnd, params->mCount, params->mOffset);
+				gPipeline.addTrianglesDrawn(params->mCount);
 
 				if (tex_setup)
 				{
@@ -6926,7 +6924,7 @@ void LLPipeline::renderMotionBlurWithTexture(U32 type)
 			}
 		}
 	}
-}
+}*/
 
 void LLPipeline::renderGLTFObjects(U32 type, bool texture, bool rigged)
 {
@@ -8288,7 +8286,7 @@ void LLPipeline::renderDeferredLighting()
             bindDeferredShader(gDeferredBlurLightProgram);
 
             LLVector3 go = RenderShadowGaussian;
-            const U32 kern_length = 4;
+            //const U32 kern_length = 4;
             F32       blur_size = RenderShadowBlurSize;
             F32       dist_factor = RenderShadowBlurDistFactor;
 
@@ -8707,10 +8705,10 @@ void LLPipeline::renderDeferredLighting()
     }
 
 //	//BD - Motion Blur
-	if (RenderMotionBlur)
+	/*if (RenderMotionBlur)
 	{
 		renderGeomMotionBlur();
-	}
+	}*/
     screen_target->flush();
 
     if (!gCubeSnapshot)
@@ -8727,7 +8725,7 @@ void LLPipeline::renderDeferredLighting()
 }
 
 //BD - Motion Blur
-LLTrace::BlockTimerStatHandle FTM_RENDER_MOTION_BLUR("Motion Blur");
+/*LLTrace::BlockTimerStatHandle FTM_RENDER_MOTION_BLUR("Motion Blur");
 
 void LLPipeline::renderGeomMotionBlur()
 {
@@ -8838,7 +8836,7 @@ void LLPipeline::renderGeomMotionBlur()
 
 	gGLLastMatrix = NULL;
 	gGL.loadMatrix(gGLModelView);
-}
+}*/
 
 void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
 {
@@ -8979,395 +8977,56 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
 		
 }
 
-void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
+void LLPipeline::unbindDeferredShader(LLGLSLShader& shader)
 {
-    LLRenderTarget* deferred_target       = &mDeferredScreen;
-    LLRenderTarget* deferred_depth_target = &mDeferredDepth;
-    LLRenderTarget* deferred_light_target = &mDeferredLight;
+	LLRenderTarget* deferred_target = &mRT->deferredScreen;
+	LLRenderTarget* deferred_light_target = &mRT->deferredLight;
 
 	stop_glerror();
-    shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_BRDF_LUT);
+	//shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage());
+	shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage());
 	shader.disableTexture(LLShaderMgr::DIFFUSE_MAP);
 	shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM);
 
 	for (U32 i = 0; i < 4; i++)
 	{
-		if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1)
+		if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i) > -1)
 		{
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
 		}
 	}
 
 	for (U32 i = 4; i < 6; i++)
 	{
-		if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1)
+		if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i) > -1)
 		{
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
 		}
 	}
 
 	shader.disableTexture(LLShaderMgr::DEFERRED_NOISE);
 	shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC);
 
-	S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
-	if (channel > -1)
-	{
-		LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
-		if (cube_map)
-		{
-			cube_map->disable();
-		}
-	}
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	gGL.getTexUnit(0)->activate();
-	shader.unbind();
-}
-
-inline float sgn(float a)
-{
-    if (a > 0.0F) return (1.0F);
-    if (a < 0.0F) return (-1.0F);
-    return (0.0F);
-}
-
-void LLPipeline::generateWaterReflection(LLCamera& camera_in)
-{
-	LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
-
-	if (!assertInitialized())
-	{
-		return;
-	}
-
-	if (LLPipeline::sWaterReflections && LLDrawPoolWater::sNeedsReflectionUpdate)
-	{
-		//disable occlusion culling for reflection/refraction passes (save setting to restore later)
-		S32 occlude = LLPipeline::sUseOcclusion;
-		LLPipeline::sUseOcclusion = 0;
-
-		bool skip_avatar_update = false;
-		if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
-		{
-			skip_avatar_update = true;
-		}
-
-		LLCamera camera = camera_in;
-		camera.setFar(camera_in.getFar() * 0.75f);
-
-		bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater();
-
-		LLPipeline::sReflectionRender = true;
-
-		gPipeline.pushRenderTypeMask();
-
-		glh::matrix4f saved_modelview = get_current_modelview();
-		glh::matrix4f saved_projection = get_current_projection();
-		glh::matrix4f mat;
-
-		S32 reflection_detail = RenderReflectionDetail;
-
-		F32 water_height = gAgent.getRegion()->getWaterHeight();
-		F32 camera_height = camera_in.getOrigin().mV[VZ];
-		F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height);
-
-		LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f);
-		LLVector3 camera_look_at = camera_in.getAtAxis();
-		LLVector3 reflection_look_at = LLVector3(camera_look_at.mV[VX], camera_look_at.mV[VY], -camera_look_at.mV[VZ]);
-		LLVector3 reflect_origin = camera_in.getOrigin() - reflection_offset;
-		LLVector3 reflect_interest_point = reflect_origin + (reflection_look_at * 5.0f);
-
-		camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point);
-
-		//plane params
-		LLPlane plane;
-		LLVector3 pnorm;
-
-		if (camera_is_underwater)
-		{
-			//camera is below water, cull above water
-			pnorm.setVec(0, 0, 1);
-		}
-		else
-		{
-			//camera is above water, cull below water
-			pnorm = LLVector3(0, 0, -1);
-		}
-
-		plane.setVec(LLVector3(0, 0, water_height), pnorm);
-
-		if (!camera_is_underwater)
-		{
-			//generate planar reflection map
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0;
-
-			gGL.matrixMode(LLRender::MM_MODELVIEW);
-			gGL.pushMatrix();
-
-			mat.set_scale(glh::vec3f(1, 1, -1));
-			mat.set_translate(glh::vec3f(0, 0, water_height*2.f));
-			mat = saved_modelview * mat;
-
-
-			mReflectionModelView = mat;
-
-			set_current_modelview(mat);
-			gGL.loadMatrix(mat.m);
-
-			LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE);
-
-			glh::vec3f    origin(0, 0, 0);
-			glh::matrix4f inv_mat = mat.inverse();
-			inv_mat.mult_matrix_vec(origin);
-
-			camera.setOrigin(origin.v);
-
-			glCullFace(GL_FRONT);
-
-			if (LLDrawPoolWater::sNeedsReflectionUpdate)
-			{
-				gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-				glClearColor(0, 0, 0, 0);
-				mWaterRef.bindTarget();
-
-				gGL.setColorMask(true, true);
-				mWaterRef.clear();
-				gGL.setColorMask(true, false);
-				mWaterRef.getViewport(gGLViewport);
-
-				//initial sky pass (no user clip plane)
-				//mask out everything but the sky
-				gPipeline.pushRenderTypeMask();
-				{
-					if (reflection_detail >= WATER_REFLECT_MINIMAL)
-					{
-						gPipeline.andRenderTypeMask(
-							LLPipeline::RENDER_TYPE_SKY,
-							LLPipeline::RENDER_TYPE_WL_SKY,
-							LLPipeline::RENDER_TYPE_CLOUDS,
-							LLPipeline::END_RENDER_TYPES);
-					}
-					else
-					{
-						gPipeline.andRenderTypeMask(
-							LLPipeline::RENDER_TYPE_SKY,
-							LLPipeline::RENDER_TYPE_WL_SKY,
-							LLPipeline::END_RENDER_TYPES);
-					}
-
-					updateCull(camera, mSky);
-					stateSort(camera, mSky);
-					renderGeom(camera, TRUE);
-				}
-				gPipeline.popRenderTypeMask();
-
-				if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT)
-				{
-					gPipeline.pushRenderTypeMask();
-					{
-						clearRenderTypeMask(
-							LLPipeline::RENDER_TYPE_WATER,
-							LLPipeline::RENDER_TYPE_VOIDWATER,
-							LLPipeline::RENDER_TYPE_GROUND,
-							LLPipeline::RENDER_TYPE_SKY,
-							LLPipeline::RENDER_TYPE_CLOUDS,
-							LLPipeline::END_RENDER_TYPES);
-
-						if (reflection_detail > WATER_REFLECT_MINIMAL)
-						{ //mask out selected geometry based on reflection detail
-							if (reflection_detail < WATER_REFLECT_EVERYTHING)
-							{
-								clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
-								if (reflection_detail < WATER_REFLECT_AVATARS)
-								{
-									clearRenderTypeMask(
-										LLPipeline::RENDER_TYPE_AVATAR,
-										LLPipeline::RENDER_TYPE_CONTROL_AV,
-										END_RENDER_TYPES);
-									if (reflection_detail < WATER_REFLECT_STATIC_OBJECTS)
-									{
-										clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
-									}
-								}
-							}
-
-							LLGLUserClipPlane clip_plane(plane, mReflectionModelView, saved_projection);
-							LLGLDisable cull(GL_CULL_FACE);
-							updateCull(camera, mReflectedObjects, &plane);
-							stateSort(camera, mReflectedObjects);
-							renderGeom(camera);
-						}
-					}
-					gPipeline.popRenderTypeMask();
-				}
-
-				mWaterRef.flush();
-			}
-
-    // make sure we're not already targeting the same spot light with both shadow maps
-    llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull());
-
-    if (!gCubeSnapshot)
+	if (!LLPipeline::sReflectionProbesEnabled)
 	{
-		LLDrawable* potential = drawablep;
-		//determine if this light is higher priority than one of the existing spot shadows
-		F32 m_pri = volume->getSpotLightPriority();
-
-			set_current_modelview(saved_modelview);
-		}
-
-		camera.setOrigin(camera_in.getOrigin());
-		//render distortion map
-		static bool last_update = true;
-		if (last_update)
+		S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
+		if (channel > -1)
 		{
-			gPipeline.pushRenderTypeMask();
-
-			camera.setFar(camera_in.getFar());
-			clearRenderTypeMask(
-				LLPipeline::RENDER_TYPE_WATER,
-				LLPipeline::RENDER_TYPE_VOIDWATER,
-				LLPipeline::RENDER_TYPE_GROUND,
-				END_RENDER_TYPES);
-
-			// intentionally inverted so that distortion map contents (objects under the water when we're above it)
-			// will properly include water fog effects
-			LLPipeline::sUnderWaterRender = !camera_is_underwater;
-
-			if (LLPipeline::sUnderWaterRender)
+			LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
+			if (cube_map)
 			{
-				pri = mTargetShadowSpotLight[i]->getVOVolume()->getSpotLightPriority();
+				cube_map->disable();
 			}
-			LLViewerCamera::updateFrustumPlanes(camera);
-
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
-			if (LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsDistortionUpdate)
-			{
-				LLPipeline::sDistortionRender = true;
-
-				// make sure we didn't end up targeting the same spot light with both shadow maps
-				llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull());
-
-				LLViewerTexture* img = volume->getLightTexture();
-
-				// HACK FIX -- pretend underwater camera is the world camera to fix weird visibility artifacts
-				// during distortion render (doesn't break main render because the camera is the same perspective
-				// as world camera and occlusion culling is disabled for this pass)
-				//LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1;
-				LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
-
-				mWaterDis.bindTarget();
-				mWaterDis.getViewport(gGLViewport);
-
-				gGL.setColorMask(true, true);
-				mWaterDis.clear();
-				gGL.setColorMask(true, false);
-
-				F32 water_dist = water_height;
-
-				//clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself,
-				// but not so much as to clip out parts of avatars that should be seen under the water in the distortion map
-				LLPlane plane;
-
-				if (camera_is_underwater)
-				{
-					//nudge clip plane below water to avoid visible holes in objects intersecting water surface
-					water_dist /= LLPipeline::sDistortionWaterClipPlaneMargin;
-					//camera is below water, clip plane points up
-					pnorm.setVec(0, 0, -1);
-				}
-				else
-				{
-					//nudge clip plane above water to avoid visible holes in objects intersecting water surface
-					water_dist *= LLPipeline::sDistortionWaterClipPlaneMargin;
-					//camera is above water, clip plane points down
-					pnorm = LLVector3(0, 0, 1);
-				}
-
-				plane.setVec(LLVector3(0, 0, water_dist), pnorm);
-
-				LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection);
-
-				gGL.setColorMask(true, true);
-				mWaterDis.clear();
-				gGL.setColorMask(true, false);
-
-				if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT)
-				{
-					updateCull(camera, mRefractedObjects, &plane);
-					stateSort(camera, mRefractedObjects);
-					renderGeom(camera);
-				}
-
-				gUIProgram.bind();
-
-				LLWorld::getInstance()->renderPropertyLines();
-
-				gUIProgram.unbind();
-
-				mWaterDis.flush();
-			}
-
-			LLPipeline::sDistortionRender = false;
-
-			gPipeline.popRenderTypeMask();
-		}
-		last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
-
-void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
-{
-    LLRenderTarget* deferred_target       = &mRT->deferredScreen;
-    LLRenderTarget* deferred_light_target = &mRT->deferredLight;
-
-	stop_glerror();
-    shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_BRDF_LUT);
-    //shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_target->getUsage());
-    shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage());
-	shader.disableTexture(LLShaderMgr::DIFFUSE_MAP);
-	shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM);
-
-		LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
-		LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
-
-		if (!LLRenderTarget::sUseFBO)
-		{
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
 		}
-		glClearColor(0.f, 0.f, 0.f, 0.f);
-		gViewerWindow->setup3DViewport();
-
-		LLGLState::checkStates();
-
-		if (!skip_avatar_update)
-		{
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
-		}
-
-		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
-
-    if (!LLPipeline::sReflectionProbesEnabled)
-    {
-        S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
-        if (channel > -1)
-        {
-            LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
-            if (cube_map)
-            {
-                cube_map->disable();
-            }
-        }
-    }
+	}
 
-    unbindReflectionProbes(shader);
+	unbindReflectionProbes(shader);
 
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(0)->activate();
@@ -10914,7 +10573,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool
 	bool too_complex = !for_profile && !preview_avatar && avatar->isTooComplex();
     LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID()
                               << " is " << ( too_complex ? "" : "not ") << "too complex"
-                              << LL_ENDL;*/
+                              << LL_ENDL;
 
     pushRenderTypeMask();
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 13785a3d68ddd43b9b760d1565d010f193456fee..aa4e6ae48087e45a1c4e5d4ef4db20ee1d443635 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -298,9 +298,9 @@ class LLPipeline
     void renderFullbrightMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false);
 
 	//	//BD - Motion Blur
-	void renderMotionBlur(U32 type);
+	/*void renderMotionBlur(U32 type);
 	void renderMotionBlurWithTexture(U32 type);
-	void renderGeomMotionBlur();
+	void renderGeomMotionBlur();*/
 
 	void renderGroups(LLRenderPass* pass, U32 type, bool texture);
     void renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture);
@@ -1104,9 +1104,9 @@ class LLPipeline
 	static F32 RenderGodraysFalloffMultiplier;
 
 	//    //BD - Motion Blur
-	static BOOL RenderMotionBlur;
+	/*static BOOL RenderMotionBlur;
 	static U32 RenderMotionBlurStrength;
-	static U32 RenderMotionBlurQuality;
+	static U32 RenderMotionBlurQuality;*/
 };
 
 void render_bbox(const LLVector3 &min, const LLVector3 &max);
diff --git a/indra/newview/rlvenvironment.cpp b/indra/newview/rlvenvironment.cpp
index d723630fdb117e830ba48ba7d93ed96e27cfd6fb..b9b0e5fbdc83a6988312a5d04cbe30bb56abc0f7 100644
--- a/indra/newview/rlvenvironment.cpp
+++ b/indra/newview/rlvenvironment.cpp
@@ -18,6 +18,7 @@
 
 #include "llinventoryfunctions.h"
 #include "llsettingsvo.h"
+#include "llsettingssky.h"
 #include <boost/algorithm/string.hpp>
 
 #include "rlvactions.h"
diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml
index c8370ea46730a79159e368f356a19a9391c3959d..e91a16ec9e9108fd88760036c592953b33f22397 100644
--- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml
+++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml
@@ -493,6 +493,26 @@
              name="environment"
              width="135" />-->
             <!-- label is blank because control places it below the box -->
+            <combo_box
+             height="23"
+             layout="topleft"
+             left="10"
+             name="combobox matmedia"
+             top_pad="5"
+             width="90">
+                <combo_box.item
+                 label="Blinn-Phong"
+                 name="Materials"
+                 value="Materials" />
+                <combo_box.item
+                 label="PBR Metallic Roughness"
+                 name="PBR"
+                 value="PBR" />
+                <combo_box.item
+                 label="Media"
+                 name="Media"
+                 value="Media" />
+            </combo_box>
             <radio_group
      layout="topleft"
      left="5"