Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2986)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2988)
@@ -83,5 +83,5 @@
 	OUT.color = col;
 
-	OUT.color.xyz = color.w / 1e3f;
+	OUT.color.xyz = color.w;
 	
 #if 1
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2984)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2988)
@@ -95,5 +95,5 @@
 	// hack: squeeze some information about ambient into the texture
 	//pix.col.w = glstate.material.emission.x;
-	pix.col.w = length(currentPos - IN.worldPos);
+	pix.col.w = length((currentPos - IN.worldPos) * maxDepth);
 
 	return pix;
@@ -118,5 +118,5 @@
 	// hack: squeeze some information about the ambient term into the target
 	//pix.col.w = glstate.material.emission.x;
-	pix.col.w = length(currentPos - IN.worldPos);
+	pix.col.w = length((currentPos - IN.worldPos) * maxDepth);
 
 	return pix;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2987)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2988)
@@ -55,14 +55,28 @@
 }
 
+
 float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr)
 {
 	//float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f);
-	float3 x1 = bl * (1.0f - w.x) + br * w.x;
-	float3 x2 = tl * (1.0f - w.x) + tr * w.x;
-
-	float3 v = x1 * (1.0f - w.y) + x2 * w.y;
+	float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x;
+	float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x;
+
+	float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y;
 
 	return v;
 }
+
+
+float2 Interpol2(float2 w, float2 bl, float2 br, float2 tl, float2 tr)
+{
+	//float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f);
+	float2 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x;
+	float2 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x;
+
+	float2 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y;
+
+	return v;
+}
+
 
 /** The ssao shader returning the an intensity value between 0 and 1
@@ -81,6 +95,5 @@
 		   uniform float3 br,
 		   uniform float3 tl,
-		   uniform float3 tr,
-		   uniform float maxDepth
+		   uniform float3 tr
 		   )
 {
@@ -92,6 +105,4 @@
 	float numSamples = 0;
 
-	const float y_angle = 0.43633231299858239423092269212215;
-	const float x_angle = 0.58177641733144319230789692282954;
 
 	for (int i = 0; i < NUM_SAMPLES; ++ i) 
@@ -117,8 +128,8 @@
 		float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w;
 
-		float newOffs = 0.5f + offsetTransformed * 0.5f;
+		float2 newOffs = 0.5f + offsetTransformed * 0.5f;
 
 		float3 rotView = normalize(Interpol(newOffs, bl, br, tl, tr));
-		float3 sample_position = (eyePos - rotView * eyeSpaceDepth) / maxDepth;
+		float3 sample_position = eyePos - rotView * eyeSpaceDepth;
 		//float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz;
 
@@ -180,5 +191,11 @@
 	// the current world position
 	const float4 centerPosition = tex2D(positions, IN.texCoord.xy);
-	// the current color
+
+	const float eyeDepth = tex2D(colors, IN.texCoord.xy).w;
+	float3 view2 = normalize(Interpol(IN.texCoord.xy, bl, br, tl, tr));
+	
+	float4 centerPosition2;
+	centerPosition2.xyz = eyePos - view2 * eyeDepth;
+	// the current depth
 	const float currentDepth = centerPosition.w;
 
@@ -186,15 +203,7 @@
 	float3 viewDir = normalize(IN.view);
 
-/*	const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w;
-
-	float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 
-
-	OUT.illum_col.xyz = centerPosition.xyz * maxDepth -  sample_position;
-	OUT.illum_col.w = currentDepth;
-	return OUT;
-*/
 	//const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos);
-	const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos, positions,
-		bl, br, tl, tr, maxDepth);
+	const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition2, w, viewDir, eyePos, positions,
+		bl, br, tl, tr);
 		
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2987)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2988)
@@ -357,8 +357,8 @@
 		sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples");
 
-		sTLParam = cgGetNamedParameter(sCgSsaoProgram, "bl"); 
-		sTRParam = cgGetNamedParameter(sCgSsaoProgram, "br"); 
-		sBRParam = cgGetNamedParameter(sCgSsaoProgram, "tl"); 
-		sBLParam = cgGetNamedParameter(sCgSsaoProgram, "tr"); 
+		sTLParam = cgGetNamedParameter(sCgSsaoProgram, "tl"); 
+		sTRParam = cgGetNamedParameter(sCgSsaoProgram, "tr"); 
+		sBRParam = cgGetNamedParameter(sCgSsaoProgram, "br"); 
+		sBLParam = cgGetNamedParameter(sCgSsaoProgram, "bl"); 
 	}
 	else
@@ -676,5 +676,5 @@
 	cgGLSetParameter1f(sMaxDepthParam, mScaleFactor);
 
-	Vector3 pos = mCamera->GetPosition();
+	Vector3 pos = mCamera->GetPosition() / mScaleFactor;
 	cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z);
 	
@@ -700,7 +700,7 @@
 	ComputeViewVectors(tl, tr, bl, br);
 
-	cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z);
 	cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z);
 	cgGLSetParameter3f(sBRParam, br.x, br.y, br.z);
+	cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z);
 	cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z);
 
@@ -730,39 +730,4 @@
 }
 
-Vector3 RotateY(Vector3 v, float a)
-{
-	Vector3 r;
-
-	r.z = v.z * cos(a) - v.x * sin(a);
-	r.x = v.z * sin(a) + v.x * cos(a);
-	r.y = v.y;
-
-	return r;
-}
-
-
-Vector3 RotateX(Vector3 v, float a)
-{
-	Vector3 r;
-
-	r.y = v.y * cos(a) - v.z * sin(a);
-	r.z = v.y * sin(a) + v.z * cos(a);
-	r.x = v.x;
-
-	return r;
-}
-
-
-Vector3 RotateZ(Vector3 v, float a)
-{
-	Vector3 r;
-
-	r.x = v.x * cos(a) - v.y * sin(a);
-	r.y = v.x * sin(a) + v.y * cos(a);
-	r.z = v.z;
-
-	return r;
-}
-
 
 Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr)
@@ -788,10 +753,4 @@
 	tl = Normalize(ntl - ftl);
 	tr = Normalize(ntr - ftr);
-
-
-	Vector3 dummy = Normalize(Interpol(0, 0, bl, br, tl, tr));
-	Vector3 dummy2 = Normalize(Interpol(0.5f, 0.5f, bl, br, tl, tr));
-
-	cout << "here3: " << dummy2 << " " << -mCamera->GetDirection() << endl;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2986)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2988)
@@ -162,6 +162,4 @@
 	const Vector3 fc = pos + view * z_far; 
 	
-	cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl;
-
 	Vector3 t1, t2;
 
