Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3221)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3225)
@@ -6,7 +6,7 @@
 //-- ssao + gi parameters
 
-#define NUM_SAMPLES 8
+//#define NUM_SAMPLES 8
 //#define NUM_SAMPLES 16
-//#define NUM_SAMPLES 24
+#define NUM_SAMPLES 24
 //#define NUM_SAMPLES 48
 
@@ -58,5 +58,4 @@
 #define DYNAMIC_OBJECTS_THRESHOLD 1e-8f
 
-#define USE_GTX
 
 #endif // __SHADERENV_H
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3216)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3225)
@@ -138,7 +138,7 @@
 	const float minConvergence = min(m1, m2);
 
-	const float convergence = minConvergence;
+	//const float convergence = minConvergence;
 	//const float convergence = 0;
-	//const float convergence = ao.y;
+	const float convergence = ao.y;
 
 	// filter reaches size 1 pixel when sample size reaches threshold 
@@ -159,4 +159,5 @@
 	}
 
+	// just apply ssao if we are not in the sky
 	if (col.w < 1e10f)
 		OUT.illum_col.xyz = col.xyz * max(1e-1f, 1.0f - ao.x);
@@ -164,10 +165,16 @@
 		OUT.illum_col.xyz = col.xyz;
 
+
+	//OUT.illum_col.xyz = float3(abs(ao.y * 1e2f), abs(ao.z * 1e2f), abs(ao.w * 1e2f));
+
+	//if (convergence < (1.0f + NUM_SAMPLES * 10))
+	//	OUT.illum_col.xyz = float3(1 - convergence / (NUM_SAMPLES * 10), convergence / (NUM_SAMPLES * 10), 0);
+	
+	//OUT.illum_col.xyz = float3(ao.z * 1e4f, ao.z * 1e4f, ao.z * 1e4f);
+
 	//OUT.illum_col.xyz = float3(ao.x, ao.x, step(thres, convergence));
-	//OUT.illum_col.xyz = float3(0, convergence, 0);
 	//OUT.illum_col.xyz = float3(abs(center.x - IN.texCoord.x) * 16.0f, abs(center.y - IN.texCoord.y) * 12.0f, 0);
-	
-	//OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1);
 	//OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1);
+
 	OUT.illum_col.w = col.w;
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3221)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3225)
@@ -119,9 +119,7 @@
 	const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth);
 
-	const float xOffs = 1.0f / 1024.0f;
-	const float yOffs = 1.0f / 768.0f;
-	const float eps = 1e-6f;
-
-	// the weight of the old value
+	//const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; const float eps = 1e-6f;
+
+	// the weight of the accumulated samples from the previous frames
 	float w;
 
@@ -130,6 +128,8 @@
 
 	if (1
-		&& (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps)
-		&& (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps)
+	//	&& (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps)
+	//	&& (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps)
+		&& (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f)
+		&& (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f)
 		&& (depthDif <= MIN_DEPTH_DIFF) 
 		)
@@ -215,13 +215,6 @@
 		//const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f;
 
-#if 1
-		// if surface normal perpenticular to view dir, approx. half of the samples will not count
-		// => compensate for this (on the other hand, projected sampling area could be larger!)
-
-		const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);
-		total_ao += cosAngle * aoContrib * viewCorrection;
-#else
 		total_ao += cosAngle * aoContrib;
-#endif
+
 		// check if the samples have been valid in the last frame
 		validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x;
@@ -231,4 +224,12 @@
 
 	total_ao /= numSamples;
+
+#if 1
+	// if surface normal perpenticular to view dir, approx. half of the samples will not count
+	// => compensate for this (on the other hand, projected sampling area could be larger!)
+	const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);
+	total_ao += cosAngle * aoContrib * viewCorrection;
+
+#endif
 
 	return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples);
@@ -302,13 +303,5 @@
 		//const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f;
 
-#if 1
-		// if surface normal perpenticular to view dir, approx. half of the samples will not count
-		// => compensate for this (on the other hand, projected sampling area could be larger!)
-
-		const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);
-		total_ao += cosAngle * aoContrib * viewCorrection;
-#else
 		total_ao += cosAngle * aoContrib;
-#endif
 
 		++ numSamples;
@@ -325,5 +318,5 @@
 		validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid);
 
-#ifdef QWQ//USE_GTX
+#ifdef USE_GTX
 		// we can bail out early and use a minimal #samples)
 		// if some conditions are met as long as the hardware supports it
@@ -337,9 +330,15 @@
 		}
 #endif
-
-	}
-
-	// scale ao contribution
+	}
+
+	// "normalize" ao contribution
 	total_ao /= numSamples;
