Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2949)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2950)
@@ -97,7 +97,7 @@
 		mAlphaTestEnabled = false;
 		
-		//if (mUseAlphaToCoverage)
+		if (mUseAlphaToCoverage)
 			glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-		//else
+		else
 			glDisable(GL_ALPHA_TEST);
 	}
@@ -106,9 +106,8 @@
 		mAlphaTestEnabled = true;
 		
-		/*if (mUseAlphaToCoverage)
+		if (mUseAlphaToCoverage)
 			glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
 		else
 			glEnable(GL_ALPHA_TEST);
-			*/
 	}
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 2948)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 2950)
@@ -24,5 +24,5 @@
 	if (!mMatrix) return;
 
-	if ((state->GetRenderType() == RenderState::DEFERRED) || (state->GetRenderType() == RenderState::DEPTH_PASS_DEFERRED))
+	if (state->GetRenderType() == RenderState::DEFERRED)
 	{
 		cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix->x);
@@ -40,5 +40,5 @@
 	if (!mMatrix) return;
 
-	if ((state->GetRenderType() == RenderState::DEFERRED) || (state->GetRenderType() == RenderState::DEPTH_PASS_DEFERRED))
+	if (state->GetRenderType() == RenderState::DEFERRED)
 	{
 		static Matrix4x4 identity = IdentityMatrix();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2949)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2950)
@@ -592,5 +592,5 @@
 void InitGLstate() 
 {
-	glClearColor(0.7f, 0.0f, 0.2f, 0.0f);
+	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
 	
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -945,7 +945,8 @@
 	case RenderState::DEPTH_PASS_DEFERRED:
 
-		state.Reset();
-
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		glDisable(GL_MULTISAMPLE_ARB);
+		state.SetUseAlphaToCoverage(false);
+
+		state.SetRenderType(RenderState::DEPTH_PASS);
 
 		if (!fbo) InitFBO(); fbo->Bind();
@@ -957,21 +958,10 @@
 
 		glClear(GL_DEPTH_BUFFER_BIT);
-
-		glDisable(GL_MULTISAMPLE_ARB);
-
-		state.SetRenderType(RenderState::DEPTH_PASS);
-		state.SetUseAlphaToCoverage(false);
-		
-		glDisable(GL_ALPHA_TEST);
-		glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-
-		state.Reset();
+		//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
 		// the scene is rendered withouth any shading	
 		glShadeModel(GL_FLAT);
 		glDisable(GL_LIGHTING);
-	
 		glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-
-		PrintGLerror("here095");
 
 		break;
@@ -998,13 +988,10 @@
 
 		if (showShadowMap && !renderLightView)
-		{
 			RenderShadowMap();
-		}
-
+		
 		//glPushAttrib(GL_VIEWPORT_BIT);
 		glViewport(0, 0, texWidth, texHeight);
 
 		InitDeferredRendering();
-		
 		// draw to 3 color buffers
 		glDrawBuffers(3, mrt);
@@ -1075,5 +1062,5 @@
 	// this would conveniently solves some issues (e.g, skys without shadows)
 
-	//RenderSky();
+	RenderSky();
 	
 
@@ -1909,58 +1896,31 @@
 void RenderVisibleObjects()
 {
-	// draw all objects that have exactly the same depth as the current sample
-	//glDisable(GL_DEPTH_TEST);
-	glDepthFunc(GL_LEQUAL);
-
-	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-	PrintGLerror("here05");
 	if (renderType == RenderState::DEPTH_PASS_DEFERRED)
 	{
-		if ((renderType == RenderState::DEFERRED) || (renderType == RenderState::DEPTH_PASS_DEFERRED))
-		{
-			// set modelview matrix for shaders
-			cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, 
-				CG_GL_MODELVIEW_PROJECTION_MATRIX, 
-				CG_GL_MATRIX_IDENTITY);
-
-			static Matrix4x4 identity = IdentityMatrix();
-			cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)identity.x);
-		}		
-
-		PrintGLerror("here06");
+		if (showShadowMap && !renderLightView)
+			RenderShadowMap();
 
 		glDisable(GL_LIGHTING);
-		state.SetUseAlphaToCoverage(false);
-		
 		glViewport(0, 0, texWidth, texHeight);
 		InitDeferredRendering();
 
-		PrintGLerror("here07");
-		//glClear(GL_COLOR_BUFFER_BIT);
 		// draw to 3 color buffers
 		glDrawBuffers(3, mrt);
-		PrintGLerror("here08");
-		//glClear(GL_DEPTH_BUFFER_BIT);
 	}
 	else
+	{
+		glShadeModel(GL_SMOOTH);
+		glEnable(GL_LIGHTING);
 		state.SetRenderType(RenderState::FIXED);
-
-	PrintGLerror("here2");
+	}
+
+	// draw all objects that have exactly the same depth as the current sample
+	glDepthFunc(GL_LEQUAL);
+	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+
+	state.SetUseAlphaToCoverage(true);
 	state.Reset();
-
-	PrintGLerror("here7");
-
-	glShadeModel(GL_SMOOTH);
-	glEnable(GL_LIGHTING);
-
-	PrintGLerror("here8");
-
-	glDisable(GL_ALPHA_TEST);
-	glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-
-	PrintGLerror("here9");
-
-	PrintGLerror("here3");
-
+	
+	
 	//cout << "visible: " << (int)traverser->GetVisibleObjects().size() << endl;
 
