Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2986)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2987)
@@ -53,4 +53,15 @@
 
 	return r;
+}
+
+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;
+
+	return v;
 }
 
@@ -70,5 +81,6 @@
 		   uniform float3 br,
 		   uniform float3 tl,
-		   uniform float3 tr
+		   uniform float3 tr,
+		   uniform float maxDepth
 		   )
 {
@@ -105,11 +117,8 @@
 		float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w;
 
-		float rotx = offsetTransformed.x * -x_angle;
-		float roty = offsetTransformed.y * -y_angle;
-
-		float3 rotView_x = RotateY(viewDir, x_angle);
-		float3 rotView = RotateX(rotView_x, y_angle);
-
-		float3 sample_position = eyePos - rotView * eyeSpaceDepth;
+		float 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 = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz;
 
@@ -177,18 +186,15 @@
 	float3 viewDir = normalize(IN.view);
 
-	/*const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w;
+/*	const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w;
 
 	float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 
 
-	OUT.illum_col.xyz = centerPosition.xyz - sample_position;
+	OUT.illum_col.xyz = centerPosition.xyz * maxDepth -  sample_position;
 	OUT.illum_col.w = currentDepth;
-	return OUT;*/
-
+	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,
-		uniform float3 bl,
-		uniform float3 br,
-		uniform float3 tl,
-		uniform float3 tr);
+		bl, br, tl, tr, maxDepth);
 		
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2986)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2987)
@@ -85,4 +85,8 @@
 static CGparameter sPositionsTexCombinedSsaoParam;
 
+static CGparameter sTLParam;
+static CGparameter sTRParam;
+static CGparameter sBRParam;
+static CGparameter sBLParam;
 
 ////////////
@@ -352,4 +356,9 @@
 		sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex");  
 		sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples");
+
+		sTLParam = cgGetNamedParameter(sCgSsaoProgram, "bl"); 
+		sTRParam = cgGetNamedParameter(sCgSsaoProgram, "br"); 
+		sBRParam = cgGetNamedParameter(sCgSsaoProgram, "tl"); 
+		sBLParam = cgGetNamedParameter(sCgSsaoProgram, "tr"); 
 	}
 	else
@@ -691,4 +700,10 @@
 	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(sTRParam, tr.x, tr.y, tr.z);
+
+
 	glBegin(GL_QUADS);
 
@@ -750,4 +765,17 @@
 }
 
+
+Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr)
+{
+	//float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f);
+	Vector3 x1 = bl * (1.0f - wx) + br * wx;
+	Vector3 x2 = tl * (1.0f - wx) + tr * wx;
+
+	Vector3 v = x1 * (1.0f - wy) + x2 * wy;
+
+	return v;
+}
+
+
 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br)
 {
@@ -761,24 +789,10 @@
 	tr = Normalize(ntr - ftr);
 
-	const float y_angle = 0.43633231299858239423092269212215;
-	const float x_angle = 0.58177641733144319230789692282954;
-
-	const Vector3 view = mCamera->GetBaseDirection();
-
-	Vector3 rotView1 = RotateZ(-view, x_angle);
-	Vector3 rotView = RotateX(rotView1, y_angle);
-
-	cout << "view: " << -view << endl;
-	Matrix4x4 mat;
-	
-	mCamera->GetViewOrientationMatrix(mat);
-	rotView = mat * rotView;
-
-	cout << "x: " << rotView1 << " y: " << rotView << " " << tr << endl;
-
-	cout << "x: " << Magnitude(rotView1) << " y: " << Magnitude(rotView) << endl;
-	cout << "here3: " << acos(DotProd(rotView1, -view)) << " " << acos(DotProd(rotView, rotView1)) << endl;
-}
-
+
+	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;
+}
 
 
