Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3103)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3105)
@@ -43,6 +43,6 @@
 #define MAX_LOD_LEVEL 10
 
-//#define MIN_DEPTH_DIFF 1e-2f
-#define MIN_DEPTH_DIFF 0.1f
+#define MIN_DEPTH_DIFF 1e-3f
+//#define MIN_DEPTH_DIFF 1e-3f
 #define PRECISION_SCALE 1e-1f
 
@@ -55,5 +55,6 @@
 #define NUM_DOWNSAMPLES 9
 
-#define NUM_SSAO_FILTERSAMPLES 28
+//#define NUM_SSAO_FILTERSAMPLES 28
+#define NUM_SSAO_FILTERSAMPLES 40
 
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3104)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3105)
@@ -4,4 +4,8 @@
 // Screen Spaced Ambient Occlusion shader
 // based on shader of Alexander Kusternig
+
+#define USE_EYESPACE_DEPTH 0
+
+
 
 struct fragment
@@ -118,19 +122,20 @@
 								float2 texcoord0,
 								float3 oldEyePos,
-								sampler2D oldTex,
-								float4x4 oldModelViewProj,
-								float temporalCoherence,
-								float2 samples[NUM_SAMPLES],
-								sampler2D colors,
-								sampler2D noiseTex,
+								uniform sampler2D oldTex,
+								uniform float4x4 oldModelViewProj,
+								uniform float temporalCoherence,
+								uniform float2 samples[NUM_SAMPLES],
+								uniform sampler2D colors,
+								uniform sampler2D noiseTex,
 								float scaleFactor,
-								float3 bl,
-								float3 br,
-								float3 tl,
-								float3 tr, 
-								float3 oldbl,
-								float3 oldbr,
-								float3 oldtl,
-								float3 oldtr
+								uniform float3 bl,
+								uniform float3 br,
+								uniform float3 tl,
+								uniform float3 tr, 
+								uniform float3 oldbl,
+								uniform float3 oldbr,
+								uniform float3 oldtl,
+								uniform  float3 oldtr,
+								float invW
 								//,const uniform float4x4 inverseModelTrafo
 								//, float id
@@ -147,5 +152,7 @@
 	//else trafo = inverseModelTrafo * oldModelViewProj;
 
-	float3 translatedPt = worldPos.xyz - oldEyePos;
+	//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;
 
 	// reproject into old frame and calculate texture position of sample in old frame
@@ -158,4 +165,6 @@
 	// retrieve the sample from the last frame
 	const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));
+
+#if USE_EYESPACE_DEPTH
 	// calculate eye space position of sample in old frame
 	const float oldEyeSpaceDepth = oldPixel.w;
@@ -163,5 +172,4 @@
 	// vector from eye pos to old sample 
 	const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
-	
 	const float invlen = 1.0f / length(viewVec);
 	const float projectedEyeSpaceDepth = length(translatedPt) * invlen;
@@ -169,5 +177,16 @@
 	const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth);
 	//const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth) / 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;
+
+	// vector from eye pos to old sample 
+	const float depthDif = abs(projectedDepth - oldDepth);
+	//const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth) / projectedEyeSpaceDepth;
+#endif
+
 	float notValid = 0.5f;
 
@@ -219,5 +238,12 @@
 
 	illum_col.y = newWeight;
+
+#if USE_EYESPACE_DEPTH
 	illum_col.w = eyeSpaceDepth;
+#else
+	illum_col.w = projectedDepth;
+	illum_col.z = invW;
+#endif
+	
 	//illum_col.y = depthDif;
 
@@ -337,8 +363,9 @@
 	
 	float4 projPos = mul(modelViewProj, eyeSpacePos);
-	float w = SAMPLE_RADIUS / projPos.w;
+	const float w = 1 / projPos.w;
+	float scaleFactor = SAMPLE_RADIUS * w;
 	
 	const float2 ao = ssao(IN, colors, noiseTex, samples, normal, 
-		                   eyeSpacePos.xyz, w, bl, br, tl, tr, normalize(viewDir));
+		                   eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir));
 
 
@@ -349,5 +376,5 @@
 		                              oldTex, oldModelViewProj, temporalCoherence,
 		                              samples, colors, noiseTex, w, bl, br, tl, tr,
