Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3105)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3106)
@@ -43,5 +43,6 @@
 #define MAX_LOD_LEVEL 10
 
-#define MIN_DEPTH_DIFF 1e-3f
+//#define MIN_DEPTH_DIFF 5e-3f
+#define MIN_DEPTH_DIFF 1e-2f
 //#define MIN_DEPTH_DIFF 1e-3f
 #define PRECISION_SCALE 1e-1f
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3105)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3106)
@@ -5,5 +5,5 @@
 // based on shader of Alexander Kusternig
 
-#define USE_EYESPACE_DEPTH 0
+#define USE_EYESPACE_DEPTH 1
 
 
@@ -137,5 +137,6 @@
 								uniform float3 oldtl,
 								uniform  float3 oldtr,
-								float invW
+								float invW,
+								float3 projPos
 								//,const uniform float4x4 inverseModelTrafo
 								//, float id
@@ -152,6 +153,4 @@
 	//else trafo = inverseModelTrafo * oldModelViewProj;
 
-	//float3 translatedPt = float3(worldPos.xy - oldEyePos.xy, worldPos.z + oldEyePos.z);
-	//float3 translatedPt = float3(worldPos.x - oldEyePos.x, worldPos.y - oldEyePos.y, worldPos.z - oldEyePos.z);
 	const float3 translatedPt = worldPos.xyz - oldEyePos;
 
@@ -175,16 +174,16 @@
 	const float projectedEyeSpaceDepth = length(translatedPt) * invlen;
 	
-	const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth);
+	//const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth);
 	//const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth) / projectedEyeSpaceDepth;
+	const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth);
+
 #else
 	// calculate eye space position of sample in old frame
 	const float oldDepth = oldPixel.w;
-
-	float3 projectedPos = worldPos.xyz * invW;
-	const float projectedDepth = worldPos.z;
+	const float projectedDepth = projPos.z;
+	//const float projectedDepth = invW * worldPos.z;
 
 	// vector from eye pos to old sample 
 	const float depthDif = abs(projectedDepth - oldDepth);
-	//const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth) / projectedEyeSpaceDepth;
 #endif
 
@@ -243,7 +242,7 @@
 #else
 	illum_col.w = projectedDepth;
+#endif
+
 	illum_col.z = invW;
-#endif
-	
 	//illum_col.y = depthDif;
 
@@ -364,4 +363,5 @@
 	float4 projPos = mul(modelViewProj, eyeSpacePos);
 	const float w = 1 / projPos.w;
+	projPos *= w;
 	float scaleFactor = SAMPLE_RADIUS * w;
 	
@@ -376,5 +376,5 @@
 		                              oldTex, oldModelViewProj, temporalCoherence,
 		                              samples, colors, noiseTex, w, bl, br, tl, tr,
-									  oldbl, oldbr, oldtl, oldtr, scaleFactor);
+									  oldbl, oldbr, oldtl, oldtr, scaleFactor, projPos);
 
 	//OUT.illum_col.xyz = normal * 0.5f + 0.5f;
@@ -415,11 +415,11 @@
 	float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));
 
-	if ((ao.y < 10.0f) && (col.w < 1e10f))
-		ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y));//ao.z);
+	//if ((ao.y < 10.0f) && (col.w < 1e10f))
+	//	ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y));//ao.z);
 
 	OUT.illum_col = col * ao.x;
 	//OUT.illum_col = float4(ao.y, ao.y, ao.y, col.w);
 	//OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w);
-	OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1);
+	//OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1);
 	//OUT.illum_col.xyz = float3(1.0f - ao.x, ao.y, 0);
 	OUT.illum_col.w = col.w;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3105)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3106)
@@ -92,4 +92,5 @@
 /// eye near plane distance
 const float nearDist = 0.2f;
+//const float nearDist = 1.0f;
 /// eye far plane distance
 float farDist = 1e6f;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3105)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3106)
@@ -963,17 +963,26 @@
 	mOldProjViewMatrix = mProjViewMatrix;
 	mOldEyePos = mEyePos;
-
-
-	///////////////////
-
-	Matrix4x4 matViewing, matProjection;
+	mEyePos = mCamera->GetPosition();
 
 	// hack: temporarily change far to improve precision
 	const float oldFar = mCamera->GetFar();
-	mCamera->SetFar(1e3f);
+	const float oldNear = mCamera->GetNear();
+	//mCamera->SetFar(1e3f);
+	//mCamera->SetNear(3.0f);
 	//mCamera->SetFar(1e2f);
 
-
-	//mCamera->GetModelViewMatrix(matViewing);
+	Matrix4x4 matViewing, matProjection;
+/*
+	mCamera->SetPosition(mOldEyePos - mEyePos);
+
+	mCamera->GetModelViewMatrix(matViewing);
+	mCamera->GetProjectionMatrix(matProjection);
+
+	mOldProjViewMatrix = matViewing * matProjection;
+	mCamera->SetPosition(mEyePos);*/
+
+	///////////////////
+
+
 	mCamera->GetViewOrientationMatrix(matViewing);
 	mCamera->GetProjectionMatrix(matProjection);
@@ -981,6 +990,5 @@
 	mProjViewMatrix = matViewing * matProjection;
 	ComputeViewVectors(mCamera, mCornersView[0], mCornersView[1], mCornersView[2], mCornersView[3]);
-	mEyePos = mCamera->GetPosition();
-
+	
 
 	// switch roles of old and new fbo
@@ -1018,4 +1026,5 @@
 	// revert to old far plane
 	mCamera->SetFar(oldFar);
+	mCamera->SetNear(oldNear);
 }
 
