From f782e0192009b249edcb30ca2a5418ec7c1ddfa4 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Sat, 15 Jun 2013 05:18:50 -0700
Subject: NORSPEC-267 fix UI feedback for materials edits not appearing for
 observers when obj was selected by them

---
 indra/llprimitive/lltextureentry.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index 597f078490..0db75a0e82 100755
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -545,7 +545,7 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID)
 		{
 			mMaterialUpdatePending = true;
 			mMaterialID = pMaterialID;
-			return TEM_CHANGE_NONE;
+			return TEM_CHANGE_TEXTURE;
 		}
 
 		mMaterialUpdatePending = false;
-- 
cgit v1.2.3


From d75667560c35a578cc3876bde485ca2a44604992 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Sat, 15 Jun 2013 07:19:23 -0700
Subject: Silence spurious asserts when pool is cleared at exactly it's limit

---
 indra/llcommon/llapr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp
index a0802c6adf..b7815b0e35 100755
--- a/indra/llcommon/llapr.cpp
+++ b/indra/llcommon/llapr.cpp
@@ -226,7 +226,7 @@ void LLVolatileAPRPool::clearVolatileAPRPool()
 		llassert_always(mNumActiveRef > 0) ;
 	}
 
-	llassert(mNumTotalRef < (FULL_VOLATILE_APR_POOL << 2)) ;
+	llassert(mNumTotalRef <= (FULL_VOLATILE_APR_POOL << 2)) ;
 }
 
 BOOL LLVolatileAPRPool::isFull()
-- 
cgit v1.2.3


From c603eb5ece7ca2f2faa870bfd89f5f4e71e2b8f0 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Mon, 17 Jun 2013 08:03:32 -0700
Subject: MAINT-318 prevent crashes from incomplete quads and lines and prevent
 drivers from crashing to desktop when passed short buffers

---
 indra/llrender/llrender.cpp | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index c60eb8d9d9..f2f1b62be0 100755
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1849,35 +1849,36 @@ void LLRender::flush()
 			sUIVerts += mCount;
 		}
 		
-		if (gDebugGL)
+		//store mCount in a local variable to avoid re-entrance (drawArrays may call flush)
+		U32 count = mCount;
+
+		if (mMode == LLRender::QUADS && !sGLCoreProfile)
 		{
-			if (mMode == LLRender::QUADS && !sGLCoreProfile)
+			if (mCount%4 != 0)
 			{
-				if (mCount%4 != 0)
-				{
-					llerrs << "Incomplete quad rendered." << llendl;
-				}
+				count -= (mCount % 4);
+				llwarns << "Incomplete quad requested." << llendl;
 			}
-			
-			if (mMode == LLRender::TRIANGLES)
+		}
+
+		if (mMode == LLRender::TRIANGLES)
+		{
+			if (mCount%3 != 0)
 			{
-				if (mCount%3 != 0)
-				{
-					llerrs << "Incomplete triangle rendered." << llendl;
-				}
+				count -= (mCount % 3);
+				llwarns << "Incomplete triangle requested." << llendl;
 			}
-			
-			if (mMode == LLRender::LINES)
+		}
+
+		if (mMode == LLRender::LINES)
+		{
+			if (mCount%2 != 0)
 			{
-				if (mCount%2 != 0)
-				{
-					llerrs << "Incomplete line rendered." << llendl;
-				}
+				count -= (mCount % 2);
+				llwarns << "Incomplete line requested." << llendl;
 			}
 		}
-
-		//store mCount in a local variable to avoid re-entrance (drawArrays may call flush)
-		U32 count = mCount;
+		
 		mCount = 0;
 
 		if (mBuffer->useVBOs() && !mBuffer->isLocked())
-- 
cgit v1.2.3


From c1b7c8cacb6f6bcb8f6b9c7f73e059a41fee8c33 Mon Sep 17 00:00:00 2001
From: Graham Madarasz <graham@lindenlab.com>
Date: Mon, 17 Jun 2013 12:56:08 -0700
Subject: NORSPEC-246 Force light func to use GL_R32F format for more precision
 on older nV mobile cards with single FP hardware

---
 indra/newview/pipeline.cpp | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 8942092221..4a1b182fd2 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1190,7 +1190,14 @@ void LLPipeline::releaseLUTBuffers()
 {
 	if (mLightFunc)
 	{
-		LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, GL_R16F, 0, 1, &mLightFunc);
+		U32 pix_format = GL_R16F;
+#if LL_DARWIN
+		if (gGLManager.mIsMobileGF)
+		{
+			pix_format = GL_R32F;
+		}
+#endif
+		LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, pix_format, 0, 1, &mLightFunc);
 		mLightFunc = 0;
 	}
 }
@@ -1367,7 +1374,7 @@ void LLPipeline::createLUTBuffers()
 					// This is fine, given we only need to create our LUT once per buffer initialization.
 					spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n)));
 
-					// Since we use R16F, we no longer have a dynamic range issue we need to work around here.
+					// Since we use R16/32F, we no longer have a dynamic range issue we need to work around here.
 					// Though some older drivers may not like this, newer drivers shouldn't have this problem.
 					ls[y*lightResX+x] = spec;
 
@@ -1390,9 +1397,16 @@ void LLPipeline::createLUTBuffers()
 				}
 			}
 			
-			LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, GL_R16F, 1, &mLightFunc);
+			U32 pix_format = GL_R16F;
+#if LL_DARWIN
+			if (gGLManager.mIsMobileGF)
+			{
+				pix_format = GL_R32F;
+			}
+#endif
+			LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc);
 			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc);
-			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R16F, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false);
+			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false);
 			//LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_UNSIGNED_BYTE, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, ls, false);
 			gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
 			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
-- 
cgit v1.2.3


From 0dbe156e2317f8e34f2f0cfa65dc89ea30cd18f1 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Tue, 18 Jun 2013 09:10:13 -0700
Subject: NORSPEC-246 make 32F light LUT apply to all OS X machines as several
 non-nV cards were also failing

---
 indra/newview/pipeline.cpp | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4a1b182fd2..48f29b3237 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1192,10 +1192,9 @@ void LLPipeline::releaseLUTBuffers()
 	{
 		U32 pix_format = GL_R16F;
 #if LL_DARWIN
-		if (gGLManager.mIsMobileGF)
-		{
-			pix_format = GL_R32F;
-		}
+		// Need to work around limited precision with 10.6.8 and older drivers
+		//
+		pix_format = GL_R32F;
 #endif
 		LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, pix_format, 0, 1, &mLightFunc);
 		mLightFunc = 0;
@@ -1399,10 +1398,9 @@ void LLPipeline::createLUTBuffers()
 			
 			U32 pix_format = GL_R16F;
 #if LL_DARWIN
-			if (gGLManager.mIsMobileGF)
-			{
-				pix_format = GL_R32F;
-			}
+			// Need to work around limited precision with 10.6.8 and older drivers
+			//
+			pix_format = GL_R32F;
 #endif
 			LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, pix_format, 1, &mLightFunc);
 			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc);
-- 
cgit v1.2.3


From 42a46595558c5d87f62c9fd8e52fdad1c6960e4d Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Thu, 20 Jun 2013 09:34:30 -0700
Subject: NORSPEC-278 fix misuse of legacy bumps when rendering objects with TE
 bumpmap setting of 18 aka BUMPY_TEXTURE

---
 indra/newview/llvovolume.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 3be1f52352..685f854573 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5354,7 +5354,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 								mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE;
 			}
 
-			bool use_legacy_bump = te->getBumpmap() && (!mat || mat->getNormalID().isNull());
+			bool use_legacy_bump = te->getBumpmap() && (te->getBumpmap() < 18) && (!mat || mat->getNormalID().isNull());
 
 			if (mat && LLPipeline::sRenderDeferred && !hud_group)
 			{
-- 
cgit v1.2.3


From 65f0972a64f77388752794610e6dedc27b9eb228 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Thu, 20 Jun 2013 12:41:46 -0700
Subject: NORSPEC-262 make drag and drop aware of editing context so that
 editing normal/spec textures causes application to the correct tex channel

---
 indra/newview/llfloatertools.h      |  2 ++
 indra/newview/llpanelface.cpp       | 37 +++++++++++++++--------------
 indra/newview/llpanelface.h         | 21 +++++++++++++----
 indra/newview/llselectmgr.cpp       |  6 ++---
 indra/newview/lltooldraganddrop.cpp | 47 ++++++++++++++++++++++++++++++++++++-
 indra/newview/pipeline.cpp          |  4 +++-
 6 files changed, 89 insertions(+), 28 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloatertools.h b/indra/newview/llfloatertools.h
index ecb0092a6f..189bae46c2 100755
--- a/indra/newview/llfloatertools.h
+++ b/indra/newview/llfloatertools.h
@@ -109,6 +109,8 @@ public:
 
 	static void setGridMode(S32 mode);
 
+	LLPanelFace* getPanelFace() { return mPanelFace; }
+
 private:
 	void refresh();
 	void refreshMedia();
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 911af9df04..3869219da6 100755
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -66,7 +66,7 @@
 #include "llvovolume.h"
 #include "lluictrlfactory.h"
 #include "llpluginclassmedia.h"
-#include "llviewertexturelist.h"
+#include "llviewertexturelist.h"// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI
 
 //
 // Constant definitions for comboboxes
@@ -89,6 +89,19 @@ const S32 SHINY_TEXTURE = 4;		// use supplied specular map
 //
 std::string USE_TEXTURE;
 
+LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit()
+{
+	LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia");
+	LLComboBox* combobox_mattype	= getChild<LLComboBox>("combobox mattype");
+
+	LLRender::eTexIndex channel_to_edit = (combobox_matmedia && combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ?
+													  (combobox_mattype ? (LLRender::eTexIndex)combobox_mattype->getCurrentIndex() : LLRender::DIFFUSE_MAP) : LLRender::DIFFUSE_MAP;
+
+	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;
+}
+
 // Things the UI provides...
 //
 LLUUID	LLPanelFace::getCurrentNormalMap()			{ return getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID();	}
@@ -1194,7 +1207,8 @@ void LLPanelFace::updateUI()
 			getChildView("checkbox fullbright")->setEnabled(editable);
 			getChild<LLUICtrl>("checkbox fullbright")->setTentative(!identical_fullbright);
 		}
-		
+
+
 		// Repeats per meter
 		{
 			F32 repeats_diff = 1.f;
@@ -1218,6 +1232,9 @@ void LLPanelFace::updateUI()
 				F32  repeats = 1.0f;
 
 				U32 material_type = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? combobox_mattype->getCurrentIndex() : MATTYPE_DIFFUSE;
+
+				LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type));
+
 				switch (material_type)
 				{
 					default:
@@ -1328,18 +1345,6 @@ void LLPanelFace::updateUI()
 					getChild<LLColorSwatchCtrl>("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE);
 				}
 
-				// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI
-				// NORSPEC-103
-				LLRender::eTexIndex channel_to_edit = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? (LLRender::eTexIndex)combobox_mattype->getCurrentIndex() : LLRender::DIFFUSE_MAP;
-
-				if ( ((channel_to_edit == LLRender::NORMAL_MAP) && material->getNormalID().isNull())
-					||((channel_to_edit == LLRender::SPECULAR_MAP) && material->getSpecularID().isNull()))
-				{
-					channel_to_edit = LLRender::DIFFUSE_MAP;
-				}
-
-				LLSelectMgr::getInstance()->setTextureChannel(channel_to_edit);
-
 				// Bumpy (normal)
 				texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
 				texture_ctrl->setImageAssetID(material->getNormalID());
@@ -1365,10 +1370,6 @@ void LLPanelFace::updateUI()
 					updateBumpyControls(!material->getNormalID().isNull(), true);
 				}
 			}
