diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 20e5c91296ce8e7ab8ee32067bea46c59227fa1e..7d76e1cf26a51283d23173bd341d2f2acf1ebb53 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -52,9 +52,9 @@ public:
 		POOL_BUMP,
 		POOL_MATERIALS,
 		POOL_TERRAIN,	
+		POOL_TREE,
 		POOL_SKY,
 		POOL_WL_SKY,
-		POOL_TREE,
 		POOL_ALPHA_MASK,
 		POOL_FULLBRIGHT_ALPHA_MASK,
 		POOL_GRASS,
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 457184e94ac29f98c43b01dc7c547feef554e513..297bc4e37cb2ffe4e0dc2d552dbc24cfe2c42590 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -248,6 +248,7 @@ void LLDrawPoolWater::render(S32 pass)
 	
 	glClearStencil(1);
 	glClear(GL_STENCIL_BUFFER_BIT);
+	glClearStencil(0);
 	LLGLEnable gls_stencil(GL_STENCIL_TEST);
 	glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP);
 	glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index d041204b12cea3248ba37d5597e9eeb13fc2a3b6..19b2230ef638abaa747efebac133b4abd7052c4e 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -323,6 +323,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
 
 	const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius();
 
+	LLGLDisable stencil(GL_STENCIL_TEST);
 	LLGLSNoFog disableFog;
 	LLGLDepthTest depth(GL_TRUE, GL_FALSE);
 	LLGLDisable clip(GL_CLIP_PLANE0);
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 2c4e4ca83d0b79455f659703ef07db160100598a..b441c4d51b928992d9a086e2a473b0db54e5f87a 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -1661,6 +1661,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
 		glStencilMask(stencil_mask);
 		glClearStencil(1);
 		glClear(GL_STENCIL_BUFFER_BIT);
+		glClearStencil(0);
 		LLGLEnable cull_face(GL_CULL_FACE);
 		LLGLEnable stencil(GL_STENCIL_TEST);
 		LLGLDepthTest depth (GL_TRUE, GL_FALSE, GL_ALWAYS);
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 3a3949334da7525469c173819a18ca0726f07e76..a85212c5111375b1b05dbbbf86286a2af8f566cd 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -3175,6 +3175,8 @@ public:
 			return;
 		}
 
+		LLGLDisable stencil(GL_STENCIL_TEST);
+
 		group->rebuildGeom();
 		group->rebuildMesh();
 
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 7c5a8b8631b41462983bf04876cd815c9e750a6a..00ddee5f38ad87f0d5914483025de3326d5cafac 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1194,6 +1194,8 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh
 {
 	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
 	{
+		LLGLDisable stencil(GL_STENCIL_TEST);
+
 		//move mBounds to the agent space if necessary
 		LLVector4a bounds[2];
 		bounds[0] = mBounds[0];
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2ab8dd275b67e438dfba7860dbf881f0fab6d68e..7fb389ac609b540cbfa201a62b2bec254342b757 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -287,9 +287,9 @@ std::string gPoolNames[] =
 	"POOL_BUMP",
 	"POOL_MATERIALS",
 	"POOL_TERRAIN,"	
+	"POOL_TREE",
 	"POOL_SKY",
 	"POOL_WL_SKY",
-	"POOL_TREE",
 	"POOL_ALPHA_MASK",
 	"POOL_FULLBRIGHT_ALPHA_MASK",
 	"POOL_GRASS",
@@ -2400,6 +2400,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 
 	LLGLDisable blend(GL_BLEND);
 	LLGLDisable test(GL_ALPHA_TEST);
+	LLGLDisable stencil(GL_STENCIL_TEST);
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
 
@@ -3967,6 +3968,7 @@ void LLPipeline::renderHighlights()
 		glStencilMask(0xFFFFFFFF);
 		glClearStencil(1);
 		glClear(GL_STENCIL_BUFFER_BIT);
+		glClearStencil(0);
 
 		glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
 		glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);