Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3294)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3375)
@@ -39,9 +39,6 @@
 /*
 	mIndices = new unsigned int[mNumVertices];
-
-	for (int i = 0; i < mNumVertices; ++ i)
-	{
-		mIndices[i] = i;
-	}*/
+	for (int i = 0; i < mNumVertices; ++ i)	{ mIndices[i] = i; }
+*/
 
 	// prepare vbos
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3373)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3375)
@@ -547,7 +547,8 @@
 				pixelValid = 100.0f;
 			}
-			else if ((cosAngle >= 0) && (distanceDiff > 1e-3f))
+			else if (/*(cosAngle >= 0) && */(distanceDiff > 1e-3f))
 			{
 				pixelValid = 5.0f;
+				//pixelValid = 100.0f;
 			}
 		}
@@ -732,5 +733,5 @@
 	if (ao.y > partlyResetThres)
 	{
-		const float factor = 2.0f;
+		const float factor = 3.0f;
 
 		oldWeight = min(oldWeight, factor * NUM_SAMPLES);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3372)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3375)
@@ -39,5 +39,5 @@
 	float4 outColor;
 
-#if 0
+#if 1
 	// hack: prevent to shade the sky
 	if (color.w > DEPTH_THRESHOLD)
@@ -47,10 +47,8 @@
 	else 
 	{
-		if (useAO > .5f)
-			outColor = (ambient * ao + diffuse) * color;
-		else
-			outColor = (ambient + diffuse) * color;
+		outColor = (useAO > .5f) ? (ambient * ao + diffuse) * color : (ambient + diffuse) * color;
 	}
 #else
+	// just output ambient occlusion
 	outColor = ao;
 #endif
@@ -81,6 +79,8 @@
 	
 	OUT.color = col;
+
 	// store scaled view vector so wie don't have to normalize for later
-	//OUT.color.w = color.w / length(IN.view);
+	if (0) OUT.color.w = color.w / length(IN.view);
+
 	OUT.color.w = color.w;
 
@@ -150,8 +150,12 @@
 				  uniform float3 br,
 				  uniform float3 tl,
-				  uniform float3 tr
+				  uniform float3 tr,
+				  uniform sampler2D aoTex,
+				  uniform float useAO
 				  )
 {
 	pixel OUT;
+
+	float4 ao = 1;//(useAO > .5f) ? tex2Dlod(aoTex, float4(IN.texCoord, 0, 0)) : 1.0f;
 
 	const float3 normal = tex2D(normals, IN.texCoord.xy);
@@ -192,7 +196,9 @@
 	const float4 ambient = glstate.light[0].ambient;
 	// compute shading
-	OUT.color = useShading ? (ambient + diffuse) * color : color;
+	OUT.color = useShading ? (ambient * ao + diffuse) * color : color * ao;
+	
 	// store scaled view vector from now on so wie don't have to normalize later (e.g., for ssao)
-	//OUT.color.w = color.w / lenView;
+	if (0) OUT.color.w = color.w / lenView;
+
 	OUT.color.w = color.w;
 
@@ -216,83 +222,4 @@
 	return color;
 }
-
-
-/** This shader computes the reprojection and checks
-	if the reprojected pixel from last frame is still
-	valid in the current frame
-*/
-/*inline float2 ComputeInfo(sampler2D oldTex,
-						  float4 color,
-						  float3 difVec,
-						  float2 texCoord,
-						  float3 viewDir,
-						  float3 oldEyePos,
-						  float4x4 modelViewProj,
-						  float4x4 oldModelViewProj,
-						  float3 oldbl,
-						  float3 oldbr,
-						  float3 oldtl,
-						  float3 oldtr,
-						  sampler2D myTex
-						  )
-{
-	// reconstruct position from the eye space depth
-	const float eyeSpaceDepth = color.w;
-	const float4 worldPos = float4(-viewDir * eyeSpaceDepth, 1.0f);
-
-	// compute position from old frame for dynamic objects + translational portion
-	const float3 translatedPos = -oldEyePos + worldPos.xyz + difVec;
-
-
-	/////////////////
-	//-- reproject into old frame and calculate texture position of sample in old frame
-
-	// note: the old model view matrix only holds the view orientation part
-	float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f));
-	backProjPos /= backProjPos.w;
-	
-	// fit from unit cube into 0 .. 1
-	const float2 oldTexCoords = backProjPos.xy * .5f + .5f;
-	
-	// retrieve the sample from the last frame
-	const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));
-	const float oldDiff = tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).x;
-
-	// calculate eye space position of sample in old frame
-	const float oldEyeSpaceDepth = oldPixel.w;
-
-	// vector from eye pos to old sample 
-	const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);
-	const float invLen = 1.0f / length(oldViewDir);
-	
-
-	// check if the pixel was outside of the frame buffer
-	if ((oldTexCoords.x <= .0f) || (oldTexCoords.x >= 1.0f) || 
-		(oldTexCoords.y <= .0f) || (oldTexCoords.y >= 1.0f)
-		)
-	{
-		isPixelValid = pixelIsNotValid;
-	}
-	else if (// check if changed from dynamic to not dynamic object
-   	         (
-			 // (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) ||
-			 (
-			  (oldEyeSpaceDepth < DEPTH_THRESHOLD) && (projectedEyeSpaceDepth < DEPTH_THRESHOLD) &&
-			  //(oldDynamic || newDynamic) &&  // check if we have a dynamic object 
-			  (depthDif > 5e-2f)))//MIN_DEPTH_DIFF)))
-			  ) // and there is a depth discontinuity
-	{	
-		isPixelValid = pixelCouldBeValid;
-	}
-	else 
-	{
-		isPixelValid = pixelIsValid;
-	}
-	
-	//isPixelValid = depthDif;
-
-	return float3(isPixelValid, abs(oldEyeSpaceDepth - projectedEyeSpaceDepth));
-}
-*/
 
 
@@ -365,21 +292,4 @@
 	const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz);
 