-			else
-			{
-				LLSelectMgr::getInstance()->setTextureChannel(LLRender::DIFFUSE_MAP);
-			}
 		}
 
 		// Set variable values for numeric expressions
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index 42c1f6bd48..834ad9e14c 100755
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -100,6 +100,19 @@ public:
 	void			setMediaURL(const std::string& url);
 	void			setMediaType(const std::string& mime_type);
 
+	LLMaterialPtr createDefaultMaterial(LLMaterialPtr current_material)
+	{
+		LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial());
+		llassert_always(new_material);
+
+		// Preserve old diffuse alpha mode or assert correct default blend mode as appropriate for the alpha channel content of the diffuse texture
+		//
+		new_material->setDiffuseAlphaMode(current_material.isNull() ? (isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE) : current_material->getDiffuseAlphaMode());
+		return new_material;
+	}
+
+	LLRender::eTexIndex getTextureChannelToEdit();
+
 protected:
 	void			getState();
 
@@ -178,6 +191,8 @@ protected:
 
 	static F32     valueGlow(LLViewerObject* object, S32 face);
 
+	
+
 private:
 
 	bool		isAlpha() { return mIsAlpha; }
@@ -234,7 +249,7 @@ private:
 			{
 				if (_edit)
 				{
-					LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial());
+					LLMaterialPtr new_material = _panel->createDefaultMaterial(current_material);
 					llassert_always(new_material);
 
 					// Determine correct alpha mode for current diffuse texture
@@ -242,10 +257,6 @@ private:
 					//
 					U8 default_alpha_mode = (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
 
-					// Default to matching expected state of UI
-					//
-					new_material->setDiffuseAlphaMode(current_material.isNull() ? default_alpha_mode : current_material->getDiffuseAlphaMode());
-
 					// Do "It"!
 					//
 					_edit->apply(new_material);
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 0cbdbe16a3..7b397d46f3 100755
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -91,7 +91,7 @@
 #include "llvovolume.h"
 #include "pipeline.h"
 #include "llviewershadermgr.h"
-
+#include "llpanelface.h"
 #include "llglheaders.h"
 
 LLViewerObject* getSelectedParentObject(LLViewerObject *object) ;
@@ -2534,7 +2534,7 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch)
 					if (tep && !tep->getMaterialParams().isNull())
 					{
 						LLMaterialPtr orig = tep->getMaterialParams();
-						LLMaterialPtr p = new LLMaterial(orig->asLLSD());
+						LLMaterialPtr p = gFloaterTools->getPanelFace()->createDefaultMaterial(orig);
 						p->setNormalRepeat(normal_scale_s, normal_scale_t);
 						p->setSpecularRepeat(specular_scale_s, specular_scale_t);
 
@@ -2560,8 +2560,8 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch)
 					if (tep && !tep->getMaterialParams().isNull())
 					{
 						LLMaterialPtr orig = tep->getMaterialParams();
+						LLMaterialPtr p = gFloaterTools->getPanelFace()->createDefaultMaterial(orig);
 
-						LLMaterialPtr p = new LLMaterial(orig->asLLSD());
 						p->setNormalRepeat(normal_scale_s, normal_scale_t);
 						p->setSpecularRepeat(specular_scale_s, specular_scale_t);
 
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index e085834326..ef7d0cd81b 100755
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -58,6 +58,7 @@
 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llworld.h"
+#include "llpanelface.h"
 
 // syntactic sugar
 #define callMemberFunction(object,ptrToMember)  ((object).*(ptrToMember))
@@ -1163,7 +1164,51 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
 	// update viewer side image in anticipation of update from simulator
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
 	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
-	hit_obj->setTEImage(hit_face, image);
+
+	LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL;
+
+	LLPanelFace* panel_face = gFloaterTools->getPanelFace();
+
+	if (gFloaterTools->getVisible() && panel_face)
+	{
+		switch (LLSelectMgr::getInstance()->getTextureChannel())
+		{
+
+		case 0:
+		default:
+			{
+				hit_obj->setTEImage(hit_face, image);
+			}
+			break;
+
+		case 1:
+			{
+				LLMaterialPtr old_mat = tep->getMaterialParams();
+				LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat);
+				new_mat->setNormalID(asset_id);
+				tep->setMaterialParams(new_mat);
+				hit_obj->setTENormalMap(hit_face, asset_id);
+				LLMaterialMgr::getInstance()->put(hit_obj->getID(), hit_face, *new_mat);
+			}
+			break;
+
+		case 2:
+			{
+				LLMaterialPtr old_mat = tep->getMaterialParams();
+				LLMaterialPtr new_mat = panel_face->createDefaultMaterial(old_mat);
+				new_mat->setSpecularID(asset_id);
+				tep->setMaterialParams(new_mat);
+				hit_obj->setTESpecularMap(hit_face, asset_id);
+				LLMaterialMgr::getInstance()->put(hit_obj->getID(), hit_face, *new_mat);
+			}
+			break;
+		}
+	}
+	else
+	{
+		hit_obj->setTEImage(hit_face, image);
+	}
+	
 	dialog_refresh_all();
 
 	// send the update to the simulator
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 56a3ebe3a8..d37b086ae3 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -111,6 +111,8 @@
 #include "llpathinglib.h"
 #include "llfloaterpathfindingconsole.h"
 #include "llfloaterpathfindingcharacters.h"
+#include "llfloatertools.h"
+#include "llpanelface.h"
 #include "llpathfindingpathtool.h"
 
 #ifdef _DEBUG
@@ -3962,7 +3964,7 @@ void LLPipeline::postSort(LLCamera& camera)
 	{
 		mSelectedFaces.clear();
 
-		LLPipeline::setRenderHighlightTextureChannel(LLSelectMgr::getInstance()->getTextureChannel());
+		LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit());
 
 		// Draw face highlights for selected faces.
 		if (LLSelectMgr::getInstance()->getTEMode())
-- 
cgit v1.2.3


From 3a8cdb5d46cd12a5aad001e4bcec5b26f6f748ce Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Thu, 20 Jun 2013 15:27:22 -0700
Subject: NORSPEC-277 WIP backout old-school normal permutation

---
 .../shaders/class1/deferred/blurLightF.glsl        | 17 -----------
 .../shaders/class1/deferred/materialF.glsl         | 17 -----------
 .../shaders/class1/deferred/multiPointLightF.glsl  | 17 -----------
 .../shaders/class1/deferred/multiSpotLightF.glsl   | 17 -----------
 .../shaders/class1/deferred/pointLightF.glsl       | 17 -----------
 .../shaders/class1/deferred/softenLightF.glsl      | 17 -----------
 .../shaders/class1/deferred/spotLightF.glsl        | 17 -----------
 .../shaders/class1/deferred/sunLightSSAOF.glsl     | 17 -----------
 .../shaders/class2/deferred/multiSpotLightF.glsl   | 17 -----------
 .../shaders/class2/deferred/softenLightF.glsl      | 17 -----------
 .../shaders/class2/deferred/spotLightF.glsl        | 17 -----------
 .../shaders/class2/deferred/sunLightF.glsl         | 17 -----------
 .../shaders/class2/deferred/sunLightSSAOF.glsl     | 17 -----------
 indra/newview/llviewershadermgr.cpp                | 34 ----------------------
 14 files changed, 255 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 968a5f6b3d..a4f54dff70 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -59,22 +59,6 @@ vec4 getPosition(vec2 pos_screen)
 	return pos;
 }
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -91,7 +75,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 void main() 
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 618ea747f5..6cd8caa113 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -428,22 +428,6 @@ VARYING vec3 vary_normal;
 VARYING vec4 vertex_color;
 VARYING vec2 vary_texcoord0;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -460,7 +444,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 void main() 
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 868526d457..c95aa8bb3c 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -56,22 +56,6 @@ uniform float far_z;
 
 uniform mat4 inv_proj;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -88,7 +72,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition(vec2 pos_screen)
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 97bf49a605..7d39ad7bc1 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -67,22 +67,6 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -99,7 +83,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 correctWithGamma(vec4 col)
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index caf20ce707..106d48bd71 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -54,22 +54,6 @@ uniform vec2 screen_res;
 uniform mat4 inv_proj;
 uniform vec4 viewport;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -86,7 +70,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition(vec2 pos_screen)
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 08583ad0f2..f0d2746700 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -78,22 +78,6 @@ vec3 vary_AtmosAttenuation;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec3 decode_normal (vec2 enc)
 {
     vec2 fenc = enc*4-2;
@@ -104,7 +88,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition_d(vec2 pos_screen, float depth)
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 1975b18652..045d1a00cd 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -65,22 +65,6 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -97,7 +81,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 correctWithGamma(vec4 col)
 {
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 6653f57ee1..c0a5865bef 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -49,22 +49,6 @@ VARYING vec2 vary_fragcoord;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -81,7 +65,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition(vec2 pos_screen)
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 780df9ed1a..0deb4fe3b6 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -68,22 +68,6 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -100,7 +84,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 correctWithGamma(vec4 col)
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 67bac1f7c2..6e05091b57 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -78,22 +78,6 @@ vec3 vary_AtmosAttenuation;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -110,7 +94,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition_d(vec2 pos_screen, float depth)
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index fc0e6b2388..7a4337c277 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -68,22 +68,6 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -100,7 +84,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 correctWithGamma(vec4 col)
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 7b09dd29dd..95c09d3238 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -65,22 +65,6 @@ uniform float shadow_offset;
 uniform float spot_shadow_bias;
 uniform float spot_shadow_offset;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -97,7 +81,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition(vec2 pos_screen)
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 01e34ed792..b5ff6404ea 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -66,22 +66,6 @@ uniform float shadow_offset;
 uniform float spot_shadow_bias;
 uniform float spot_shadow_offset;
 
-#ifdef SINGLE_FP_ONLY
-vec2 encode_normal(vec3 n)
-{
-	vec2 sn;
-	sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
-	return sn;
-}
-
-vec3 decode_normal (vec2 enc)
-{
-	vec3 n;
-	n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
-	n.z = sqrt(1.0f - dot(n.xy,n.xy));
-	return n;
-}
-#else
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
@@ -98,7 +82,6 @@ vec3 decode_normal (vec2 enc)
     n.z = 1-f/2;
     return n;
 }
-#endif
 
 vec4 getPosition(vec2 pos_screen)
 {
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e24237522a..fa9c2ce51f 100755
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -42,22 +42,6 @@
 #include "llvosky.h"
 #include "llrender.h"
 
-#if LL_DARWIN
-#include "OpenGL/OpenGL.h"
-
-// include spec exp clamp to fix older mac rendering artifacts
-//
-#define SINGLE_FP_PERMUTATION(shader)					\
-	if (gGLManager.mIsMobileGF)							\
-	{																\
-		shader.addPermutation("SINGLE_FP_ONLY","1");		\
-	}
-
-
-#else
-#define SINGLE_FP_PERMUTATION(shader)
-#endif
-
 #ifdef LL_RELEASE_FOR_DOWNLOAD
 #define UNIFORM_ERRS LL_WARNS_ONCE("Shader")
 #else
@@ -1308,8 +1292,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 			bool has_skin = i & 0x10;
 			gDeferredMaterialProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0");
 
-			SINGLE_FP_PERMUTATION(gDeferredMaterialProgram[i]);
-
 			if (has_skin)
 			{
 				gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true;
@@ -1368,8 +1350,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredLightProgram);
-
 		success = gDeferredLightProgram.createShader(NULL, NULL);
 	}
 
@@ -1381,8 +1361,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredMultiLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram);
-
 		success = gDeferredMultiLightProgram.createShader(NULL, NULL);
 	}
 
