Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp	(revision 3104)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp	(revision 3112)
@@ -21,4 +21,5 @@
 
 
+
 /*********************************************************/
 /*         GPUProgramParameters implementation           */
@@ -52,4 +53,5 @@
 	mMatrices.clear();
 	mArrays.clear();
+	mMatrixArrays.clear();
 
 	mTimerParam = -1;
@@ -118,4 +120,13 @@
 
 
+void GPUProgramParameters::SetMatrixArray(int idx, float *mats, int numElements)
+{
+	if (mMatrixArrays.size() < idx + 1)
+		mMatrixArrays.resize(idx + 1);
+
+	mMatrixArrays[idx] = MatrixArrayParam(mats, numElements);
+}
+
+
 void GPUProgramParameters::SetTexture(int idx, unsigned int tex)
 {
@@ -199,4 +210,10 @@
 {
 	SetMatrix(mProgram->GetParamIdxByName(name), mat);
+}
+
+
+void GPUProgramParameters::SetMatrixArray(const string &name, float *mats, int numElements)
+{
+	SetMatrixArray(mProgram->GetParamIdxByName(name), mats, numElements);
 }
 
@@ -272,4 +289,12 @@
 	}
 
+	for (int i = 0; i < (int)mMatrixArrays.size(); ++ i)
+	{
+		const MatrixArrayParam &p = mMatrixArrays[i];
+
+		if (p.mValid)
+			mProgram->SetMatrixArray(i, p.mValues, p.mNumEntries);
+	}
+
 	if (mTimerParam >= 0)
 		mProgram->SetValue1f(mTimerParam, sCurrentTimer);
@@ -295,5 +320,4 @@
 	// transform to view space
 	cam->GetViewOrientationMatrix(vo);
-	//sCurrentLightDir = /*vo **/ -light->GetDirection();
 	sCurrentLightDir = vo * -light->GetDirection();
 }
@@ -441,4 +465,11 @@
 
 
+void ShaderProgram::SetMatrixArray(int idx, float *mats, int numElements)
+{
+	cgGLSetMatrixParameterArrayfc(GetParameter(idx), 0, numElements, (const float *)mats);
+}
+
+
+
 void ShaderProgram::SetTexture(int idx, unsigned int tex)
 {
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3057)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3112)
@@ -45,8 +45,11 @@
 	if(lastError)
 	{
-		printf("%s\n\n", cgGetErrorString(lastError));
+		Debug << "\n" << cgGetErrorString(lastError) << endl;
+		Debug << "\n" << cgGetLastListing(sCgContext) << endl;
+		/*printf("%s\n\n", cgGetErrorString(lastError));
 		printf("%s\n", cgGetLastListing(sCgContext));
-		
+		*/
 		printf("Cg error, exiting...\n");
+
 
 		exit(0);
@@ -63,4 +66,6 @@
 	// get the optimal fragment profile
 	sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
+	//sCgFragmentProfile = CG_PROFILE_GPU_FP;
+		//CG_PROFILE_FP40;;
 	cgGLSetOptimalOptions(sCgFragmentProfile);
 	// get the optimal vertex profile
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3111)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3112)
@@ -6,4 +6,6 @@
 
 #define USE_EYESPACE_DEPTH 1
+//#extension GL_EXT_gpu_shader4 : enable
+
 
 
@@ -130,7 +132,7 @@
 								uniform float3 tl,
 								uniform float3 tr, 
+								float3 projPos,
 								float invW,
-								float3 projPos,
-								float4x4 inverseModelTrafo,
+								float4x4 inverseModelTrafos[2],
 								float id,
 								uniform sampler2D noiseTex,
@@ -148,7 +150,11 @@
 	////////////
 	//-- dynamic objects
-	
+	/*float4x4 dummy;
+	uniform mat4 ident = float4x4(1);
+	x = dot(vec, ident[n]);
+*/
+	float4x4 dummyTrafo = inverseModelTrafos[(int)id];
 	//float4x4 trafo = (id < 10.0f) ? oldModelViewProj : mul(oldModelViewProj, inverseModelTrafo);
-	float4x4 trafo = mul(oldModelViewProj, inverseModelTrafo);
+	float4x4 trafo = mul(oldModelViewProj, dummyTrafo);
 
 	// compute translational portion
@@ -351,5 +357,5 @@
 		   uniform float3 oldtr,
 		   uniform sampler2D attribsTex,
