Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3093)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3094)
@@ -73,5 +73,4 @@
 							   uniform float3 tr, 
 							   float2 texcoord0,
-							   float3 eyePos,
 							   float3 oldEyePos,
 							   uniform float3 oldbl,
@@ -87,5 +86,5 @@
 	float2 texCoord = texcoord0 + offsetTransformed * scaleFactor;
 	//texCoord.x += 0.5f / 1024.0f; texCoord.y += 0.5f / 768.0f;
-	const float3 samplePos = ReconstructSamplePos(colors, texCoord, bl, br, tl, tr) + eyePos;
+	const float3 samplePos = ReconstructSamplePos(colors, texCoord, bl, br, tl, tr);
 
 	// reproject into old frame and calculate projected depth
@@ -114,6 +113,5 @@
 	as well as a boolean that 
 */
-float4 temporalSmoothing(float4 currentProjPos,
-						 float4 worldPos,
+float4 temporalSmoothing(float4 eyeSpacePos,
 						 uniform sampler2D oldTex,
 						 const uniform float4x4 oldModelViewProj,
@@ -129,5 +127,4 @@
 						 uniform float3 tr, 
 						 float2 texcoord0,
-						 float3 eyePos,
 						 float eyeSpaceDepth,
 						 float3 oldEyePos,
@@ -151,5 +148,5 @@
 
 	// reproject into old frame and calculate projected depth
-	float4 backProjPos = mul(oldModelViewProj, worldPos);
+	float4 backProjPos = mul(oldModelViewProj, eyeSpacePos);
 	backProjPos /= backProjPos.w;
 	// fit from unit cube into 0 .. 1
@@ -162,18 +159,13 @@
 
 	const float oldEyeSpaceDepth = oldCol.w;
-	//oldTexCoords.x += 0.5f / 1024.0f; oldTexCoords.y += 0.5f / 768.0f;
 
 	float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
-	//float3 oldSamplePos = -viewVec * eyeSpaceDepth + oldEyePos;
-	float3 oldSamplePos = oldEyePos - viewVec * oldEyeSpaceDepth;
-
-	const float depthDif = length(oldSamplePos - worldPos.xyz);
-	const float dummy5 = abs(oldEyeSpaceDepth - eyeSpaceDepth);
-	//const float dummy5 = length(oldTexCoords - texcoord0) * 1e5f;
-	//const float dummy5 = depthDif;
+	float3 oldEyeSpacePos = oldEyePos - viewVec * oldEyeSpaceDepth;
+
+	const float depthDif = length(oldEyeSpacePos - eyeSpacePos.xyz);
 
 	float notValid = 0.5f;
 
-	for (int i = 0; i < NUM_SAMPLES; ++ i) 
+	/*for (int i = 0; i < NUM_SAMPLES; ++ i) 
 	{
 		float sampleDif = ComputeDifference(samples[i],
@@ -185,11 +177,10 @@
 							  bl, br, tl, tr, 
 							  texcoord0,
-							  eyePos,
 							  oldEyePos,
 							  oldbl, oldbr, oldtl, oldtr,
-							  worldPos.xyz);
+							  eyePos.xyz);
 
 		if (sampleDif >= 1e-1f) ++ notValid;
-	}
+	}*/
 
 	//if (notValid < 1.0f) temporalCoherence = 4.0f;
@@ -213,5 +204,5 @@
 		newWeight = oldWeight + 1.0f;
 		illum_col.x = (ao.x + oldCol.x * oldWeight) / newWeight;
-		if (notValid > 1.0f) newWeight = 2;
+		if (notValid > 1.0f) newWeight = 2.0f;
 	}
 	else
@@ -223,5 +214,5 @@
 	illum_col.y = newWeight;
 	illum_col.w = eyeSpaceDepth;
-	//illum_col.y = dummy5;
+	
 
 	return illum_col;
@@ -270,5 +261,4 @@
 
 		//if ((texcoord.x <= 1.0f) && (texcoord.x >= 0.0f) && (texcoord.y <= 1.0f) && (texcoord.y >= 0.0f)) ++ numSamples;
-
 		const float3 samplePos = ReconstructSamplePos(colors, texcoord, bl, br, tl, tr);
 
@@ -316,5 +306,4 @@
 		   uniform float4x4 oldModelViewProj,
 		   uniform float temporalCoherence,
-		   uniform float3 eyePos,
 		   uniform float3 bl,
 		   uniform float3 br,
@@ -335,6 +324,5 @@
 	const float3 viewDir = IN.view;
 	const float eyeSpaceDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w;
-	const float3 eyeSpacePos = -viewDir * eyeSpaceDepth;
-	const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f);
+	const float4 eyeSpacePos = float4(-viewDir * eyeSpaceDepth, 1);
 
 
@@ -342,11 +330,8 @@
 	//-- calculcate the current projected posiion (also used for next frame)
 	
