Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3227)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3230)
@@ -7,7 +7,9 @@
 
 //#define NUM_SAMPLES 8
-#define NUM_SAMPLES 16
+//#define NUM_SAMPLES 16
 //#define NUM_SAMPLES 24
-//#define NUM_SAMPLES 48
+#define NUM_SAMPLES 48
+
+#define MIN_SAMPLES 8
 
 #define DISTANCE_SCALE 1e-2f
@@ -27,6 +29,7 @@
 //-- reprojection
 
-#define MIN_DEPTH_DIFF 5e-3f
-#define PRECISION_SCALE 1e-1f
+//#define MIN_DEPTH_DIFF 5e-3f
+#define MIN_DEPTH_DIFF 1e-3f
+#define DYNAMIC_OBJECTS_THRESHOLD 1e-8f
 
 
@@ -57,5 +60,4 @@
 #define NUM_DOWNSAMPLES 9
 
-#define DYNAMIC_OBJECTS_THRESHOLD 1e-8f
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3227)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3230)
@@ -93,6 +93,4 @@
 	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 accumulated samples from the previous frames
 	float w;
@@ -102,6 +100,4 @@
 
 	if (1
-	//	&& (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)
@@ -232,5 +228,5 @@
 			float3 tr, 
 			float3 viewDir,
-			float newWeight,
+			float convergence,
 			float sampleIntensity,
 			bool isMovingObject
@@ -243,7 +239,5 @@
 	for (int i = 0; i < NUM_SAMPLES; ++ i) 
 	{
-		const float2 offset = samples[i];
-
-		float2 offsetTransformed;
+		float2 offset;
 
 		////////////////////
@@ -251,11 +245,17 @@
 		//-- (affects performance for some reason!)
 
-		float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy;
-		//float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord, 0, 0)).xy;
-		//offsetTransformed = myreflect(offset, mynoise);
-		offsetTransformed = myrotate(offset, mynoise.x);
+		if (convergence < 700)
+		{
+			float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy;
+			//offsetTransformed = myreflect(offset, mynoise);
+			offset = myrotate(samples[i], mynoise.x);
+		}
+		else
+		{
+			offset = samples[i];
+		}
 		
 		// weight with projected coordinate to reach similar kernel size for near and far
-		const float2 texcoord = IN.texCoord.xy + offsetTransformed * scaleFactor;
+		const float2 texcoord = IN.texCoord.xy + offset * scaleFactor;
 
 		const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f));
@@ -299,11 +299,12 @@
 		// we can bail out early and use a minimal #samples)
 		// if some conditions are met as long as the hardware supports it
-		if (numSamples >= 8)
+		if (numSamples >= MIN_SAMPLES)
 		{
+			//break;
 			// if the pixel belongs to a static object and all the samples stay valid in the current frame
 			if (!isMovingObject && (validSamples < 1.0f)) break;
 			// if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high 
 			// (=> there was no discontinuity recently)
-			else if (isMovingObject && (newWeight > NUM_SAMPLES * 5)) break;
+			else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break;
 		}
 #endif
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3227)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3230)
@@ -230,5 +230,5 @@
 	// compute position from old frame for dynamic objects + translational portion
 	//const float3 translatedPos = difVec - oldEyePos + worldPos.xyz;
-	const float3 translatedPos = - oldEyePos + worldPos.xyz;
+	const float3 translatedPos = -oldEyePos + worldPos.xyz;
 
 
@@ -276,10 +276,11 @@
 		pixelValid = pixelNotValid;
 	}
-	else if (!((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) &&
+	else if (//!((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) &&
 		// check if changed from dynamic to not dynamic object
 		((oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) ||
 		// check if we have a dynamic object and is a depth discontinuity
 		(
-		//(oldDynamic || newDynamic) && 
+		(oldDynamic || newDynamic) && 
+		//(depthDif > 1e-5f))))
 		(depthDif > MIN_DEPTH_DIFF))))
 	{	
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h	(revision 3227)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h	(revision 3230)
@@ -59,2 +59,5 @@
 	return rpt;
 }
+
+
+#define USE_GTX
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3212)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3230)
@@ -186,5 +186,5 @@
 	currentPos /= currentPos.w;
 	
