Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3110)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3111)
@@ -145,16 +145,14 @@
 	float4 illum_col;
 
+
 	////////////
 	//-- dynamic objects
 	
-	float4x4 trafo;
-	
-	if (id < 10) 
-		trafo = oldModelViewProj;
-	else 
-		trafo = inverseModelTrafo * oldModelViewProj;
+	//float4x4 trafo = (id < 10.0f) ? oldModelViewProj : mul(oldModelViewProj, inverseModelTrafo);
+	float4x4 trafo = mul(oldModelViewProj, inverseModelTrafo);
 
 	// compute translational portion
 	const float3 translatedPt = worldPos.xyz - oldEyePos;
+
 
 	/////////////////
@@ -167,5 +165,4 @@
 	// fit from unit cube into 0 .. 1
 	const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f;
-	
 	// retrieve the sample from the last frame
 	const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));
@@ -173,4 +170,5 @@
 
 #if USE_EYESPACE_DEPTH
+
 	// calculate eye space position of sample in old frame
 	const float oldEyeSpaceDepth = oldPixel.w;
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 3085)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 3111)
@@ -60,4 +60,5 @@
 	static int colorBufferIdx;
 
+	Matrix4x4 invTrafo;
 
 protected:
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3110)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3111)
@@ -212,4 +212,6 @@
 static int sCurrentMrtSet = 0;
 
+static Matrix4x4 invTrafo = IdentityMatrix();
+
 
 //////////////
@@ -234,5 +236,5 @@
 ShadowMap *shadowMap = NULL;
 DirectionalLight *light = NULL;
-DeferredRenderer *ssaoShader = NULL;
+DeferredRenderer *deferredShader = NULL;
 
 //SceneEntity *cube = NULL;
@@ -462,5 +464,4 @@
 
 	LoadModel("hbuddha.dem", dynamicObjects);
-	//LoadModel("hbuddha2.dem", dynamicObjects);
 	buddha = dynamicObjects.back();
 	
@@ -528,5 +529,5 @@
 		dynamicObjects[i]->mId = 0;
 	
-	buddha->mId = 50;
+	buddha->mId = 250;
 
 
@@ -897,14 +898,11 @@
 void MainLoop() 
 {	
-	Vector3 oldPos = motionPath->GetCurrentPosition();
-
-	//motionPath->Move(0.3f);
-	motionPath->Move(0.01f);
-
-	nMatrix mat = 
-	Vector3 planepos = motionPath->GetCurrentPosition();
-
-	Matrix4x4 mat = TranslationMatrix(planepos);
-	buddha->GetTransform()->SetMatrix(mat);
+	static Matrix4x4 invTrafo = IdentityMatrix();
+
+	Vector3 buddhaPos = motionPath->GetCurrentPosition();
+	Matrix4x4 trafo = TranslationMatrix(buddhaPos);
+	buddha->GetTransform()->SetMatrix(trafo);
+
+	/////////////
 
 	Vector3 oldPos = camera->GetPosition();
@@ -1070,5 +1068,5 @@
 		FrameBufferObject::Release();
 
-		if (!ssaoShader) ssaoShader = 
+		if (!deferredShader) deferredShader = 
 			new DeferredRenderer(texWidth, texHeight, camera);
 		
@@ -1085,11 +1083,11 @@
 			shadingMethod = DeferredRenderer::DEFAULT;
 
-
-		ssaoShader->SetShadingMethod(shadingMethod);
-		ssaoShader->SetSamplingMethod(samplingMethod);
-		ssaoShader->SetUseTemporalCoherence(useTemporalCoherence);
+		deferredShader->invTrafo = invTrafo;
+		deferredShader->SetShadingMethod(shadingMethod);
+		deferredShader->SetSamplingMethod(samplingMethod);
+		deferredShader->SetUseTemporalCoherence(useTemporalCoherence);
 
 		ShadowMap *sm = showShadowMap ? shadowMap : NULL;
-		ssaoShader->Render(fbo, ssaoTempCohFactor, light, useHDR, sm);
+		deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, sm);
 	}
 
@@ -1130,4 +1128,19 @@
 
 	glutSwapBuffers();
+
+
+	/////////////////////////
+
+	//motionPath->Move(0.3f);
+	motionPath->Move(0.01f);
+	Vector3 oldBuddhaPos = buddhaPos;
+	// new position
+	buddhaPos = motionPath->GetCurrentPosition();
+
+	Vector3 diff = oldBuddhaPos - buddhaPos;
+	//Vector3 diff = buddhaPos - oldBuddhaPos;
+
+	invTrafo = TranslationMatrix(diff);
+	//cout<< "diff " << diff << endl;
 }
 
@@ -1704,5 +1717,5 @@
 	DEL_PTR(perfGraph);
 	DEL_PTR(fbo);
-	DEL_PTR(ssaoShader);
+	DEL_PTR(deferredShader);
 	DEL_PTR(light);
 	DEL_PTR(visCamera);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3110)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3111)
@@ -253,5 +253,6 @@
 mSamplingMethod(SAMPLING_POISSON),
 mShadingMethod(DEFAULT),
-mIllumFboIndex(0)
+mIllumFboIndex(0),
+invTrafo(IdentityMatrix())
 {
 	///////////
@@ -337,11 +338,13 @@
 	string ssaoParams[] = 
 		{"colors", "normals", "oldTex", "noiseTex", "temporalCoherence", 
-		 "samples", "bl", "br", "tl", "tr", "modelViewProj", "oldModelViewProj",
-		 "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"};
+		 "samples", "bl", "br", "tl", "tr", 
+		 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 
+		 "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"};
 	sCgSsaoProgram->AddParameters(ssaoParams, 0, 19);
 	
 	string giParams[] = 
 		{"colors", "normals", "noiseTex", "oldSsaoTex", "oldIllumTex", 
-		 "temporalCoherence", "samples", "bl", "br", "tl", "tr", "oldModelViewProj", "modelViewProj"};
+		 "temporalCoherence", "samples", "bl", "br", "tl", 
+		 "tr", "oldModelViewProj", "modelViewProj"};
 	sCgGiProgram->AddParameters(giParams, 0, 13);
 
@@ -562,5 +565,6 @@
 	sCgSsaoProgram->SetTexture(i ++, attribsTex);
 
-	sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix());
+	sCgSsaoProgram->SetMatrix(i ++, invTrafo);
+	//sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix());
 
 	DrawQuad(sCgSsaoProgram);
