Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3155)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3156)
@@ -251,6 +251,5 @@
 
 	// compute position from old frame for dynamic objects + translational portion
-	//const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz;
-	const float3 translatedPos = worldPos.xyz;
+	const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz;
 
 
@@ -259,11 +258,10 @@
 
 	// note: the old model view matrix only holds the view orientation part
-	//float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f));
-	float4 backProjPos = mul(modelViewProj, float4(translatedPos, 1.0f));
+	float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f));
 	backProjPos /= backProjPos.w;
 	
 	// fit from unit cube into 0 .. 1
-	//const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f;
-	const float2 oldTexCoords = texCoord;
+	const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f;
+	//const float2 oldTexCoords = texCoord;
 	// retrieve the sample from the last frame
 	const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));
@@ -273,5 +271,5 @@
 
 	// vector from eye pos to old sample 
-	const float3 oldViewDir = viewDir;//Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
+	const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
 	const float invLen = 1.0f / length(oldViewDir);
 	const float projectedEyeSpaceDepth = invLen * length(translatedPos);
@@ -280,5 +278,4 @@
 
 	const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z;
-
 	//if (squaredLen < 1e-8f) // object not dynamic
 	//{}
@@ -289,6 +286,6 @@
 		&& (oldTexCoords.x >= 0.0f) && (oldTexCoords.x < 1.0f)
 		&& (oldTexCoords.y >= 0.0f) && (oldTexCoords.y < 1.0f)
-		//&& (depthDif <= MIN_DEPTH_DIFF) 
-		&& (depthDif <= 9e-1f) 
+		&& (depthDif <= MIN_DEPTH_DIFF) 
+		//&& (depthDif <= 9e-1f) 
 		)
 	{
@@ -297,9 +294,9 @@
 	else
 	{	
-		validPixel = 1.5f;
+		validPixel = 10.5f;
 	}
 
-	return depthDif;
-	//return validPixel;
+	//return depthDif;
+	return validPixel;
 }
 
@@ -310,9 +307,9 @@
 				   uniform float4x4 modelViewProj,
 				   uniform float4x4 oldModelViewProj,
-				   uniform float3 oldEyePos,
 				   uniform float3 oldbl,
 				   uniform float3 oldbr,
 				   uniform float3 oldtl,
 				   uniform float3 oldtr,
+				   uniform float3 oldEyePos,
 				   uniform sampler2D diffVals
 				   ): COLOR
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3155)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3156)
@@ -106,11 +106,9 @@
 		const float scale =	adaptFactor * scaleFactor * ao.z  / (adaptFactor + ao.y);
 
-		//ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale);
+		ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale);
 	}
 
 	OUT.illum_col.xyz = col.xyz * ao.x;
-	
-	OUT.illum_col.xyz = float3(0, ao.x, 0);
-
+	//OUT.illum_col.xyz = float3(0, ao.x, 0);
 	//OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1);
 	OUT.illum_col.w = col.w;
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3155)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3156)
@@ -183,31 +183,5 @@
 #endif
 
-	//float pixelValid = 0.5f;
-	float overallDepth = 0;
-
-#if 0
 	const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z;
-
-	if (squaredLen < 1e-8f) // object not dynamic
-	{
-		for (int i = 0; i < NUM_SAMPLES; ++ i) 
-		{
-			float sampleDif = ComputeDifference(samples[i],
-												oldTex,
-												oldModelViewProj,
-												colors,
-												noiseTex,
-												scaleFactor,
-												bl, br, tl, tr, 
-												texcoord0,
-												oldEyePos,
-												oldbl, oldbr, oldtl, oldtr,
-												eyeSpaceDepth
-												);
-			//overallDepth += sampleDif;
-			if (sampleDif >= MIN_DEPTH_DIFF) ++ notValid;
-		}
-	}
-#endif
 
 	const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence);
@@ -227,5 +201,5 @@
 		// increase the weight for convergence
 		newWeight = oldWeight + 1.0f;
-		if (pixelValid > 1.0f) newWeight = 4.0f;
+		if ((pixelValid > 1.0f) && (squaredLen < 1e-8f)) newWeight = 4.0f;
 		//if (pixelValid > 1.0f) newWeight = max(15.0f - notValid * 2.0f, 1.0f);
 	}
@@ -461,4 +435,5 @@
 	}
 
+
 	/////////////////
 	//-- compute temporal reprojection
@@ -482,5 +457,5 @@
 
 
-	OUT.illum_col.x = ao.y;//(ao.x + oldSsao * (newWeight - 1.0f)) / newWeight;
+	OUT.illum_col.x = (ao.x + oldSsao * (newWeight - 1.0f)) / newWeight;
 	OUT.illum_col.y = newWeight;
 	OUT.illum_col.z = invw;
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3155)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3156)
@@ -445,5 +445,5 @@
 	
 	string prepareSsaoParams[] = 
-		{"colorsTex", "oldTex", "modelViewProj", "oldModelViewProj", "oldEyePos", 
+		{"colorsTex", "oldTex", "oldEyePos", "modelViewProj", "oldModelViewProj",
 		 "oldbl", "oldbr", "oldtl", "oldtr", "diffVals"};
 
@@ -968,10 +968,4 @@
 	//sCgSsaoProgram->SetTexture(i ++, normalsTex);
 	sCgPrepareSsaoProgram->SetTexture(i ++, oldTex);
-	
-	sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix);
-	sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix);
-
-	for (int j = 0; j < 4; ++ j, ++ i)
-		sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z);
 
 	Vector3 de;
@@ -981,4 +975,10 @@
 
 	sCgPrepareSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z);
+
+	sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix);
+	sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix);
+
+	for (int j = 0; j < 4; ++ j, ++ i)
+		sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z);
 
 	sCgPrepareSsaoProgram->SetTexture(i ++, diffVals);