-	float4 projPos = mul(modelViewProj, worldPos);
+	float4 projPos = mul(modelViewProj, eyeSpacePos);
+	float w = SAMPLE_RADIUS / projPos.w;
 	
-	float w = 1.0f / projPos.w;
-	projPos *= w;
-	w *= SAMPLE_RADIUS;
-	
-	const float2 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(viewDir));
+	const float2 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, w, bl, br, tl, tr, normalize(viewDir));
 
 
@@ -354,6 +339,6 @@
 	//-- compute temporally smoothing
 	
-	OUT.illum_col = temporalSmoothing(projPos, worldPos, oldTex, oldModelViewProj, temporalCoherence, ao,
-		                              samples, colors, noiseTex, w, bl, br, tl, tr, IN.texCoord, eyePos, eyeSpaceDepth,
+	OUT.illum_col = temporalSmoothing(eyeSpacePos, oldTex, oldModelViewProj, temporalCoherence, ao,
+		                              samples, colors, noiseTex, w, bl, br, tl, tr, IN.texCoord, eyeSpaceDepth,
 									  oldEyePos, oldbl, oldbr, oldtl, oldtr);
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3084)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3094)
@@ -158,5 +158,4 @@
 		   const uniform float4x4 modelViewProj,
 		   uniform float temporalCoherence,
-		   uniform float3 eyePos,
 		   uniform float3 bl,
 		   uniform float3 br,
@@ -177,10 +176,8 @@
 	const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w;
 	
-	const float3 eyeSpacePos = -viewDir * eyeDepth;
-
-	const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f);
+	const float4 eyeSpacePos = float4(-viewDir * eyeDepth, 1.0f);
 
 	// calculcate the current projected depth for next frame
-	float4 currentPos = mul(modelViewProj, worldPos);
+	float4 currentPos = mul(modelViewProj, eyeSpacePos);
 
 	const float w = SAMPLE_RADIUS / currentPos.w;
@@ -200,5 +197,5 @@
 	// reprojection new frame into old one 
 	// calculate projected depth
-	float4 projPos = mul(oldModelViewProj, worldPos);
+	float4 projPos = mul(oldModelViewProj, eyeSpacePos);
 	projPos /= projPos.w;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3093)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3094)
@@ -257,6 +257,7 @@
 	//-- the flip-flop fbos
 
-//	mIllumFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE);
-	mIllumFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
+	mIllumFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE);
+	//mIllumFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
+
 	mFBOs.push_back(mIllumFbo);
 
@@ -267,6 +268,6 @@
 	}
 
-	//mDownSampleFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE);
-	mDownSampleFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
+	mDownSampleFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE);
+	//mDownSampleFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
 	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
 	// downsample buffer for the normal texture
@@ -328,5 +329,4 @@
 	sCgSsaoProgram->AddParameter("oldTex", i ++);
 	sCgSsaoProgram->AddParameter("noiseTex", i ++);
-	sCgSsaoProgram->AddParameter("eyePos", i ++);
 	sCgSsaoProgram->AddParameter("temporalCoherence", i ++);
 	sCgSsaoProgram->AddParameter("samples", i ++);
@@ -350,5 +350,4 @@
 	sCgGiProgram->AddParameter("oldSsaoTex", i ++);
 	sCgGiProgram->AddParameter("oldIllumTex", i ++);
-	sCgGiProgram->AddParameter("eyePos", i ++);
 	sCgGiProgram->AddParameter("temporalCoherence", i ++);
 	sCgGiProgram->AddParameter("samples", i ++);
@@ -540,8 +539,5 @@
 	sCgSsaoProgram->SetTexture(3, noiseTex);
 
-	//sCgSsaoProgram->SetValue3f(4, mEyePos.x, mEyePos.y, mEyePos.z);
-	sCgSsaoProgram->SetValue3f(4, 0, 0, 0);
-
-	sCgSsaoProgram->SetValue1f(5, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0);
+	sCgSsaoProgram->SetValue1f(4, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0);
 	
 	if (mUseTemporalCoherence || mRegenerateSamples)
@@ -553,5 +549,5 @@
 		// needs longer to converge
 		GenerateSamples(mSamplingMethod); 
-		sCgSsaoProgram->SetArray2f(6, (float *)samples2, NUM_SAMPLES);
+		sCgSsaoProgram->SetArray2f(5, (float *)samples2, NUM_SAMPLES);
 	}
 	
@@ -561,14 +557,11 @@
 	Vector3 tr = mCornersView[3];
 
