Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 2819)
@@ -3,9 +3,10 @@
 
 #include "glInterface.h"
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
 #include "common.h"
 #include "AxisAlignedBox3.h"
 #include "Triangle3.h"
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
+
 
 namespace CHCDemoEngine 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h	(revision 2819)
@@ -2,4 +2,7 @@
 #define __MATERIAL_H
 
+#include "glInterface.h"
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
 #include "common.h"
 
@@ -69,4 +72,6 @@
 	void InitMaterial();
 
+	static CGparameter sDiffuseParam;
+	static CGparameter sDiffuseTexParam;
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2819)
@@ -57,4 +57,7 @@
 	static CGprofile sCgVertexProfile; 
 
+	static CGprogram sCgMrtFragmentProgram;
+	static CGprogram sCgMrtFragmentTexProgram;
+
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2819)
@@ -8,4 +8,7 @@
 namespace CHCDemoEngine
 {
+
+CGparameter Material::sDiffuseParam;
+CGparameter Material::sDiffuseTexParam;
 
 RgbaColor RandomColor(float a, float b)
@@ -60,7 +63,13 @@
 
 	if (mTexture)
+	{
 		mTexture->Bind();
+		cgGLSetParameter4f(sDiffuseTexParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a);
+	}
 	else
+	{
+		cgGLSetParameter4f(sDiffuseParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a);
 		glBindTexture(GL_TEXTURE_2D, 0);
+	}
 
 	glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2819)
@@ -23,4 +23,5 @@
 #include "SceneQuery.h"
 #include "RenderQueue.h"
+#include "Material.h"
 #include <Cg/cg.h>
 #include <Cg/cgGL.h>
@@ -144,7 +145,9 @@
 bool eightKeyPressed = false;
 
-
 static Vector3 samples[32];
 GLubyte *randomNormals;
+
+PerfTimer frameTimer, algTimer;
+	
 
 // function forward declarations
@@ -207,5 +210,5 @@
 static CGprogram sCgMrtVertexProgram = NULL;
 static CGprogram sCgSSAOProgram = NULL;
-static CGprogram sCgMrtFragmentProgram = NULL;
+
 
 static CGparameter sColorsTexParam;
@@ -217,4 +220,5 @@
 //static CGparameter sModelMatrixParam;
 static CGparameter sMaxDepthParam;
+static CGparameter sMaxDepthParamTex;
 
 const static float radius = 1e-3f;
@@ -394,5 +398,25 @@
 	}
 
-	sCgMrtFragmentProgram = 
+	RenderState::sCgMrtFragmentTexProgram = 
+		cgCreateProgramFromFile(sCgContext, 
+								CG_SOURCE,
+								"src/shaders/mrt.cg", 
+								RenderState::sCgFragmentProfile,
+								"fragtex",
+								NULL);
+
+	if (RenderState::sCgMrtFragmentTexProgram != NULL)
+	{
+		cgGLLoadProgram(RenderState::sCgMrtFragmentTexProgram);
+
+		sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth");
+		Material::sDiffuseTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "diffuse");
+
+		cgGLSetParameter1f(sMaxDepthParamTex, 10.0f / myfar);
+	}
+	else
+		cerr << "fragment tex program failed to load" << endl;
+
+	RenderState::sCgMrtFragmentProgram = 
 		cgCreateProgramFromFile(sCgContext, 
 								CG_SOURCE,
@@ -402,14 +426,15 @@
 								NULL);
 
-	if(sCgMrtFragmentProgram != NULL)
-	{
-		cgGLLoadProgram(sCgMrtFragmentProgram);
-
-		sMaxDepthParam = cgGetNamedParameter(sCgMrtFragmentProgram, "maxDepth");
+	if (RenderState::sCgMrtFragmentProgram != NULL)
+	{
+		cgGLLoadProgram(RenderState::sCgMrtFragmentProgram);
+
+		sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth");
+		Material::sDiffuseParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "diffuse");
 
 		cgGLSetParameter1f(sMaxDepthParam, 10.0f / myfar);
 	}
 	else
-		cerr << "test program failed to load" << endl;
+		cerr << "fragment program failed to load" << endl;
 
 	PrintGLerror("test");
