Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3348)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3349)
@@ -20,5 +20,5 @@
 {
 	float4 illum_col: COLOR0;
-	//float4 col: COLOR1;
+	float4 col: COLOR1;
 };
 
@@ -117,5 +117,5 @@
 	const float oldEyeSpaceDepth = oldPixel.w;
 
-	// vector from eye pos to old sample
+	// vector from eye pos to old sample 
 	const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
 	const float invLen = 1.0f / length(viewVec);
@@ -148,15 +148,15 @@
 		
 		//w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f));
-		//w = floor(oldPixel.y);
-		//w = oldPixel.y;
-		idx = floor(oldPixel.y);
+		w = oldPixel.y;
+		idx = floor(oldPixel.z);
+
 	}
 	else
 	{	
-		w   = .0f;
+		w = 0.0f;
 		idx = .0f;
 	}
 
-	return float3(ssao, idx, w);
+	return float3(ssao, w, idx);
 }
 
@@ -201,5 +201,4 @@
 			tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy;
 
-
 		////////////////////
 		//-- add random noise: reflect around random normal vector 
@@ -208,5 +207,5 @@
 		if (convergence < SSAO_CONVERGENCE_THRESHOLD)
 		{
-			float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, .0f, .0f)).xy;
+			float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy;
 			//offset = myreflect(samples[i], mynoise);
 			//offset = myrotate(samples[i], mynoise.x);
@@ -502,5 +501,5 @@
 #ifdef PERFORMANCE_TEST	
 
-	float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, .0f, .0f)).xyz;
+	float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz;
 
 	const float sqrMoveSpeed = SqrLen(diffVec);
@@ -522,16 +521,14 @@
 	const float oldSsao = temporalVals.x;
 	
-	//float oldIdx = temporalCoherence > 1 ? temporalVals.y : .0f;
-	float oldIdx = temporalVals.y;
-	//float oldWeight = temporalVals.y;
-	float oldWeight = clamp(oldIdx, 0, temporalCoherence);
-
+	float oldWeight = temporalVals.y;
+	float oldIdx = temporalCoherence > 1 ? temporalVals.z : 0;
+	
 #else
 
 	const bool isMovingObject = false;
-	const float oldSsao = .0f;
-	
-	float oldWeight = .0f;
-	float oldIdx = .0f;
+	const float oldSsao = 0;
+	
+	float oldWeight = 0;
+	float oldIdx = 0;
 	
 #endif
@@ -585,7 +582,7 @@
 		else if (ao.y > partlyResetThres)
 		{
-			//if (oldIdx > 4.0f * NUM_SAMPLES) oldIdx = 0;
-			oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); oldIdx = oldWeight;
-			//oldWeight = oldIdx;//.0f; oldIdx = .0f;
+			oldWeight = min(oldWeight, 4.0f * newWeight);
+			//oldWeight = .0f; 
+			//oldIdx = .0f;
 		}
 	}
@@ -599,10 +596,8 @@
 
 	// the new weight for the next frame
-	const float newIdx = newWeight + oldIdx;
-	//const float combinedWeight = clamp(newIdx, .0f, temporalCoherence);
-	const float combinedWeight = clamp(newIdx, .0f, min(newWeight + oldWeight, temporalCoherence));
-
-	//OUT.illum_col.y = combinedWeight;
-	OUT.illum_col.y = newIdx; // the new index
+	const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence);
+
+	OUT.illum_col.y = combinedWeight;
+	OUT.illum_col.z = oldIdx + newWeight; // the new index
 	OUT.illum_col.w = eyeSpaceDepth;
 
@@ -610,6 +605,6 @@
 
 	// this value can be used to check if this pixel belongs to a moving object
-	//OUT.col.x = SqrLen(diffVec);
-	OUT.illum_col.z = SqrLen(diffVec);
+	OUT.col.x = SqrLen(diffVec);
+	//OUT.illum_col.z = SqrLen(diffVec);
 
 #else
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg	(revision 3347)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg	(revision 3349)
@@ -250,5 +250,5 @@
 
 	//OUT.illum_col.xyz = float3(ao.w * 5e-1f, 0, 0);
-	//OUT.illum_col.xyz = float3(ao.y * 1e-2f);
+	//OUT.illum_col.xyz = float3(ao.z * 1e-1f);
 	//OUT.illum_col.xyz = float3(ao.y * 1e-1f);//, 0, 0);
 	//OUT.illum_col.xyz = ao.xyz;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3347)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3349)
@@ -254,6 +254,5 @@
 	// retrieve the sample from the last frame
 	const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));
-	//const float oldDiff = tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).x;
-	const float oldDiff = oldPixel.z;//tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).z;
+	const float oldDiff = tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).x;
 
 	// calculate eye space position of sample in old frame
@@ -306,5 +305,4 @@
 		isPixelValid = pixelIsValid;
 	}
-	//isPixelValid = pixelIsValid;
 	
 	return float2(isPixelValid, abs(oldEyeSpaceDepth - projectedEyeSpaceDepth));
@@ -340,5 +338,6 @@
 	const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz);
 
-#ifdef PERFORMANCE_TEST
+//#ifdef PERFORMANCE_TEST
+#if 1
 	// do reprojection and filter out the pixels that are not save
 	const float2 pValid = PixelValid(oldTex,
@@ -354,5 +353,5 @@
 									 );
 #else
-	const float2 pValid = float2(0, 0);
+	const float2 pValid = float2(0,0);
 #endif
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3347)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3349)
@@ -432,5 +432,4 @@
 	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
 
-
 	for (int i = 0; i < 2; ++ i)
 	{
@@ -822,5 +821,5 @@
 	// read the second buffer, write to the first buffer
 	mIllumFbo->Bind();
-	glDrawBuffers(1, mrt + mIllumFboIndex);
+	glDrawBuffers(2, mrt + mIllumFboIndex);
 
 	int i = 0;
@@ -929,6 +928,6 @@
 
 	// the neighbouring texels
-	const float xOffs = 1.0f / fbo->GetWidth();
-	const float yOffs = 1.0f / fbo->GetHeight();
+	float xOffs = 1.0f / fbo->GetWidth();
+	float yOffs = 1.0f / fbo->GetHeight();
 
 	sCgAntiAliasingProgram->SetTexture(0, colorsTex);
@@ -1383,7 +1382,9 @@
 	gluOrtho2D(0, 1, 0, 1);
 
+
 	glMatrixMode(GL_MODELVIEW);
 	glPushMatrix();
 	glLoadIdentity();
+
 	
 	glPushAttrib(GL_VIEWPORT_BIT);