@@ -1394,8 +1372,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredSpotLightProgram);
-
 		success = gDeferredSpotLightProgram.createShader(NULL, NULL);
 	}
 
@@ -1407,8 +1383,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredMultiSpotLightProgram);
-
 		success = gDeferredMultiSpotLightProgram.createShader(NULL, NULL);
 	}
 
@@ -1436,8 +1410,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
 		gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredSunProgram);
-
 		success = gDeferredSunProgram.createShader(NULL, NULL);
 	}
 
@@ -1449,8 +1421,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredBlurLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredBlurLightProgram);
-
 		success = gDeferredBlurLightProgram.createShader(NULL, NULL);
 	}
 
@@ -1482,8 +1452,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0");
 		gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredAlphaProgram);
-
 		success = gDeferredAlphaProgram.createShader(NULL, NULL);
 
 		// Hack
@@ -1600,8 +1568,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 
 		gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
-		SINGLE_FP_PERMUTATION(gDeferredSoftenProgram);
-
 		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);
-- 
cgit v1.2.3


From 559173f71196602dd85211a786af7829ab2877c4 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Mon, 24 Jun 2013 06:44:14 -0700
Subject: NORSPEC-280 include fix to downsampleDepthRect shader making GL 3.3.
 drivers cry

---
 .../app_settings/shaders/class1/interface/downsampleDepthRectF.glsl     | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
index 2f89b8ed72..0e5dc08183 100644
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
@@ -23,6 +23,8 @@
  * $/LicenseInfo$
  */
 
+#extension GL_ARB_texture_rectangle : enable
+
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-- 
cgit v1.2.3


From 280a9d9827e4e5e0e1408cc8f9c20ef792a6c714 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 25 Jun 2013 18:02:08 -0500
Subject: MATBUG-78 Fix for alpha lighting falloff not matching opaque lighting
 falloff (again).

---
 indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl    | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 0899caa2af..143af0576c 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -101,7 +101,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float
 		float dist = d/la;
 		da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
 		da *= da;
-		da *= 1.4;
+		da *= 2.0;
 	
 
 		// spotlight coefficient.
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 618ea747f5..10b6385809 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -142,7 +142,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
 		float dist = d/la;
 		float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
 		dist_atten *= dist_atten;
-		dist_atten *= 1.4;
+		dist_atten *= 2.0;
 
 		// spotlight coefficient.
 		float spot = max(dot(-ln, lv), is_pointlight);
-- 
cgit v1.2.3


From 1c6783fdb564cb10ade2a585a874ce951fff34e6 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 26 Jun 2013 09:43:01 -0400
Subject: NORSPEC-29: use the MaxMaterialsPerTransaction simulator feature if
 available

---
 indra/newview/llmaterialmgr.cpp  | 86 +++++++++++++++++++++++++---------------
 indra/newview/llmaterialmgr.h    |  2 +
 indra/newview/llviewerregion.cpp |  2 +-
 indra/newview/llviewerregion.h   |  2 +-
 4 files changed, 57 insertions(+), 35 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index 16871adc4d..ad9958546c 100644
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -50,13 +50,12 @@
 #define MATERIALS_CAP_MATERIAL_FIELD              "Material"
 #define MATERIALS_CAP_OBJECT_ID_FIELD             "ID"
 #define MATERIALS_CAP_MATERIAL_ID_FIELD           "MaterialID"
+#define SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION "MaxMaterialsPerTransaction"
 
-#define MATERIALS_GET_MAX_ENTRIES                 50
+#define MATERIALS_DEFAULT_MAX_ENTRIES             50
 #define MATERIALS_GET_TIMEOUT                     (60.f * 20)
-#define MATERIALS_POST_MAX_ENTRIES                50
 #define MATERIALS_POST_TIMEOUT                    (60.f * 5)
 #define MATERIALS_PUT_THROTTLE_SECS               1.f