-									  oldbl, oldbr, oldtl, oldtr);
+									  oldbl, oldbr, oldtl, oldtr, scaleFactor);
 
 	//OUT.illum_col.xyz = normal * 0.5f + 0.5f;
@@ -358,5 +385,6 @@
 			 uniform sampler2D ssaoTex,
 			 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES],
-			 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES])
+			 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES],
+			 float scale)
 {
 	float average = .0f;
@@ -365,5 +393,5 @@
 	for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i)
 	{
-		average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i], 0, 0)).x;
+		average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i] * scale, 0, 0)).x;
 		w += filterWeights[i];
 	}
@@ -384,10 +412,11 @@
 	pixel OUT;
 
-	float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0));
+	const float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0));
 	float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));
 
-	//if (ao.y < 10.0f) ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights);
-
-	//OUT.illum_col = col * ao.x;
+	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);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3103)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3105)
@@ -175,4 +175,7 @@
 bool descendKeyPressed = false;
 bool ascendKeyPressed = false;
+bool leftStrafeKeyPressed = false;
+bool rightStrafeKeyPressed = false;
+
 bool altKeyPressed = false;
 
@@ -844,4 +847,21 @@
 
 
+void KeyStrafe(float shift)
+{
+	Vector3 viewDir = camera->GetDirection();
+	Vector3 pos = camera->GetPosition();
+
+	// the 90 degree rotated view vector 
+	// z zero so we don't move in the vertical
+	Vector3 rVec(viewDir[0], viewDir[1], 0);
+
+	Matrix4x4 rot = RotationZMatrix(M_PI * 0.5f);
+	rVec = rot * rVec;
+	pos += rVec * shift;
+
+	camera->SetPosition(pos);
+}
+
+
 /** Initialize the deferred rendering pass.
 */
@@ -899,4 +919,9 @@
 	if (descendKeyPressed)
 		KeyVerticalMotion(-KeyShift());
+	if (leftStrafeKeyPressed)
+		KeyStrafe(KeyShift());
+	if (rightStrafeKeyPressed)
+		KeyStrafe(-KeyShift());
+
 
 	// place view on ground
@@ -1218,4 +1243,12 @@
 		downKeyPressed = true;
 		break;
+	case 'j':
+	case 'J':
+		leftStrafeKeyPressed = true;
+		break;
+	case 'k':
+	case 'K':
+		rightStrafeKeyPressed = true;
+		break;
 	case 'r':
 	case 'R':
@@ -1297,5 +1330,12 @@
 		ascendKeyPressed = false;
 		break;
-	
+	case 'j':
+	case 'J':
+		leftStrafeKeyPressed = false;
+		break;
+	case 'k':
+	case 'K':
+		rightStrafeKeyPressed = false;
+		break;
 	default:
 		return;
@@ -1505,5 +1545,6 @@
 
 
-// strafe
+/** strafe
+*/
 void MiddleMotion(int x, int y) 
 {
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3104)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3105)
@@ -394,9 +394,10 @@
 	//const float filterWidth = 10.0f;
 	const float filterWidth = 5.0f;
+	//const float filterWidth = 60.0f;
 
 	//const float xoffs = filterWidth / mDownSampleFbo->GetWidth();
 	//const float yoffs = filterWidth / mDownSampleFbo->GetHeight();
-	const float xoffs = (float)filterWidth / 1024.0f;
-	const float yoffs = (float)filterWidth / 768.0f;
+	const float xoffs = (float)filterWidth / mWidth;
+	const float yoffs = (float)filterWidth / mHeight;
 
 	for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i)
@@ -543,5 +544,9 @@
 	sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix);
 
-	Vector3 de = mOldEyePos - mEyePos;
+	//Vector3 de = mOldEyePos - mEyePos;
+	Vector3 de;
+	de.x = mOldEyePos.x - mEyePos.x;
+	de.y = mOldEyePos.y - mEyePos.y; 
+	de.z = mOldEyePos.z - mEyePos.z;
 	//Vector3 de = mEyePos - mOldEyePos;
 