+
+#if 1
+	// if surface normal perpenticular to view dir, approx. half of the samples will not count
+	// => compensate for this (on the other hand, projected sampling area could be larger!)
+	const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);
+	total_ao *= viewCorrection;
+#endif
 
 	return float3(total_ao, validSamples, numSamples);
@@ -434,5 +433,7 @@
 	const float newWeight = ao.z;
 
+	// completely reset the ao in this pixel
 	const float completelyResetThres = 4.0f;
+	// don't fully reset the ao in this pixel, but give low weight to old solution
 	const float partlyResetThres = 1.0f;
 	
@@ -440,7 +441,12 @@
 	{
 		if (ao.y > completelyResetThres) 
+		{
 			oldWeight = .0f; 
+		}
 		else if (ao.y > partlyResetThres)
-			oldWeight = min(oldWeight, 4.0f * newWeight);
+		{
+			//oldWeight = min(oldWeight, 4.0f * newWeight);
+			oldWeight = .0f; 
+		}
 	}
 
@@ -448,12 +454,17 @@
 	const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence);
 
+
 	//////////
 	//-- blend ao between old and new samples (and avoid division by zero)
+
 	OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight);
 
+	OUT.illum_col.y = combinedWeight;
+	// can be used to check if this pixel belongs to a moving object
 	OUT.illum_col.z = SqrLen(diffVec);
-	OUT.illum_col.y = combinedWeight;
 	OUT.illum_col.w = eyeSpaceDepth;
 
+	//OUT.illum_col.yzw = diffVec;
+
 	return OUT;
 }
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3224)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3225)
@@ -131,4 +131,6 @@
 StatsWriter *statsWriter = NULL;
 
+bool makeSnapShot = false;
+
 
 /// the technique used for rendering
@@ -1038,9 +1040,11 @@
 	//-- update animations
 
-	Matrix4x4 rotMatrix = RotationZMatrix(M_PI * 1e-3f);
+	//const float rotAngle = M_PI * 1e-3f;
+	const float rotAngle = 1.0f * M_PI / 180.0f;
+
+	Matrix4x4 rotMatrix = RotationZMatrix(rotAngle);
 	dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix);
 
 	motionPath->Move(0.01f);
-
 
 
@@ -1263,4 +1267,6 @@
 		}
 
+		static int snapShotIdx = 0;
+
 		deferredShader->SetSunVisiblePixels(sunVisiblePixels);
 		deferredShader->SetShadingMethod(shadingMethod);
@@ -1271,5 +1277,13 @@
 		deferredShader->SetUseTemporalCoherence(useTemporalCoherence);
 		deferredShader->SetSortSamples(sortSamples);
-		deferredShader->SetSaveFrame(recordedFramesSuffix, (recordFrames && replayPath) ? currentReplayFrame : -1);
+
+		if (recordFrames && replayPath)
+			deferredShader->SetSaveFrame(recordedFramesSuffix, currentReplayFrame);
+		else if (makeSnapShot)
+			deferredShader->SetSaveFrame("snap", snapShotIdx ++);		
+		else
+			deferredShader->SetSaveFrame("", -1);		
+
+		if (makeSnapShot) makeSnapShot = false;
 
 		ShadowMap *sm = showShadowMap ? shadowMap : NULL;
@@ -1503,4 +1517,8 @@
 		// move light source instead of camera tilt
 		moveLight = !moveLight;
+		break;
+	case '#':
+		// make a snapshot of the current frame
+		makeSnapShot = true;
 		break;
 	default:
@@ -2379,8 +2397,11 @@
 	cout << "\nloading model " << filename << endl;
 	if (resourceManager->Load(filename, entities))
+	{
 		cout << "model " << filename << " successfully loaded" << endl;
+	}
 	else
 	{
 		cerr << "loading model " << filename << " failed" << endl;
+
 		CleanUp();
 		exit(0);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3221)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3225)
@@ -112,5 +112,5 @@
 				EnableFiberSafeOptimizations="true"
 				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include;&quot;$(CG_INC_PATH)&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET;NOT_USE_GTX"
 				StringPooling="true"
 				RuntimeLibrary="2"
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3219)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3225)
@@ -146,3 +146,10 @@
 scenequery
 
-fix walk speed
+fix walk speed for deferred shading
+
+fix color bleeding
+fix ao2
+fix full resolution mode
+
+for the paper: make ao more efficient, for example we do not need to downsample normal texture for ao version 1
+also for full resolution mode: test what happens if we do not use downsampling, look why currently so slow with full resolution (was previously > 80 frame or so!!)
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3223)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3225)
@@ -88,5 +88,5 @@
 
 # use full resolution ssao (vs. half resoltion)
-ssaoUseFullResolution=0
+ssaoUseFullResolution=1
 # ssao kernel radius
 ssaoKernelRadius=8e-1f