-	const float currentDepth = currentPos.z * PRECISION_SCALE;
+	const float currentDepth = currentPos.z;
 
 	///////////
@@ -203,5 +203,5 @@
 
 	// the current depth projected into the old frame
-	const float projDepth = projPos.z * PRECISION_SCALE;
+	const float projDepth = projPos.z;
 
 	// fit from unit cube into 0 .. 1
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 3229)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 3230)
@@ -6,16 +6,20 @@
 using namespace CHCDemoEngine;
 
-//HaltonSequence PoissonDiscSampleGenerator2D::sHalton(2);
-//HaltonSequence RandomSampleGenerator2D::sHalton(2);
-//HaltonSequence QuadraticDiscSampleGenerator2D::sHalton(2);
-
 
 SampleGenerator::SampleGenerator(int numSamples, float radius):
 mNumSamples(numSamples), mRadius(radius)
-{}
+{
+	mHalton = new HaltonSequence(2);
+}
+
+
+SampleGenerator::~SampleGenerator()
+{
+	DEL_PTR(mHalton);
+}
 
 
 PoissonDiscSampleGenerator2D::PoissonDiscSampleGenerator2D(int numSamples, float radius):
-SampleGenerator(numSamples, radius), sHalton(HaltonSequence(2))
+SampleGenerator(numSamples, radius)
 {}
 
@@ -58,5 +62,5 @@
 
 			// note: should use halton, but seems somewhat broken
-			sHalton.GetNext(r);
+			mHalton->GetNext(r);
 
 			// scale to -1 .. 1
@@ -106,5 +110,5 @@
 
 RandomSampleGenerator2D::RandomSampleGenerator2D(int numSamples, float radius):
-SampleGenerator(numSamples, radius), sHalton(HaltonSequence(2))
+SampleGenerator(numSamples, radius)
 {}
 
@@ -120,5 +124,5 @@
 	while (numSamples < mNumSamples)
 	{
-		sHalton.GetNext(r);
+		mHalton->GetNext(r);
 		
 		const float rx = r[0] * 2.0f - 1.0f;
@@ -165,7 +169,4 @@
 QuadraticDiscSampleGenerator2D::QuadraticDiscSampleGenerator2D(int numSamples, float radius):
 PoissonDiscSampleGenerator2D(numSamples, radius)
-//SampleGenerator(numSamples, radius), 
-//sHalton(HaltonSequence(2)), 
-//mPoisson(PoissonDiscSampleGenerator2D(numSamples, radius))
 {}
 
@@ -179,5 +180,5 @@
 	for (int i = 0; i < mNumSamples; ++ i)
 	{
-		sHalton.GetNext(r);
+		mHalton->GetNext(r);
 
 		// create samples over disc: the sample density
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 3229)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 3230)
@@ -38,8 +38,11 @@
 	virtual void Generate(float *samples) const = 0;
 
+	virtual ~SampleGenerator();
+
 protected:
 
 	SampleGenerator() {};
 
+	HaltonSequence *mHalton;
 	int mNumSamples;
 	float mRadius;
@@ -54,8 +57,4 @@
 
 	virtual void Generate(float *samples) const;
-
-protected:
-
-	HaltonSequence &sHalton;
 };
 
@@ -72,8 +71,4 @@
 
 	virtual void Generate(float *samples) const;
-
-protected:
-
-	HaltonSequence &sHalton;
 };
 
@@ -90,9 +85,4 @@
 
 	virtual void Generate(float *samples) const;
-
-protected:
-
-	//PoissonDiscSampleGenerator2D &mPoisson;
-	//HaltonSequence &sHalton;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3225)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3230)
@@ -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;NOT_USE_GTX"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET"
 				StringPooling="true"
 				RuntimeLibrary="2"
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3227)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3230)
@@ -94,7 +94,7 @@
 # ssao sample intensity
 #ssaoSampleIntensity=0.2f
-ssaoSampleIntensity=1.0f
+ssaoSampleIntensity=0.8f
 # ssao temporal coherence factor
-tempCohFactor=1000.0f
+tempCohFactor=2000.0f
 # ssao filter radius
 ssaoFilterRadius=12.0f