-#define MATERIALS_PUT_MAX_ENTRIES                 50
 
 /**
  * LLMaterialsResponder helper class
@@ -595,8 +594,9 @@ void LLMaterialMgr::processGetQueue()
 		LLSD materialsData = LLSD::emptyArray();
 
 		material_queue_t& materials = itRegionQueue->second;
-		material_queue_t::iterator loopMaterial = materials.begin();
-		while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) )
+		U32 max_entries = getMaxEntries(regionp);
+		material_queue_t::iterator loopMaterial = materials.begin();		
+		while ( (materials.end() != loopMaterial) && (materialsData.size() < max_entries) )
 		{
 			material_queue_t::iterator itMaterial = loopMaterial++;
 			materialsData.append((*itMaterial).asLLSD());
@@ -680,39 +680,43 @@ void LLMaterialMgr::processPutQueue()
 
 		const LLUUID& object_id = itQueue->first;
 		const LLViewerObject* objectp = gObjectList.findObject(object_id);
-		if ( (!objectp) || (!objectp->getRegion()) )
+		if ( !objectp )
 		{
-			LL_WARNS("Materials") << "Object or object region is NULL" << LL_ENDL;
-
+			LL_WARNS("Materials") << "Object is NULL" << LL_ENDL;
 			mPutQueue.erase(itQueue);
-			continue;
-		}
-
-		const LLViewerRegion* regionp = objectp->getRegion();
-		if (!regionp->capabilitiesReceived())
-		{
-			continue;
 		}
-
-		LLSD& facesData = requests[regionp];
-
-		facematerial_map_t& face_map = itQueue->second;
-		facematerial_map_t::iterator itFace = face_map.begin();
-		while ( (face_map.end() != itFace) && (facesData.size() < MATERIALS_GET_MAX_ENTRIES) )
+		else
 		{
-			LLSD faceData = LLSD::emptyMap();
-			faceData[MATERIALS_CAP_FACE_FIELD] = static_cast<LLSD::Integer>(itFace->first);
-			faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast<LLSD::Integer>(objectp->getLocalID());
-			if (!itFace->second.isNull())
+			const LLViewerRegion* regionp = objectp->getRegion();
+			if ( !regionp )
 			{
-				faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD();
+				LL_WARNS("Materials") << "Object region is NULL" << LL_ENDL;
+				mPutQueue.erase(itQueue);
+			}
+			else if ( regionp->capabilitiesReceived())
+			{
+				LLSD& facesData = requests[regionp];
+
+				facematerial_map_t& face_map = itQueue->second;
+				U32 max_entries = getMaxEntries(regionp);
+				facematerial_map_t::iterator itFace = face_map.begin();
+				while ( (face_map.end() != itFace) && (facesData.size() < max_entries) )
+				{
+					LLSD faceData = LLSD::emptyMap();
+					faceData[MATERIALS_CAP_FACE_FIELD] = static_cast<LLSD::Integer>(itFace->first);
+					faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast<LLSD::Integer>(objectp->getLocalID());
+					if (!itFace->second.isNull())
+					{
+						faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD();
+					}
+					facesData.append(faceData);
+					face_map.erase(itFace++);
+				}
+				if (face_map.empty())
+				{
+					mPutQueue.erase(itQueue);
+				}
 			}
-			facesData.append(faceData);
-			face_map.erase(itFace++);
-		}
-		if (face_map.empty())
-		{
-			mPutQueue.erase(itQueue);
 		}
 	}
 
@@ -773,10 +777,26 @@ void LLMaterialMgr::clearGetQueues(const LLUUID& region_id)
 	mGetAllPending.erase(region_id);
 	mGetAllCallbacks.erase(region_id);
 }
-
 void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp)
 {
 	clearGetQueues(regionp->getRegionID());
 	// Put doesn't need clearing: objects that can't be found will clean up in processPutQueue()
 }
 
+U32 LLMaterialMgr::getMaxEntries(const LLViewerRegion* regionp)
+{
+	LLSD sim_features;
+	regionp->getSimulatorFeatures(sim_features);
+	U32 max_entries;
+	if (   sim_features.has( SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION )
+		&& sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].isInteger())
+	{
+		max_entries = sim_features[ SIM_FEATURE_MAX_MATERIALS_PER_TRANSACTION ].asInteger();
+	}
+	else
+	{
+		max_entries = MATERIALS_DEFAULT_MAX_ENTRIES;
+	}
+	return max_entries;
+}
+
diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h
index e317a791ad..e83f1f4e01 100644
--- a/indra/newview/llmaterialmgr.h
+++ b/indra/newview/llmaterialmgr.h
@@ -124,6 +124,8 @@ protected:
 	put_queue_t mPutQueue;
 
 	material_map_t mMaterials;
+
+	U32 getMaxEntries(const LLViewerRegion* regionp);
 };
 
 #endif // LL_LLMATERIALMGR_H
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 8422708add..a4f6340d9e 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1219,7 +1219,7 @@ void LLViewerRegion::getInfo(LLSD& info)
 	info["Region"]["Handle"]["y"] = (LLSD::Integer)y;
 }
 
-void LLViewerRegion::getSimulatorFeatures(LLSD& sim_features)
+void LLViewerRegion::getSimulatorFeatures(LLSD& sim_features) const
 {
 	sim_features = mSimulatorFeatures;
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 56cd0c9ea1..031159183b 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -293,7 +293,7 @@ public:
 	bool meshRezEnabled() const;
 	bool meshUploadEnabled() const;
 
-	void getSimulatorFeatures(LLSD& info);	
+	void getSimulatorFeatures(LLSD& info) const;	
 	void setSimulatorFeatures(const LLSD& info);
 
 	
-- 
cgit v1.2.3


From 5595888dd23b0ac526fc520eb20de6e11a2b62ee Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 26 Jun 2013 11:52:10 -0500
Subject: NORSPEC-290 Allow shader compiler to unroll loop in multiPointLightF

---
 .../shaders/class1/deferred/multiPointLightF.glsl  | 91 +++++++++-------------
 indra/newview/featuretable_mac.txt                 |  4 +-
 indra/newview/llface.cpp                           |  6 --
 indra/newview/llviewershadermgr.cpp                | 27 ++++---
 indra/newview/llviewershadermgr.h                  |  4 +-
 indra/newview/pipeline.cpp                         | 19 +++--
 6 files changed, 69 insertions(+), 82 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 868526d457..6612892f6e 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -45,9 +45,8 @@ uniform float sun_wash;
 
 uniform int light_count;
 
-#define MAX_LIGHT_COUNT		16
-uniform vec4 light[MAX_LIGHT_COUNT];
-uniform vec4 light_col[MAX_LIGHT_COUNT];
+uniform vec4 light[LIGHT_COUNT];
+uniform vec4 light_col[LIGHT_COUNT];
 
 VARYING vec4 vary_fragcoord;
 uniform vec2 screen_res;
@@ -122,73 +121,59 @@ void main()
 	vec3 npos = normalize(-pos);
 
 	// As of OSX 10.6.7 ATI Apple's crash when using a variable size loop
-	for (int i = 0; i < MAX_LIGHT_COUNT; ++i)
+	for (int i = 0; i < LIGHT_COUNT; ++i)
 	{
-		bool light_contrib = (i < light_count);
-		
 		vec3 lv = light[i].xyz-pos;
 		float dist = length(lv);
 		dist /= light[i].w;
-		if (dist > 1.0)
+		if (dist <= 1.0)
 		{
-			light_contrib = false;
-		}
-		
-		float da = dot(norm, lv);
-		if (da < 0.0)
-		{
-			light_contrib = false;
-		}
-		
-		if (light_contrib)
-		{
-			lv = normalize(lv);
-			da = dot(norm, lv);
+			float da = dot(norm, lv);
+			if (da > 0.0)
+			{
+				lv = normalize(lv);
+				da = dot(norm, lv);
 			
-			float fa = light_col[i].a+1.0;
-			float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
-			dist_atten *= dist_atten;
-			dist_atten *= 2.0;
+				float fa = light_col[i].a+1.0;
+				float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
+				dist_atten *= dist_atten;
+				dist_atten *= 2.0;
 			
-			dist_atten *= noise;
+				dist_atten *= noise;
 
-			float lit = da * dist_atten;
+				float lit = da * dist_atten;
 						
-			vec3 col = light_col[i].rgb*lit*diff;
+				vec3 col = light_col[i].rgb*lit*diff;
 			
-			//vec3 col = vec3(dist2, light_col[i].a, lit);
+				//vec3 col = vec3(dist2, light_col[i].a, lit);
 			
-			if (spec.a > 0.0)
-			{
-				lit = min(da*6.0, 1.0) * dist_atten;
-				//vec3 ref = dot(pos+lv, norm);
-				vec3 h = normalize(lv+npos);
-				float nh = dot(norm, h);
-				float nv = dot(norm, npos);
-				float vh = dot(npos, h);
-				float sa = nh;
-				float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
-
-				float gtdenom = 2 * nh;
-				float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
-								
-				if (nh > 0.0)
+				if (spec.a > 0.0)
 				{
-					float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
-					col += lit*scol*light_col[i].rgb*spec.rgb;
-					//col += spec.rgb;
+					lit = min(da*6.0, 1.0) * dist_atten;
+					//vec3 ref = dot(pos+lv, norm);
+					vec3 h = normalize(lv+npos);
+					float nh = dot(norm, h);
+					float nv = dot(norm, npos);
+					float vh = dot(npos, h);
+					float sa = nh;
+					float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
+
+					float gtdenom = 2 * nh;
+					float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
+								
+					if (nh > 0.0)
+					{
+						float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+						col += lit*scol*light_col[i].rgb*spec.rgb;
+						//col += spec.rgb;
+					}
 				}
-			}
 			
-			out_col += col;
+				out_col += col;
+			}
 		}
 	}
 	
-	if (dot(out_col, out_col) <= 0.0)
-	{
-		discard;
-	}
-	
 	frag_color.rgb = out_col;
 	frag_color.a = 0.0;
 }
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index 1c0d45c11b..0bdd425504 100755
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -309,8 +309,8 @@ RenderVolumeLODFactor		1	2.0
 VertexShaderEnable			1	1
 WindLightUseAtmosShaders	1	1
 WLSkyDetail					1	128
-RenderDeferred				1	0
-RenderDeferredSSAO			1	0
+RenderDeferred				1	1
+RenderDeferredSSAO			1	1
 RenderShadowDetail			1	2
 RenderFSAASamples			1	2
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index f021f4ed0f..700b31f8d3 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -817,12 +817,6 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 			size.mul(scale);
 		}
 
-		// Catch potential badness from normalization before it happens
-		//
-		llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO));
-		llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO));
-		llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO));
-
 		mat_normal.mMatrix[0].normalize3fast();
 		mat_normal.mMatrix[1].normalize3fast();
 		mat_normal.mMatrix[2].normalize3fast();
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e24237522a..e4f04a414d 100755
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -199,7 +199,7 @@ LLGLSLShader			gDeferredTreeShadowProgram;
 LLGLSLShader			gDeferredAvatarProgram;
 LLGLSLShader			gDeferredAvatarAlphaProgram;
 LLGLSLShader			gDeferredLightProgram;
-LLGLSLShader			gDeferredMultiLightProgram;
+LLGLSLShader			gDeferredMultiLightProgram[16];
 LLGLSLShader			gDeferredSpotLightProgram;
 LLGLSLShader			gDeferredMultiSpotLightProgram;
 LLGLSLShader			gDeferredSunProgram;
@@ -1128,7 +1128,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredImpostorProgram.unload();
 		gDeferredTerrainProgram.unload();
 		gDeferredLightProgram.unload();
-		gDeferredMultiLightProgram.unload();
+		for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; ++i)
+		{
+			gDeferredMultiLightProgram[i].unload();
+		}
 		gDeferredSpotLightProgram.unload();
 		gDeferredMultiSpotLightProgram.unload();
 		gDeferredSunProgram.unload();
@@ -1373,17 +1376,21 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		success = gDeferredLightProgram.createShader(NULL, NULL);
 	}
 
-	if (success)
+	for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; i++)
 	{
-		gDeferredMultiLightProgram.mName = "Deferred MultiLight Shader";
-		gDeferredMultiLightProgram.mShaderFiles.clear();
-		gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB));
-		gDeferredMultiLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
-		gDeferredMultiLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+		if (success)
+		{
+			gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i);
+			gDeferredMultiLightProgram[i].mShaderFiles.clear();
+			gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB));
+			gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
+			gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+			gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1));
 
-		SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram);
+			SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram[i]);
 
-		success = gDeferredMultiLightProgram.createShader(NULL, NULL);
+			success = gDeferredMultiLightProgram[i].createShader(NULL, NULL);
+		}
 	}
 
 	if (success)
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 438853cd6f..ed8167947d 100755
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -30,6 +30,8 @@
 #include "llshadermgr.h"
 #include "llmaterial.h"
 
+#define LL_DEFERRED_MULTI_LIGHT_COUNT 16
+
 class LLViewerShaderMgr: public LLShaderMgr
 {
 public:
@@ -341,7 +343,7 @@ extern LLGLSLShader			gDeferredTerrainProgram;
 extern LLGLSLShader			gDeferredTreeProgram;
 extern LLGLSLShader			gDeferredTreeShadowProgram;
 extern LLGLSLShader			gDeferredLightProgram;
-extern LLGLSLShader			gDeferredMultiLightProgram;
+extern LLGLSLShader			gDeferredMultiLightProgram[LL_DEFERRED_MULTI_LIGHT_COUNT];
 extern LLGLSLShader			gDeferredSpotLightProgram;
 extern LLGLSLShader			gDeferredMultiSpotLightProgram;
 extern LLGLSLShader			gDeferredSunProgram;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4801c52209..2eeedc8214 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8672,10 +8672,6 @@ void LLPipeline::renderDeferredLighting()
 			vert[2].set(3,1,0);
 
 			{
-				bindDeferredShader(gDeferredMultiLightProgram);
-			
-				mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
-
 				LLGLDepthTest depth(GL_FALSE);
 
 				//full screen blit
@@ -8687,7 +8683,7 @@ void LLPipeline::renderDeferredLighting()
 
 				U32 count = 0;
 
-				const U32 max_count = 8;
+				const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT;
 				LLVector4 light[max_count];
 				LLVector4 col[max_count];
 
@@ -8710,17 +8706,20 @@ void LLPipeline::renderDeferredLighting()
 					count++;
 					if (count == max_count || fullscreen_lights.empty())
 					{
-						gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count);
-						gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light);
-						gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col);
-						gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z);
+						U32 idx = count-1;
+						bindDeferredShader(gDeferredMultiLightProgram[idx]);
+						gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count);
+						gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light);
+						gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col);
+						gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z);
 						far_z = 0.f;
 						count = 0; 
+						mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 						mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
 					}
 				}
 				
-				unbindDeferredShader(gDeferredMultiLightProgram);
+				unbindDeferredShader(gDeferredMultiLightProgram[0]);
 
 				bindDeferredShader(gDeferredMultiSpotLightProgram);
 
-- 
cgit v1.2.3


From 2b5205c74395ca67dde8c2978e26c2e2d5d41b97 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 26 Jun 2013 15:33:07 -0500
Subject: Merge cleanup.

---
 indra/newview/llviewershadermgr.cpp | 2 --
 1 file changed, 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index d195971c03..7bce629d3e 100755
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1366,8 +1366,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 			gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB));
 			gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 			gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1));
-
-			SINGLE_FP_PERMUTATION(gDeferredMultiLightProgram[i]);
 			success = gDeferredMultiLightProgram[i].createShader(NULL, NULL);
 		}
 	}
-- 
cgit v1.2.3


From 06b024f60e6953f3b1de08523b511e0f0a777531 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 26 Jun 2013 19:16:49 -0500
Subject: MATBUG-194 Fix for crazy colors on projector shadows with NVIDIA
 OpenGL 3.3 implementations

---
 .../app_settings/shaders/class2/deferred/multiSpotLightF.glsl        | 4 ++++
 indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl   | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 0deb4fe3b6..14f6afc8c2 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -318,6 +318,10 @@ void main()
 		}
 	}
 	
+
+	//not sure why, but this line prevents MATBUG-194
+	col = max(col, vec3(0.0));
+
 	frag_color.rgb = col;	
 	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 7a4337c277..6e0218cb9c 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -315,7 +315,10 @@ void main()
 			}
 		}
 	}
-	
+
+	//not sure why, but this line prevents MATBUG-194
+	col = max(col, vec3(0.0));
+
 	frag_color.rgb = col;	
 	frag_color.a = 0.0;
 }
-- 
cgit v1.2.3


From 7df863265f6f536aeae84dceab9140fb4465213c Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 28 Jun 2013 13:32:01 -0500
Subject: NORSPEC-290 Shader optimization WIP -- remove a couple normalizes,
 pows, and divides from various lighting functions.

---
 indra/llrender/llrender.cpp                        |   2 +-
 .../shaders/class1/deferred/alphaF.glsl            |  51 +++--
 .../shaders/class1/deferred/alphaNonIndexedF.glsl  | 150 -------------
 .../class1/deferred/alphaNonIndexedNoColorF.glsl   |  92 --------
 .../shaders/class1/deferred/alphaSkinnedV.glsl     | 136 ------------
 .../shaders/class1/deferred/alphaV.glsl            |  37 +---
 .../class1/deferred/avatarAlphaNoColorV.glsl       |  10 +-
 .../shaders/class1/deferred/avatarAlphaV.glsl      | 153 -------------
 .../shaders/class1/deferred/materialF.glsl         |   8 +-
 .../shaders/class1/lighting/lightFuncV.glsl        |   2 +-
 .../shaders/class1/objects/previewV.glsl           |   4 +-
 .../shaders/class2/deferred/alphaNonIndexedF.glsl  | 235 --------------------
 .../class2/deferred/alphaNonIndexedNoColorF.glsl   | 242 ---------------------
 .../shaders/class2/deferred/alphaSkinnedV.glsl     | 156 -------------
 .../shaders/class2/deferred/alphaV.glsl            | 224 -------------------
 .../shaders/class2/deferred/avatarAlphaV.glsl      | 153 -------------
 indra/newview/pipeline.cpp                         |   4 +-
 17 files changed, 46 insertions(+), 1613 deletions(-)
 delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
 delete mode 100755 indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl

(limited to 'indra')

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index b22ad60750..c4585936ee 100755
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1150,7 +1150,7 @@ void LLRender::syncLightState()
 
 			position[i] = light->mPosition;
 			direction[i] = light->mSpotDirection;
-			attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]);
+			attenuation[i].set(1.f/light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]);
 			diffuse[i].set(light->mDiffuse.mV);
 		}
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 143af0576c..af3f362208 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -61,6 +61,7 @@ VARYING vec3 vary_directional;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
 VARYING vec3 vary_pointlight_col;
+VARYING vec3 vary_pointlight_col_linear;
 VARYING vec2 vary_texcoord0;
 VARYING vec3 vary_norm;
 
@@ -82,7 +83,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l)
 	return vec3(a,a,a);
 }
 
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
 {
 	//get light vector
 	vec3 lv = lp.xyz-v;
@@ -92,14 +93,14 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float
 	
 	float da = 0.0;
 
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
+//	if (d > 0.0 && la > 0.0 && fa > 0.0)
 	{
 		//normalize light vector
-		lv = normalize(lv);
+		lv /= d;
 	
 		//distance attenuation
-		float dist = d/la;
-		da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		float dist = d*la;
+		da = clamp(1.0-(dist+fa-1.0)/fa, 0.0, 1.0);
 		da *= da;
 		da *= 2.0;
 	
@@ -112,7 +113,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float
 		da *= max(dot(n, lv), 0.0);		
 	}
 
-	return vec3(da,da,da);	
+	return da;	
 }
 
 #if HAS_SHADOW
@@ -138,6 +139,25 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
 
 void main() 
 {
+#ifdef USE_INDEXED_TEX
+	vec4 diff = diffuseLookup(vary_texcoord0.xy);
+#else
+	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
+#endif
+
+#ifdef USE_VERTEX_COLOR
+	float vertex_color_alpha = vertex_color.a;	
+#else
+	float vertex_color_alpha = 1.0;
+#endif
+
+	float alpha = vertex_color_alpha*diff.a;
+
+	vec4 gamma_diff = diff;
+
+	diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f));
+
+
 	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
 	frag *= screen_res;
 	
@@ -210,21 +230,6 @@ void main()
 	}
 #endif
 
-#ifdef USE_INDEXED_TEX
-	vec4 diff = diffuseLookup(vary_texcoord0.xy);
-#else
-	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
-#endif
-	vec4 gamma_diff = diff;
-
-	diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f));
-
-#ifdef USE_VERTEX_COLOR
-	float vertex_color_alpha = vertex_color.a;	
-#else
-	float vertex_color_alpha = 1.0;
-#endif
-	
 	vec3 normal = vary_norm; 
 	
 	vec3 l = light_position[0].xyz;
@@ -243,6 +248,7 @@ void main()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
+	//convert to linear space
 	color.rgb = pow(color.rgb, vec3(2.2));
 	col = vec4(0,0,0,0);
 
@@ -257,8 +263,9 @@ void main()
 	LIGHT_LOOP(6)
 	LIGHT_LOOP(7)
 
-	color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb;
+	color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb;
 
+	//convert to gamma space
 	color.rgb = pow(color.rgb, vec3(1.0/2.2));
 
 	frag_color = color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
deleted file mode 100755
index 2ce44d599f..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ /dev/null
@@ -1,150 +0,0 @@
-/** 
- * @file alphaF.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
- 
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-VARYING vec4 vertex_color;
-VARYING vec3 vary_norm;
-
-uniform mat4 inv_proj;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-vec3 calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = pow(max(dot(n,l),0.0), 0.7);
-        return vec3(a,a,a);
-}
-
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(pow(dot(n, lv), 0.7), 0.0);		
-	}
-
-	return vec3(da,da,da);	
-}
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
-
-void main() 
-{
-	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
-	frag *= screen_res;
-	
-	vec4 pos = vec4(vary_position, 1.0);
-	
-	vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy);
-
-	vec3 n = vary_norm;
-	vec3 l = light_position[0].xyz;
-	vec3 dlight = calcDirectionalLight(n, l);
-	dlight = dlight * vary_directional.rgb * vary_pointlight_col;
-
-	vec4 col = vec4(vary_ambient + dlight, vertex_color.a);
-	vec4 color = diff * col;
-	
-	color.rgb = atmosLighting(color.rgb);
-
-	color.rgb = scaleSoftClip(color.rgb);
-	vec3 light_col = vec3(0,0,0);
-
-  #define LIGHT_LOOP(i) \
-	light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
-
-	LIGHT_LOOP(1)
-	LIGHT_LOOP(2)
-	LIGHT_LOOP(3)
-	LIGHT_LOOP(4)
-	LIGHT_LOOP(5)
-	LIGHT_LOOP(6)
-	LIGHT_LOOP(7)
-
-	color.rgb += diff.rgb * vary_pointlight_col * light_col;
-
-	color.rgb = pow(color.rgb, vec3(1.0/2.2));
-
-	frag_color = color;
-	//frag_color = vec4(1,0,1,1);
-	//frag_color = vec4(1,0,1,1)*shadow;
-	
-}
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
deleted file mode 100755
index 1113a9845b..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
+++ /dev/null
@@ -1,92 +0,0 @@
-/** 
- * @file alphaNonIndexedNoColorF.glsl
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2005, 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$
- */
- 
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform float minimum_alpha;
-
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-
-uniform mat4 inv_proj;
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
-
-void main() 
-{
-	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
-	frag *= screen_res;
-	
-	vec4 pos = vec4(vary_position, 1.0);
-	
-	vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy);
-
-	if (diff.a < minimum_alpha)
-	{
-		discard;
-	}
-
-	vec4 col = vec4(vary_ambient + vary_directional.rgb, 1.0);
-	vec4 color = diff * col;
-	
-	
-	color.rgb = atmosLighting(color.rgb);
-
-	color.rgb = scaleSoftClip(color.rgb);
-
-	color.rgb += diff.rgb * vary_pointlight_col.rgb;
-
-	frag_color = color;
-}
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
deleted file mode 100755
index 5f93986f1d..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ /dev/null
@@ -1,136 +0,0 @@
-/** 
- * @file alphaSkinnedV.glsl
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
-
-uniform mat4 projection_matrix;
-uniform mat4 modelview_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec2 texcoord0;
-
-mat4 getObjectSkinnedTransform();
-void calcAtmospherics(vec3 inPositionEye);
-
-float calcDirectionalLight(vec3 n, vec3 l);
-
-vec3 atmosAmbient(vec3 light);
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-
-VARYING vec3 vary_position;
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_pointlight_col;
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-VARYING vec3 vary_norm;
-
-uniform float near_clip;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = max(dot(n,l),0.0);
-        return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return da;	
-}
-
-void main()
-{
-	vary_texcoord0 = texcoord0;
-				
-	vec4 pos;
-	vec3 norm;
-	
-	mat4 trans = getObjectSkinnedTransform();
-	trans = modelview_matrix * trans;
-	
-	pos = trans * vec4(position.xyz, 1.0);
-	
-	norm = position.xyz + normal.xyz;
-	norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz);
-	vary_norm = norm;
-	vec4 frag_pos = projection_matrix * pos;
-	gl_Position = frag_pos;
-	
-	vary_position = pos.xyz;
-		
-	calcAtmospherics(pos.xyz);
-
-	//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
-	vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-	vary_pointlight_col = diffuse_color.rgb;
-	col.rgb = vec3(0,0,0);
-
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	
-	vary_ambient = col.rgb*diffuse_color.rgb;
-	vary_directional.rgb = atmosAffectDirectionalLight(1);
-	
-	col.rgb = col.rgb*diffuse_color.rgb;
-	
-	vertex_color = col;
-
-	
-	
-	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-}
-
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 9d3ba564cd..cc63baa422 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -68,6 +68,7 @@ VARYING vec3 vary_directional;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
 VARYING vec3 vary_pointlight_col;
+VARYING vec3 vary_pointlight_col_linear;
 
 #ifdef USE_VERTEX_COLOR
 VARYING vec4 vertex_color;
@@ -79,43 +80,8 @@ VARYING vec3 vary_norm;
 
 uniform float near_clip;
 
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
 uniform vec3 sun_dir;
 
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return vec3(da,da,da);	
-}
-
 void main()
 {
 	vec4 pos;
@@ -181,6 +147,7 @@ void main()
 	
 
 	vary_pointlight_col = diff;
+	vary_pointlight_col_linear = pow(diff, vec3(2.2));
 
 	
 	col.rgb = vec3(0,0,0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
index c8ddefac26..145cf524d4 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
@@ -71,18 +71,18 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	vec3 lv = lp.xyz-v;
 	
 	//get distance
-	float d = dot(lv,lv);
+	float d = length(lv);
 	
 	float da = 0.0;
 
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	//if (d > 0.0 && la > 0.0 && fa > 0.0)
 	{
 		//normalize light vector
-		lv = normalize(lv);
+		lv /= d;
 	
 		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		float dist = d*la;
+		da = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0);
 
 		// spotlight coefficient.
 		float spot = max(dot(-ln, lv), is_pointlight);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
deleted file mode 100755
index d6149fcc32..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ /dev/null
@@ -1,153 +0,0 @@
-/** 
- * @file avatarAlphaV.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
-
-uniform mat4 projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec2 texcoord0;
-
-vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
-mat4 getSkinnedTransform();
-void calcAtmospherics(vec3 inPositionEye);
-
-float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
-
-vec3 atmosAmbient(vec3 light);
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-vec3 scaleDownLight(vec3 light);
-vec3 scaleUpLight(vec3 light);
-
-VARYING vec3 vary_position;
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_pointlight_col;
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-
-uniform float near_clip;
-
-uniform vec4 color;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = max(dot(n,l),0.0);
-        return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return da;	
-}
-
-void main()
-{
-	vary_texcoord0 = texcoord0;
-				
-	vec4 pos;
-	vec3 norm;
-	
-	mat4 trans = getSkinnedTransform();
-	vec4 pos_in = vec4(position.xyz, 1.0);
-	pos.x = dot(trans[0], pos_in);
-	pos.y = dot(trans[1], pos_in);
-	pos.z = dot(trans[2], pos_in);
-	pos.w = 1.0;
-	
-	norm.x = dot(trans[0].xyz, normal);
-	norm.y = dot(trans[1].xyz, normal);
-	norm.z = dot(trans[2].xyz, normal);
-	norm = normalize(norm);
-		
-	vec4 frag_pos = projection_matrix * pos;
-	gl_Position = frag_pos;
-	
-	vary_position = pos.xyz;
-	
-	calcAtmospherics(pos.xyz);
-
-	vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
-
-	// Collect normal lights
-	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
-	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
-	col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
-	col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
-	col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
-	col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-	
-	vary_pointlight_col = col.rgb*color.rgb;
-
-	col.rgb = vec3(0,0,0);
-
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	
-	vary_ambient = col.rgb*color.rgb;
-	vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
-	
-	col.rgb = col.rgb * color.rgb;
-	
-	vertex_color = col;
-
-	
-	
-	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-}
-
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 53ade8ea64..27bb43110b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -133,14 +133,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
 
 	vec3 col = vec3(0,0,0);
 
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	//if (d > 0.0 && la > 0.0 && fa > 0.0)
 	{
 		//normalize light vector
-		lv = normalize(lv);
+		lv /= d;
 	
 		//distance attenuation
-		float dist = d/la;
-		float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		float dist = d*la;
+		float dist_atten = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0);
 		dist_atten *= dist_atten;
 		dist_atten *= 2.0;
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index a9288b3df6..dc0b989e34 100755
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -45,7 +45,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	lv *= 1.0/d;
 	
 	//distance attenuation
-	float da = clamp(1.0/(la * d), 0.0, 1.0);
+	float da = clamp(1.0/(1.f/la * d), 0.0, 1.0);
 	
 	// spotlight coefficient.
 	float spot = max(dot(-ln, lv), is_pointlight);
diff --git a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
index 7f3f84398b..c325a236d7 100755
--- a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
@@ -91,8 +91,8 @@ void main()
 
 	// Collect normal lights (need to be divided by two, as we later multiply by 2)
 	col.rgb += light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz);
-	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z);
-	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z);
+	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], 1.f/light_attenuation[2].x, light_attenuation[2].z);
+	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], 1.f/light_attenuation[3].x, light_attenuation[3].z);
 		
 	vertex_color = col*color;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
deleted file mode 100755
index 9670d59399..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ /dev/null
@@ -1,235 +0,0 @@
-/** 
- * @file alphaF.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
- 
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform sampler2DShadow shadowMap0;
-uniform sampler2DShadow shadowMap1;
-uniform sampler2DShadow shadowMap2;
-uniform sampler2DShadow shadowMap3;
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-VARYING vec4 vertex_color;
-VARYING vec3 vary_norm;
-
-uniform vec2 shadow_res;
-uniform float shadow_bias;
-
-uniform mat4 inv_proj;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-vec3 calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = pow(max(dot(n,l),0.0), 0.7);
-        return vec3(a,a,a);
-}
-
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(pow(dot(n, lv), 0.7), 0.0);		
-	}
-
-	return vec3(da,da,da);	
-}
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos.xyz /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
-
-float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
-{
-	stc.xyz /= stc.w;
-	stc.z += shadow_bias;
-
-	stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
-	
-	float cs = shadow2D(shadowMap, stc.xyz).x;
-	float shadow = cs;
-	
-    shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
-    shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-    shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
-    shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-                        
-    return shadow*0.2;
-}
-
-
-void main() 
-{
-	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
-	frag *= screen_res;
-	
-	float shadow = 0.0;
-	vec4 pos = vec4(vary_position, 1.0);
-	
-	vec4 spos = pos;
-		
-	if (spos.z > -shadow_clip.w)
-	{	
-		vec4 lpos;
-		
-		vec4 near_split = shadow_clip*-0.75;
-		vec4 far_split = shadow_clip*-1.25;
-		vec4 transition_domain = near_split-far_split;
-		float weight = 0.0;
-
-		if (spos.z < near_split.z)
-		{
-			lpos = shadow_matrix[3]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
-			shadow += pcfShadow(shadowMap3, lpos)*w;
-			weight += w;
-			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
-		}
-
-		if (spos.z < near_split.y && spos.z > far_split.z)
-		{
-			lpos = shadow_matrix[2]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
-			w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
-			shadow += pcfShadow(shadowMap2, lpos)*w;
-			weight += w;
-		}
-
-		if (spos.z < near_split.x && spos.z > far_split.y)
-		{
-			lpos = shadow_matrix[1]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
-			w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
-			shadow += pcfShadow(shadowMap1, lpos)*w;
-			weight += w;
-		}
-
-		if (spos.z > far_split.x)
-		{
-			lpos = shadow_matrix[0]*spos;
-							
-			float w = 1.0;
-			w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
-				
-			shadow += pcfShadow(shadowMap0, lpos)*w;
-			weight += w;
-		}
-		
-
-		shadow /= weight;
-
-	}
-	else
-	{
-		shadow = 1.0;
-	}
-	vec3 n = vary_norm;
-	vec3 l = light_position[0].xyz;
-	vec3 dlight = calcDirectionalLight(n, l);
-	dlight = dlight * vary_directional.rgb * vary_pointlight_col;
-	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
-
-	vec4 col = vec4(vary_ambient + dlight*shadow, vertex_color.a);
-	vec4 color = diff * col;
-	
-	color.rgb = atmosLighting(color.rgb);
-
-	color.rgb = scaleSoftClip(color.rgb);
-	vec3 light_col = vec3(0,0,0);
-
-  #define LIGHT_LOOP(i) \
-		light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
-
-	LIGHT_LOOP(1)
-	LIGHT_LOOP(2)
-	LIGHT_LOOP(3)
-	LIGHT_LOOP(4)
-	LIGHT_LOOP(5)
-	LIGHT_LOOP(6)
-	LIGHT_LOOP(7)
-
-	color.rgb += diff.rgb * vary_pointlight_col * light_col;
-
-	frag_color = color;	
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
deleted file mode 100755
index fae279fba0..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
+++ /dev/null
@@ -1,242 +0,0 @@
-/** 
- * @file alphaNonIndexedNoColorF.glsl
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2005, 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$
- */
- 
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform float minimum_alpha;
-
-uniform sampler2DShadow shadowMap0;
-uniform sampler2DShadow shadowMap1;
-uniform sampler2DShadow shadowMap2;
-uniform sampler2DShadow shadowMap3;
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-VARYING vec3 vary_norm;
-
-uniform vec2 shadow_res;
-
-uniform float shadow_bias;
-
-uniform mat4 inv_proj;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-vec3 calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = pow(max(dot(n,l),0.0), 0.7);
-        return vec3(a, a, a);
-}
-
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(pow(dot(n, lv), 0.7), 0.0);		
-	}
-
-	return vec3(da,da,da);	
-}
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos.xyz /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
-
-float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
-{
-	stc.xyz /= stc.w;
-	stc.z += shadow_bias;
-
-	stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
-	float cs = shadow2D(shadowMap, stc.xyz).x;
-	
-	float shadow = cs;
-
-        shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
-        shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-        shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
-        shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-                        
-        return shadow*0.2;
-}
-
-
-void main() 
-{
-	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
-	frag *= screen_res;
-	
-	float shadow = 0.0;
-	vec4 pos = vec4(vary_position, 1.0);
-	
-	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
-
-	if (diff.a < minimum_alpha)
-	{
-		discard;
-	}
-	
-	vec4 spos = pos;
-		
-	if (spos.z > -shadow_clip.w)
-	{	
-		vec4 lpos;
-		
-		vec4 near_split = shadow_clip*-0.75;
-		vec4 far_split = shadow_clip*-1.25;
-		vec4 transition_domain = near_split-far_split;
-		float weight = 0.0;
-
-		if (spos.z < near_split.z)
-		{
-			lpos = shadow_matrix[3]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
-			shadow += pcfShadow(shadowMap3, lpos)*w;
-			weight += w;
-			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
-		}
-
-		if (spos.z < near_split.y && spos.z > far_split.z)
-		{
-			lpos = shadow_matrix[2]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
-			w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
-			shadow += pcfShadow(shadowMap2, lpos)*w;
-			weight += w;
-		}
-
-		if (spos.z < near_split.x && spos.z > far_split.y)
-		{
-			lpos = shadow_matrix[1]*spos;
-			
-			float w = 1.0;
-			w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
-			w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
-			shadow += pcfShadow(shadowMap1, lpos)*w;
-			weight += w;
-		}
-
-		if (spos.z > far_split.x)
-		{
-			lpos = shadow_matrix[0]*spos;
-							
-			float w = 1.0;
-			w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
-				
-			shadow += pcfShadow(shadowMap0, lpos)*w;
-			weight += w;
-		}
-		
-
-		shadow /= weight;
-	}
-	else
-	{
-		shadow = 1.0;
-	}
-	vec3 n = vary_norm;
-	vec3 l = light_position[0].xyz;
-	vec3 dlight = calcDirectionalLight(n, l);
-	dlight = dlight * vary_directional.rgb * vary_pointlight_col;
-	
-	vec4 col = vec4(vary_ambient + dlight*shadow, 1.0);
-	vec4 color = diff * col;
-	
-	color.rgb = atmosLighting(color.rgb);
-
-	color.rgb = scaleSoftClip(color.rgb);
-	vec3 light_col = vec3(0,0,0);
-
-  #define LIGHT_LOOP(i) \
-		light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
-
-	LIGHT_LOOP(1)
-	LIGHT_LOOP(2)
-	LIGHT_LOOP(3)
-	LIGHT_LOOP(4)
-	LIGHT_LOOP(5)
-	LIGHT_LOOP(6)
-	LIGHT_LOOP(7)
-
-	color.rgb += diff.rgb * vary_pointlight_col * light_col;
-
-	frag_color = color;
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
deleted file mode 100755
index 7f4d82ecc6..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
+++ /dev/null
@@ -1,156 +0,0 @@
-/** 
- * @file alphaSkinnedV.glsl
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
-
-uniform mat4 projection_matrix;
-uniform mat4 texture_matrix0;
-uniform mat4 modelview_matrix;
-uniform mat4 modelview_projection_matrix;
- 
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec2 texcoord0;
-
-vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
-void calcAtmospherics(vec3 inPositionEye);
-
-float calcDirectionalLight(vec3 n, vec3 l);
-mat4 getObjectSkinnedTransform();
-vec3 atmosAmbient(vec3 light);
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-vec3 scaleDownLight(vec3 light);
-vec3 scaleUpLight(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-VARYING vec3 vary_norm;
-
-uniform float near_clip;
-uniform float shadow_offset;
-uniform float shadow_bias;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = max(dot(n,l),0.0);
-        return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return da;	
-}
-
-void main()
-{
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-	
-	mat4 mat = getObjectSkinnedTransform();
-	
-	mat = modelview_matrix * mat;
-	
-	vec3 pos = (mat*vec4(position, 1.0)).xyz;
-	
-	gl_Position = projection_matrix * vec4(pos, 1.0);
-	
-	vec4 n = vec4(position, 1.0);
-	n.xyz += normal.xyz;
-	n.xyz = (mat*n).xyz;
-	n.xyz = normalize(n.xyz-pos.xyz);
-	
-	vec3 norm = n.xyz;
-	vary_norm = norm;
-
-	float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz));
-	vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset;
-			
-	calcAtmospherics(pos.xyz);
-
-	//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
-	vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-
-	// Collect normal lights
-	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
-	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
-	col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
-	col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
-	col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
-	col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-	
-	vary_pointlight_col = col.rgb*diffuse_color.rgb;
-
-	col.rgb = vec3(0,0,0);
-
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-		
-	vary_ambient = col.rgb*diffuse_color.rgb;
-	vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
-	
-	col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
-	
-	vertex_color = col;
-
-	
-	
-	pos.xyz = (modelview_projection_matrix * vec4(position.xyz, 1.0)).xyz;
-	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
-	
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
deleted file mode 100755
index 13c6ffc607..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ /dev/null
@@ -1,224 +0,0 @@
-/** 
- * @file alphaV.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
-
-uniform mat3 normal_matrix;
-uniform mat4 texture_matrix0;
-uniform mat4 projection_matrix;
-uniform mat4 modelview_matrix;
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-#ifdef USE_INDEXED_TEX
-void passTextureIndex();
-#endif
-
-ATTRIBUTE vec3 normal;
-
-#ifdef USE_VERTEX_COLOR
-ATTRIBUTE vec4 diffuse_color;
-#endif
-
-ATTRIBUTE vec2 texcoord0;
-
-#ifdef HAS_SKIN
-mat4 getObjectSkinnedTransform();
-#else
-#ifdef IS_AVATAR_SKIN
-mat4 getSkinnedTransform();
-#endif
-#endif
-
-vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
-void calcAtmospherics(vec3 inPositionEye);
-
-vec3 calcDirectionalLight(vec3 n, vec3 l);
-
-vec3 atmosAmbient(vec3 light);
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-vec3 scaleDownLight(vec3 light);
-vec3 scaleUpLight(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-
-#ifdef USE_VERTEX_COLOR
-VARYING vec4 vertex_color;
-#endif
-
-VARYING vec2 vary_texcoord0;
-VARYING vec3 vary_norm;
-
-uniform float near_clip;
-uniform float shadow_offset;
-uniform float shadow_bias;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-uniform vec3 sun_dir;
-
-vec3 calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = max(dot(n,l),0.0);
-        return vec3(a,a,a);
-}
-
-vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return vec3(da,da,da);	
-}
-
-void main()
-{
-	vec4 pos;
-	vec3 norm;
-	
-	//transform vertex
-#ifdef HAS_SKIN
-	mat4 trans = getObjectSkinnedTransform();
-	trans = modelview_matrix * trans;
-	
-	pos = trans * vec4(position.xyz, 1.0);
-	
-	norm = position.xyz + normal.xyz;
-	norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz);
-	vec4 frag_pos = projection_matrix * pos;
-	gl_Position = frag_pos;
-#else
-
-#ifdef IS_AVATAR_SKIN
-	mat4 trans = getSkinnedTransform();
-	vec4 pos_in = vec4(position.xyz, 1.0);
-	pos.x = dot(trans[0], pos_in);
-	pos.y = dot(trans[1], pos_in);
-	pos.z = dot(trans[2], pos_in);
-	pos.w = 1.0;
-	
-	norm.x = dot(trans[0].xyz, normal);
-	norm.y = dot(trans[1].xyz, normal);
-	norm.z = dot(trans[2].xyz, normal);
-	norm = normalize(norm);
-	
-	vec4 frag_pos = projection_matrix * pos;
-	gl_Position = frag_pos;
-#else
-	norm = normalize(normal_matrix * normal);
-	vec4 vert = vec4(position.xyz, 1.0);
-	pos = (modelview_matrix * vert);
-	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
-#endif
-	
-#endif
-
-#ifdef USE_INDEXED_TEX
-	passTextureIndex();
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-#else
-	vary_texcoord0 = texcoord0;
-#endif
-	
-	vary_norm = norm;
-	float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz));
-	vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset;
-	
-	calcAtmospherics(pos.xyz);
-
-#ifndef USE_VERTEX_COLOR
-	vec4 diffuse_color = vec4(1,1,1,1);
-#endif
-
-	//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
-	vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-
-	vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f));
-
-	vary_pointlight_col = dff;
-
-	col.rgb = vec3(0,0,0);
-
-	// Add windlight lights
-	col.rgb = atmosAmbient(col.rgb);
-	
-	float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
-	ambient *= 0.5;
-	ambient *= ambient;
-	ambient = (1.0-ambient);
-
-	col.rgb *= ambient;
-
-	vary_directional.rgb = atmosAffectDirectionalLight(1.0f);
-	vary_ambient = col.rgb*dff;
-	
-	col.rgb = col.rgb*dff;
-	
-#ifdef USE_VERTEX_COLOR
-	vertex_color = col;
-#endif
-	
-#ifdef HAS_SKIN
-	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-#else
-
-#ifdef IS_AVATAR_SKIN
-	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
-#else
-	pos = modelview_projection_matrix * vert;
-	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
-#endif
-
-#endif
-
-}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
deleted file mode 100755
index 44aaa98b97..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ /dev/null
@@ -1,153 +0,0 @@
-/** 
- * @file avatarAlphaV.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
- 
-uniform mat4 projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec2 texcoord0;
-
-vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
-mat4 getSkinnedTransform();
-void calcAtmospherics(vec3 inPositionEye);
-
-float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
-
-vec3 atmosAmbient(vec3 light);
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-vec3 scaleDownLight(vec3 light);
-vec3 scaleUpLight(vec3 light);
-
-VARYING vec3 vary_position;
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_pointlight_col;
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-uniform vec4 color;
-
-uniform float near_clip;
-uniform float shadow_offset;
-uniform float shadow_bias;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8]; 
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
-        float a = max(dot(n,l),0.0);
-        return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
-	//get light vector
-	vec3 lv = lp.xyz-v;
-	
-	//get distance
-	float d = dot(lv,lv);
-	
-	float da = 0.0;
-
-	if (d > 0.0 && la > 0.0 && fa > 0.0)
-	{
-		//normalize light vector
-		lv = normalize(lv);
-	
-		//distance attenuation
-		float dist2 = d/la;
-		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
-		// spotlight coefficient.
-		float spot = max(dot(-ln, lv), is_pointlight);
-		da *= spot*spot; // GL_SPOT_EXPONENT=2
-
-		//angular attenuation
-		da *= max(dot(n, lv), 0.0);		
-	}
-
-	return da;	
-}
-
-void main()
-{
-	vary_texcoord0 = texcoord0;
-				
-	vec4 pos;
-	vec3 norm;
-	
-	mat4 trans = getSkinnedTransform();
-	vec4 pos_in = vec4(position.xyz, 1.0);
-	pos.x = dot(trans[0], pos_in);
-	pos.y = dot(trans[1], pos_in);
-	pos.z = dot(trans[2], pos_in);
-	pos.w = 1.0;
-	
-	norm.x = dot(trans[0].xyz, normal);
-	norm.y = dot(trans[1].xyz, normal);
-	norm.z = dot(trans[2].xyz, normal);
-	norm = normalize(norm);
-		
-	gl_Position = projection_matrix * pos;
-	
-	float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz));
-	vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset;
-	
-	calcAtmospherics(pos.xyz);
-
-	vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
-
-	// Collect normal lights
-	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
-	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
-	col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
-	col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
-	col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
-	col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-	
-	vary_pointlight_col = col.rgb*color.rgb;
-
-	col.rgb = vec3(0,0,0);
-
-	// Add windlight lights
-	col.rgb = atmosAmbient(vec3(0.));
-	
-	vary_ambient = col.rgb*color.rgb;
-	vary_directional = atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
-	
-	col.rgb = col.rgb*color.rgb;
-	
-	vertex_color = col;
-
-	
-	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
-}
-
-
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 231508e253..7072c95c3e 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2710,14 +2710,14 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d
 	{
 		shader = &gDownsampleDepthRectProgram;
 		shader->bind();
-		shader->uniform2f("delta", 1.f, 1.f);
+		shader->uniform2f(sDelta, 1.f, 1.f);
 		shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight());
 	}
 	else
 	{
 		shader = &gDownsampleDepthProgram;
 		shader->bind();
-		shader->uniform2f("delta", 1.f/source.getWidth(), 1.f/source.getHeight());
+		shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight());
 		shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f);
 	}
 
-- 
cgit v1.2.3


From 1c9a4fc080bee955b5b18750fe8de7c24a3f912f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 1 Jul 2013 10:53:09 -0500
Subject: NORSPEC-290 Shader optimization WIP -- remove some more divides and
 normalizes from various lighting functions, rework flow control based on
 profile feedback.

---
 .../shaders/class1/deferred/multiPointLightF.glsl  |  6 +-
 .../shaders/class1/deferred/pointLightF.glsl       | 86 ++++++++++------------
 .../shaders/class1/deferred/pointLightV.glsl       |  2 +-
 indra/newview/pipeline.cpp                         |  6 +-
 4 files changed, 46 insertions(+), 54 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index a955ef6e9d..ed51e01a53 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -107,14 +107,14 @@ void main()
 	for (int i = 0; i < LIGHT_COUNT; ++i)
 	{
 		vec3 lv = light[i].xyz-pos;
-		float dist = length(lv);
-		dist /= light[i].w;
+		float d = length(lv);
+		float dist = d * light[i].w;
 		if (dist <= 1.0)
 		{
 			float da = dot(norm, lv);
 			if (da > 0.0)
 			{
-				lv = normalize(lv);
+				lv /= d;
 				da = dot(norm, lv);
 			
 				float fa = light_col[i].a+1.0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 106d48bd71..f162f70592 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -35,7 +35,7 @@ uniform sampler2DRect diffuseRect;
 uniform sampler2DRect specularRect;
 uniform sampler2DRect normalMap;
 uniform samplerCube environmentMap;
-uniform sampler2D noiseMap;
+//uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
 uniform sampler2DRect depthMap;
 
@@ -93,64 +93,56 @@ void main()
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = trans_center.xyz-pos;
-	float dist = length(lv);
-	dist /= size;
-	if (dist > 1.0)
-	{
-		discard;
-	}
+	float d = length(lv);
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
-	norm = decode_normal(norm.xy); // unpack norm
-	float da = dot(norm, lv);
-	if (da < 0.0)
+	float dist = d*size;
+
+	vec3 col = vec3(0.0);
+	if (dist <= 1.0)
 	{
-		discard;
-	}
+		vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+		norm = decode_normal(norm.xy); // unpack norm
+		float da = dot(norm, lv);
 	
-	norm = normalize(norm);
-	lv = normalize(lv);
-	da = dot(norm, lv);
+		norm = normalize(norm);
+		lv = normalize(lv);
+		da = max(dot(norm, lv), 0.0);
 	
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+		//float noise = texture2D(noiseMap, frag.xy/128.0).b;
 	
-	vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
-	float fa = falloff+1.0;
-	float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
-	dist_atten *= dist_atten;
-	dist_atten *= 2.0;
+		col = texture2DRect(diffuseRect, frag.xy).rgb;
+		float fa = falloff+1.0;
+		float dist_atten = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0);
+		dist_atten *= dist_atten;
+		dist_atten *= 2.0;
 	
-	float lit = da * dist_atten * noise;
+		float lit = da * dist_atten; // * noise;
 
-	col = color.rgb*lit*col;
+		col = color.rgb*lit*col;
 
-	vec4 spec = texture2DRect(specularRect, frag.xy);
-	if (spec.a > 0.0)
-	{
-		lit = min(da*6.0, 1.0) * dist_atten;
-
-		vec3 npos = -normalize(pos);
-		vec3 h = normalize(lv+npos);
-		float nh = dot(norm, h);
-		float nv = dot(norm, npos);
-		float vh = dot(npos, h);
-		float sa = nh;
-		float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5;
-		float gtdenom = 2 * nh;
-		float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh)));
-
-		if (nh > 0.0)
+		vec4 spec = texture2DRect(specularRect, frag.xy);
+		if (spec.a > 0.0)
 		{
-			float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
-			col += lit*scol*color.rgb*spec.rgb;
+			lit = min(da*6.0, 1.0) * dist_atten;
+
+			vec3 npos = -normalize(pos);
+			vec3 h = normalize(lv+npos);
+			float nh = dot(norm, h);
+			float nv = dot(norm, npos);
+			float vh = dot(npos, h);
+			float sa = nh;
+			float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5;
+			float gtdenom = 2 * nh;
+			float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh)));
+
+			if (nh > 0.0)
+			{
+				float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+				col += lit*scol*color.rgb*spec.rgb;
+			}
 		}
 	}
 	
-	if (dot(col, col) <= 0.0)
-	{
-		discard;
-	}
-		
 	frag_color.rgb = col;	
 	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
index a5625fbc16..aeef09cf5f 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -37,7 +37,7 @@ VARYING vec3 trans_center;
 void main()
 {
 	//transform vertex
-	vec3 p = position*size+center;
+	vec3 p = position*1.f/size+center;
 	vec4 pos = modelview_projection_matrix * vec4(p.xyz, 1.0);
 	vary_fragcoord = pos;
 	trans_center = (modelview_matrix*vec4(center.xyz, 1.0)).xyz;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7072c95c3e..7fa0a972ad 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8680,7 +8680,7 @@ void LLPipeline::renderDeferredLighting()
 							
 							LLFastTimer ftm(FTM_LOCAL_LIGHTS);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
-							gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
+							gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, 1.f/s);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
 							gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f);
 							gGL.syncMatrices();
@@ -8701,7 +8701,7 @@ void LLPipeline::renderDeferredLighting()
 						glh::vec3f tc(c);
 						mat.mult_matrix_vec(tc);
 					
-						fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s));
+						fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], 1.f/s));
 						light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f));
 					}
 				}
@@ -8786,7 +8786,7 @@ void LLPipeline::renderDeferredLighting()
 					col[count].mV[1] = powf(col[count].mV[1], 2.2f);
 					col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/
 					
-					far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z);
+					far_z = llmin(light[count].mV[2]-1.f/light[count].mV[3], far_z);
 					//col[count] = pow4fsrgb(col[count], 2.2f);
 					count++;
 					if (count == max_count || fullscreen_lights.empty())
-- 
cgit v1.2.3