@@ -814,8 +839,8 @@
 
 
-
 void Display() 
 {	
-	PerfTimer frameTimer, algTimer;
+	// take time from last frame
+	elapsedTime = frameTimer.Elapsed();
 	frameTimer.Start();
 
@@ -848,5 +873,5 @@
 
 	cgGLEnableProfile(RenderState::sCgFragmentProfile);
-	cgGLBindProgram(sCgMrtFragmentProgram);
+	cgGLBindProgram(RenderState::sCgMrtFragmentProgram);
 
 	cgGLEnableProfile(RenderState::sCgVertexProfile);
@@ -861,24 +886,26 @@
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
+	// render without shading
+	if (depthPass) 
+	{
+		state.SetDepthPass(true);
+		glDisable(GL_LIGHTING);
+	}
+	else
+	{
+		state.SetDepthPass(false);
+		glEnable(GL_LIGHTING);
+	}
+	
+
+	// bring eye modelview matrix up-to-date
+	SetupEyeView();
+
 	// set modelview matrix for shaders
 	cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
-
-	// render without shading
-	if (depthPass) 
-	{
-		state.SetDepthPass(true);
-		glDisable(GL_LIGHTING);
-	}
-	else
-	{
-		state.SetDepthPass(false);
-		glEnable(GL_LIGHTING);
-	}
 	
 	static Matrix4x4 identity = IdentityMatrix();
-
 	cgGLSetMatrixParameterfc(SceneEntity::sModelMatrixParam, (const float *)identity.x);
-	// bring eye modelview matrix up-to-date
-	SetupEyeView();
+	
 
 	// actually render the scene geometry using one of the specified algorithms
@@ -931,6 +958,4 @@
 
 	glutSwapBuffers();
-
-	elapsedTime = frameTimer.Elapsed();
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2819)
@@ -152,5 +152,6 @@
   float diffuse = diffuseLight + diffuseLight2;
 
-  float ao = ssao(IN, positions, normals, noiseTexture);
+  //float ao = ssao(IN, positions, normals, noiseTexture);
+  float ao = 1.0f;
   //OUT.color = ao; 
   OUT.color = ao * (ambient + diffuse) * color;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2819)
@@ -63,10 +63,15 @@
 }
 
+/*struct Material
+{
+  float4 diffuse;
+}*/
 
-pixel frag(fragin IN, uniform sampler2D tex, uniform float maxDepth)
+
+pixel fragtex(fragin IN, uniform sampler2D tex, uniform float maxDepth, uniform float4 diffuse)
 {
   pixel pix;
       
-  pix.col = tex2D(tex, IN.texCoord.xy);
+  pix.col = diffuse * tex2D(tex, IN.texCoord.xy);
   pix.pos = IN.worldPos * maxDepth;
   pix.norm = IN.normal;
@@ -75,2 +80,15 @@
   return pix;
 }
+
+
+pixel frag(fragin IN, uniform float maxDepth, uniform float4 diffuse)
+{
+  pixel pix;
+      
+  pix.col = diffuse;
+  pix.pos = IN.worldPos * maxDepth;
+  pix.norm = IN.normal;
+  pix.pos.w = IN.projPos.w;
+
+  return pix;
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2818)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2819)
@@ -9,4 +9,7 @@
 CGprofile RenderState::sCgFragmentProfile;
 CGprofile RenderState::sCgVertexProfile; 
+
+CGprogram RenderState::sCgMrtFragmentProgram = NULL;
+CGprogram RenderState::sCgMrtFragmentTexProgram = NULL;
 
 
@@ -84,4 +87,7 @@
 	{
 		mTexturesEnabled = false;
+
+		cgGLBindProgram(sCgMrtFragmentProgram);
+
 		glDisable(GL_TEXTURE_2D);
 		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -92,4 +98,7 @@
 		{
 			mTexturesEnabled = true;
+
+			cgGLBindProgram(sCgMrtFragmentTexProgram);
+
 			glEnable(GL_TEXTURE_2D);
 			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2805)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2819)
@@ -63,6 +63,5 @@
 
 	// test if entity 
-	if (mat->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled)
-		return false;
+	//if (mat->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled) return false;
 
 	const bool hasTexture = (mat->GetTexture() != NULL);