-		   uniform float4x4 inverseModelTrafo
+		   uniform float4x4 inverseModelTrafos[2]
 		   )
 {
@@ -369,7 +375,7 @@
 	
 	float4 projPos = mul(modelViewProj, eyeSpacePos);
-	const float w = 1.0f / projPos.w;
-	projPos *= w;
-	float scaleFactor = SAMPLE_RADIUS * w;
+	const float invw = 1.0f / projPos.w;
+	projPos *= invw;
+	float scaleFactor = SAMPLE_RADIUS * invw;
 	
 	float2 ao = float2(1.0f, 0);
@@ -387,6 +393,14 @@
 	OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos,
 		                              oldTex, oldModelViewProj, temporalCoherence,
-		                              colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id.z,
-									  noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr);
+		                              colors, 
+									  bl, br, tl, tr, 
+									  projPos.xyz, 
+									  invw, 
+									  inverseModelTrafos,
+									  id.z,
+									  noiseTex, 
+									  samples, 
+									  scaleFactor, 
+									  oldbl, oldbr, oldtl, oldtr);
 
 	//OUT.illum_col.xyz = id;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h	(revision 3104)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h	(revision 3112)
@@ -56,5 +56,4 @@
 	void SetArray2f(int idx, float *vals, int numElements);
 	void SetArray3f(int idx, float *vals, int numElements);
-
 	/** Sets the texture parameter.
 	*/
@@ -63,4 +62,7 @@
 	*/
 	void SetMatrix(int idx, Matrix4x4 *mat);
+	/** Sets an array of matrices
+	*/
+	void SetMatrixArray(int idx, float *vals, int numElements);
 
 	////////////
@@ -96,4 +98,5 @@
 	void SetArray2f(const std::string &name, float *vals, int numElements);
 	void SetArray3f(const std::string &name, float *vals, int numElements);
+
 	/** Sets the texture parameter.
 	*/
@@ -102,4 +105,8 @@
 	*/
 	void SetMatrix(const std::string &name, Matrix4x4 *mat);
+	/** Sets an array of matrices
+	*/
+	void SetMatrixArray(const std::string &name, float *vals, int numElements);
+
 	/** Feeds the shader program with the parameter values.
 	*/
@@ -120,7 +127,5 @@
 		{
 			for (int i = 0; i < mNumComponents; ++ i)
-			{
 				mValues[i] = val[i];
-			}
 		}
 
@@ -164,4 +169,19 @@
 	};
 
+
+	struct MatrixArrayParam
+	{
+		MatrixArrayParam(): mValues(NULL), mNumEntries(0), mValid(false) {}
+		MatrixArrayParam(float *mats, int numEntries): 
+		mValues(mats), mNumEntries(numEntries), mValid(true)
+		{}
+
+		bool mValid;
+		float *mValues;
+
+		int mNumEntries;
+	};
+
+
 	/// the program this parameter set is connected to
 	ShaderProgram *mProgram;
@@ -176,4 +196,5 @@
 	std::vector<MatrixParam> mMatrices;
 	std::vector<ArrayParam> mArrays;
+	std::vector<MatrixArrayParam> mMatrixArrays;
 };
 
@@ -215,4 +236,5 @@
 	void SetArray3f(int idx, float *vals, int numElements);
 	void SetMatrix(int idx, const Matrix4x4 &mat);
+	void SetMatrixArray(int idx, float *mats, int numElements);
 
 	void SetTexture(int idx, unsigned int tex);
@@ -233,4 +255,7 @@
 	*/
 	void SetMatrix(const std::string &name, const Matrix4x4 &mat);
+	/** Sets array of matrices
+	*/
+	void SetMatrixArray(const std::string &name, float *mats, int numElements);
 	/** Sets the texture parameter.
 	*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3111)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3112)
@@ -529,5 +529,6 @@
 		dynamicObjects[i]->mId = 0;
 	
-	buddha->mId = 250;
+	//buddha->mId = 250;
+	buddha->mId = 1;
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3111)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3112)
@@ -340,5 +340,5 @@
 		 "samples", "bl", "br", "tl", "tr", 
 		 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 
-		 "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"};
+		 "oldtl", "oldtr", "attribsTex", "inverseModelTrafos"};
 	sCgSsaoProgram->AddParameters(ssaoParams, 0, 19);
 	
@@ -565,5 +565,14 @@
 	sCgSsaoProgram->SetTexture(i ++, attribsTex);
 
-	sCgSsaoProgram->SetMatrix(i ++, invTrafo);
+	float trafos[32];
+	for (int i = 0; i < 16; ++ i)
+		trafos[i] = ((const float *)invTrafo.x)[i];
+
+	static Matrix4x4 identity = IdentityMatrix();
+
+	for (int i = 0; i < 16; ++ i)
+		trafos[i+16] = ((const float *)identity.x)[i];
+
+	sCgSsaoProgram->SetMatrixArray(i ++, trafos, 2);
 	//sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix());
 
