Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2928)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2949)
@@ -112,5 +112,4 @@
 	pix.pos = IN.worldPos * maxDepth;
 
-	//pix.norm.xyz = IN.normal * 0.5f + float3(0.5f);
 	pix.norm.xyz = IN.normal;
 	
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2943)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2949)
@@ -97,7 +97,7 @@
 		mAlphaTestEnabled = false;
 		
-		if (mUseAlphaToCoverage)
+		//if (mUseAlphaToCoverage)
 			glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-		else
+		//else
 			glDisable(GL_ALPHA_TEST);
 	}
@@ -106,8 +106,9 @@
 		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/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2948)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2949)
@@ -550,4 +550,5 @@
 void InitFBO()
 {
+	PrintGLerror("fbo start");
 	// this fbo basicly stores the scene information we get from standard rendering of a frame
 	// we store colors, normals, positions (for the ssao)
@@ -946,5 +947,8 @@
 		state.Reset();
 
+		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
 		if (!fbo) InitFBO(); fbo->Bind();
+
 		glDrawBuffers(1, mrt);
 
@@ -952,5 +956,5 @@
 		cgGLDisableProfile(RenderState::sCgVertexProfile);
 
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		glClear(GL_DEPTH_BUFFER_BIT);
 
 		glDisable(GL_MULTISAMPLE_ARB);
@@ -958,5 +962,7 @@
 		state.SetRenderType(RenderState::DEPTH_PASS);
 		state.SetUseAlphaToCoverage(false);
-
+		
+		glDisable(GL_ALPHA_TEST);
+		glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
 
 		state.Reset();
@@ -966,4 +972,6 @@
 	
 		glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
+		PrintGLerror("here095");
 
 		break;
@@ -1071,5 +1079,5 @@
 
 
-	if ((renderType == RenderState::DEFERRED))// || (renderType == RenderState::DEPTH_PASS_DEFERRED))
+	if ((renderType == RenderState::DEFERRED) || (renderType == RenderState::DEPTH_PASS_DEFERRED))
 	{
 		//glPopAttrib();
@@ -1901,32 +1909,59 @@
 void RenderVisibleObjects()
 {
-	/*if ((renderType == RenderState::DEPTH_PASS_DEFERRED))
-	{
-		//glDisable(GL_LIGHTING);
-		state.SetUseAlphaToCoverage(false);
-		//FrameBufferObject::Release();
-		InitDeferredRendering();
-
-		glClear(GL_COLOR_BUFFER_BIT || GL_DEPTH_BUFFER_BIT);
-		// draw to 3 color buffers
-		glDrawBuffers(3, mrt);
-	}
-	else*/
-		state.SetRenderType(RenderState::FIXED);
-
-	state.Reset();
-
-	glShadeModel(GL_SMOOTH);
-	glEnable(GL_LIGHTING);
-
-	glDisable(GL_ALPHA);
-	glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-
-	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
 	// draw all objects that have exactly the same depth as the current sample
 	//glDisable(GL_DEPTH_TEST);
 	glDepthFunc(GL_LEQUAL);
-	cout << "visible: " << (int)traverser->GetVisibleObjects().size() << endl;
+
+	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");
+
+		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
+		state.SetRenderType(RenderState::FIXED);
+
+	PrintGLerror("here2");
+	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;
 
 	SceneEntityContainer::const_iterator sit, 
@@ -1942,4 +1977,6 @@
 	glDepthFunc(GL_LESS);
 	state.SetUseAlphaToCoverage(true);
+
+	PrintGLerror("visibleobjects");
 }
 