-	sCgSsaoProgram->SetValue3f(7, bl.x, bl.y, bl.z);
-	sCgSsaoProgram->SetValue3f(8, br.x, br.y, br.z);
-	sCgSsaoProgram->SetValue3f(9, tl.x, tl.y, tl.z);
-	sCgSsaoProgram->SetValue3f(10, tr.x, tr.y, tr.z);
-
-	//cout << "new projview:\n" << projViewMatrix << endl;
-	//cout << "old projview:\n" << oldProjViewMatrix << endl;
-
-	sCgSsaoProgram->SetMatrix(11, mProjViewMatrix);
-	sCgSsaoProgram->SetMatrix(12, mOldProjViewMatrix);
+	sCgSsaoProgram->SetValue3f(6, bl.x, bl.y, bl.z);
+	sCgSsaoProgram->SetValue3f(7, br.x, br.y, br.z);
+	sCgSsaoProgram->SetValue3f(8, tl.x, tl.y, tl.z);
+	sCgSsaoProgram->SetValue3f(9, tr.x, tr.y, tr.z);
+
+	sCgSsaoProgram->SetMatrix(10, mProjViewMatrix);
+	sCgSsaoProgram->SetMatrix(11, mOldProjViewMatrix);
 
 	bl = mOldCornersView[0];
@@ -578,11 +571,11 @@
 
 	Vector3 d = mOldEyePos - mEyePos;
-
-	//sCgSsaoProgram->SetValue3f(13, mOldEyePos.x, mOldEyePos.y, mOldEyePos.z);
-	sCgSsaoProgram->SetValue3f(13, d.x, d.y, d.z);
-	sCgSsaoProgram->SetValue3f(14, bl.x, bl.y, bl.z);
-	sCgSsaoProgram->SetValue3f(15, br.x, br.y, br.z);
-	sCgSsaoProgram->SetValue3f(16, tl.x, tl.y, tl.z);
-	sCgSsaoProgram->SetValue3f(17, tr.x, tr.y, tr.z);
+	//Vector3 d = mEyePos - mOldEyePos;
+
+	sCgSsaoProgram->SetValue3f(12, d.x, d.y, d.z);
+	sCgSsaoProgram->SetValue3f(13, bl.x, bl.y, bl.z);
+	sCgSsaoProgram->SetValue3f(14, br.x, br.y, br.z);
+	sCgSsaoProgram->SetValue3f(15, tl.x, tl.y, tl.z);
+	sCgSsaoProgram->SetValue3f(16, tr.x, tr.y, tr.z);
 
 	DrawQuad(sCgSsaoProgram);
@@ -692,8 +685,5 @@
 	sCgGiProgram->SetTexture(4, oldIllumTex);
 
-	sCgGiProgram->SetValue3f(5, mEyePos.x, mEyePos.y, mEyePos.z);
-
-
-	sCgGiProgram->SetValue1f(6, 
+	sCgGiProgram->SetValue1f(5, 
 		(mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0);
 
@@ -707,5 +697,5 @@
 		GenerateSamples(mSamplingMethod); 
 
-		sCgGiProgram->SetArray2f(7, (float *)samples2, NUM_SAMPLES);
+		sCgGiProgram->SetArray2f(6, (float *)samples2, NUM_SAMPLES);
 	}
 
@@ -715,11 +705,11 @@
 	Vector3 tr = mCornersView[3];
 
-	sCgGiProgram->SetValue3f(8, bl.x, bl.y, bl.z);
-	sCgGiProgram->SetValue3f(9, br.x, br.y, br.z);
-	sCgGiProgram->SetValue3f(10, tl.x, tl.y, tl.z);
-	sCgGiProgram->SetValue3f(11, tr.x, tr.y, tr.z);
-
-	sCgGiProgram->SetMatrix(12, mOldProjViewMatrix);
-	sCgGiProgram->SetMatrix(13, mProjViewMatrix);
+	sCgGiProgram->SetValue3f(7, bl.x, bl.y, bl.z);
+	sCgGiProgram->SetValue3f(8, br.x, br.y, br.z);
+	sCgGiProgram->SetValue3f(9, tl.x, tl.y, tl.z);
+	sCgGiProgram->SetValue3f(10, tr.x, tr.y, tr.z);
+
+	sCgGiProgram->SetMatrix(11, mOldProjViewMatrix);
+	sCgGiProgram->SetMatrix(12, mProjViewMatrix);
 
 
@@ -825,12 +815,9 @@
 	sCgDeferredShadowProgram->SetTexture(2, shadowTex);
 	sCgDeferredShadowProgram->SetTexture(3, noiseTex);
-
 	sCgDeferredShadowProgram->SetMatrix(4, shadowMatrix);
-
 	sCgDeferredShadowProgram->SetValue1f(5, 2.0f / shadowMap->GetSize());
 
 	const Vector3 lightDir = -light->GetDirection();
 	sCgDeferredShadowProgram->SetValue3f(6, lightDir.x, lightDir.y, lightDir.z);
-
 	sCgDeferredShadowProgram->SetValue3f(7, mEyePos.x, mEyePos.y, mEyePos.z);
 
