Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h	(revision 2947)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h	(revision 2986)
@@ -72,8 +72,10 @@
 	/** Returns the current projection matrix.
 	*/
-	void GetProjectionMatrix(Matrix4x4 &mat);
+	void GetProjectionMatrix(Matrix4x4 &mat) const;
 	/** Returns the current model view matrix.
 	*/
-	void GetModelViewMatrix(Matrix4x4 &mat);
+	void GetModelViewMatrix(Matrix4x4 &mat) const;
+
+	void GetViewOrientationMatrix(Matrix4x4 &mat) const;
 	/** Calculates a frustum from the projection and the modelview matrix.
 	*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2985)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2986)
@@ -83,10 +83,15 @@
 	OUT.color = col;
 
-OUT.color.w = color.w;
-
+	OUT.color.xyz = color.w / 1e3f;
+	
+#if 1
+
+	OUT.color.w = color.w;
+
+#else
 
 	////////////
 	//-- write out logaritmic luminance for tone mapping
-/*
+
 	float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL));
 
@@ -103,5 +108,7 @@
 	else
 		OUT.color.w = logLumScaled;
-*/
+
+#endif
+
 	return OUT;
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2985)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2986)
@@ -32,4 +32,26 @@
 
 
+float3 RotateY(float3 v, float a)
+{
+	float3 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;
+}
+
+
+float3 RotateX(float3 v, float a)
+{
+	float3 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;
+}
 
 /** The ssao shader returning the an intensity value between 0 and 1
@@ -43,5 +65,10 @@
 		   uniform float scaleFactor,
 		   uniform float3 viewDir,
-		   uniform float3 eyePos
+		   uniform float3 eyePos,
+		   uniform sampler2D positions,
+		   uniform float3 bl,
+		   uniform float3 br,
+		   uniform float3 tl,
+		   uniform float3 tr
 		   )
 {
@@ -52,4 +79,7 @@
 	float total_ao = 0.0;
 	float numSamples = 0;
+
+	const float y_angle = 0.43633231299858239423092269212215;
+	const float x_angle = 0.58177641733144319230789692282954;
 
 	for (int i = 0; i < NUM_SAMPLES; ++ i) 
@@ -75,6 +105,12 @@
 		float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w;
 
-		float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 
-		
+		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;
+		//float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz;
 
 		float3 vector_to_sample = sample_position - centerPosition.xyz;
@@ -117,5 +153,9 @@
 		   uniform float maxDepth,
 		   uniform float temporalCoherence,
-		   uniform float3 eyePos
+		   uniform float3 eyePos,
+		   uniform float3 bl,
+		   uniform float3 br,
+		   uniform float3 tl,
+		   uniform float3 tr
 		   )
 {
@@ -137,5 +177,18 @@
 	float3 viewDir = normalize(IN.view);
 
-	const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos);
+	/*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.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,
+		uniform float3 bl,
+		uniform float3 br,
+		uniform float3 tl,
+		uniform float3 tr);
 		
 
@@ -206,6 +259,6 @@
 	float4 ao = tex2D(ssaoTex, IN.texCoord.xy);
 
-	OUT.illum_col = col * ao.x;
-	//OUT.illum_col.w = ao.w;
+	//OUT.illum_col = col * ao.x;
+	OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w);
 	OUT.illum_col.w = col.w;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2985)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2986)
@@ -715,4 +715,38 @@
 }
 
+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;
+}
 
 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br)
@@ -726,4 +760,23 @@
 	tl = Normalize(ntl - ftl);
 	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;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2947)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2986)
@@ -80,5 +80,5 @@
 
 
-void Camera::GetProjectionMatrix(Matrix4x4 &mat)
+void Camera::GetProjectionMatrix(Matrix4x4 &mat) const
 {
 	glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat.x);
@@ -86,5 +86,5 @@
 
 
-void Camera::GetModelViewMatrix(Matrix4x4 &mat)
+void Camera::GetModelViewMatrix(Matrix4x4 &mat) const
 {
 	mat = mViewOrientation;
@@ -97,4 +97,10 @@
 
 
+void Camera::GetViewOrientationMatrix(Matrix4x4 &mat) const
+{
+	mat = mViewOrientation;
+}
+
+
 void Camera::CalcFrustum(Frustum &frustum)
 {
@@ -132,4 +138,5 @@
 	glLoadMatrixf((float *)m.x);
 }
+
 
 
@@ -155,4 +162,6 @@
 	const Vector3 fc = pos + view * z_far; 
 	
+	cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl;
+
 	Vector3 t1, t2;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 2982)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 2986)
@@ -10,5 +10,5 @@
 winHeight=768
 camPosition=483.398f 242.364f 186.078f
-camDirection=1 0 0
+#camDirection=1 0 0
 lightDirection=-0.8f 1.0f -0.7f
 #lightDirection=0.0f 0.0f -1.0f