-	// do reprojection and filter out the pixels that are not save
-/*	const float2 pValid = PixelValid(oldTex,
-		                             color, 
-									 difVec.xyz,
-									 IN.texCoord,
-									 IN.view,
-									 oldEyePos,
-									 modelViewProj,							  
-									 oldModelViewProj,
-									 oldbl, oldbr, oldtl, oldtr,
-									 myTex
-									 );
-
-	pix.color = color;
-	pix.color.xy = pValid.xy;
-	pix.color.z = color.w;
-*/
 	const float3 translatedPos = 
 		ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3372)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3375)
@@ -537,7 +537,8 @@
 	string deferredShadowParams[] = 
 		{"colors", "normals", "shadowMap", "noiseTex", "shadowMatrix", 
-		 "sampleWidth", "lightDir", "eyePos", "samples", "weights"};
-	
-	sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 10);
+		 "sampleWidth", "lightDir", "eyePos", "samples", "weights",
+	     "aoTex", "useAO"};
+	
+	sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 12);
 	
 	////////////////
@@ -630,5 +631,5 @@
 	//-- pcf tabs for depth of field
 
-	// todo matt: it is stupid to put num samples and width of kernel into constructor => change this!!!
+	// todo matt: bad style to put #samples and width of kernel into constructor => change this!!!
 	PoissonDiscSampleGenerator2D poisson3(NUM_DOF_TABS, 1.0f);
 	poisson3.Generate((float *)dofSamples);
@@ -639,7 +640,4 @@
 		dofSamples[i].y *= 1.0f / mHeight;
 	}
-
-	//float dofWeights[NUM_PCF_TABS];
-	//sCgDOFProgram->SetArray1f(2, (float *)dofWeights, NUM_DOF_TABS);
 
 	PrintGLerror("init");
@@ -1148,4 +1146,5 @@
 	GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();
 	GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture();
+	GLuint aoTex = mTempFbo->GetColorBuffer(1)->GetTexture();
 
 	GLuint shadowTex = shadowMap->GetDepthTexture();
@@ -1167,4 +1166,7 @@
 	sCgDeferredShadowProgram->SetValue3f(6, lightDir.x, lightDir.y, lightDir.z);
 	sCgDeferredShadowProgram->SetValue3f(7, mEyePos.x, mEyePos.y, mEyePos.z);
+
+	sCgDeferredShadowProgram->SetTexture(10, aoTex);
+	sCgDeferredShadowProgram->SetValue1f(11, float(mShadingMethod == SSAO));
 
 	DrawQuad(sCgDeferredShadowProgram);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env	(revision 3362)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env	(revision 3375)
@@ -89,5 +89,5 @@
 
 # tone mapping
-useHDR=0
+useHDR=1
 # use antialiasing
 useAA=0
@@ -111,6 +111,6 @@
 ssaoKernelRadius=4e-1f
 # ssao sample intensity
-ssaoSampleIntensity=0.2f
-#ssaoSampleIntensity=0.8f
+#ssaoSampleIntensity=0.2f
+ssaoSampleIntensity=0.8f
 # ssao temporal coherence factor
 tempCohFactor=2000.0f
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env	(revision 3372)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env	(revision 3375)
@@ -31,4 +31,5 @@
 # renderMode: Frustum Culling, Stop And Wait, CHC, CHC ++
 renderMode=0
+
 
 ############
