Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 2905)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 2930)
@@ -10,20 +10,19 @@
 //#define SAMPLE_INTENSITY 40.0f
 
-// for quadradtc falloff
-//#define SAMPLE_INTENSITY 0.28f
+// for quadratic falloff
 #define SAMPLE_INTENSITY 0.32f
-//#define SAMPLE_INTENSITY 2.4f
+//#define SAMPLE_INTENSITY 0.85f
+//#define SAMPLE_INTENSITY 5.0f
 
+//#define AREA_SIZE 15e-1f
 //#define AREA_SIZE 25e-1f
-//#define AREA_SIZE 6e-1f
 #define AREA_SIZE 8e-1f
-//#define AREA_SIZE 5e-1f
 
 #define VIEW_CORRECTION_SCALE 0.0f
 //#define VIEW_CORRECTION_SCALE 0.1f
 
-//#define DISTANCE_SCALE 5e-7f
+//#define DISTANCE_SCALE 1e-4f
 #define DISTANCE_SCALE 1e-6f
-//#define DISTANCE_SCALE 0.0f
+//#define DISTANCE_SCALE 1e-8f
 
 #define ILLUM_INTENSITY 5e-1f;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 2903)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 2930)
@@ -6,7 +6,8 @@
 using namespace CHCDemoEngine;
 
-HaltonSequence SphericalSampleGenerator::sHalton;
-HaltonSequence PoissonDiscSampleGenerator::sHalton;
-HaltonSequence PseudoRandomGenerator::sHalton;
+HaltonSequence SphericalSampleGenerator3::sHalton;
+HaltonSequence PoissonDiscSampleGenerator2::sHalton;
+HaltonSequence RandomSampleGenerator2::sHalton;
+HaltonSequence QuadraticDiscSampleGenerator2::sHalton;
 
 
@@ -16,17 +17,16 @@
 
 
-PoissonDiscSampleGenerator::PoissonDiscSampleGenerator(int numSamples, float radius):
+PoissonDiscSampleGenerator2::PoissonDiscSampleGenerator2(int numSamples, float radius):
 SampleGenerator(numSamples, radius)
 {}
 
 
-void PoissonDiscSampleGenerator::Generate(float *samples) const
+void PoissonDiscSampleGenerator2::Generate(float *samples) const
 {
-	// this is a hacky poisson sampling generator which does random dart-throwing
-	// until it is not able to place any dart for a number of tries
-	// in this case, the required min distance is reduced
+	// this is a hacky poisson sampling generator which does random dart-throwing on a disc.
+	// as a savety criterium, the min distance requirement is relaxed if we are not 
+	// able to place any dart for a number of tries
 	// the solution is a possion sampling with respect to the adjusted min distance
 	// better solutions have been proposed, i.e., using hierarchical sampling
-
 	const float maxTries = 1000;
 	const float f_reduction = 0.9f;
@@ -36,12 +36,19 @@
 
 	// generates poisson distribution on disc
-	float minDist = 2.0f * mRadius / sqrt((float)mNumSamples);
+	// start with some threshold. best case: all samples lie on the circumference
+	//const float minDist = 2.0f * mRadius / sqrt((float)mNumSamples);
+	const float eps = 0.2f;
+	const float minDist = 2.0f * mRadius * M_PI * (1.0f - eps) / (float)mNumSamples;
+	float sqrMinDist = minDist * minDist;
 
 	//cout << "minDist before= " << minDist << endl;
 	Sample2 *s = (Sample2 *)samples;
 
+	int totalTries = 0;
+
+	// check if on disc
 	for (int i = 0; i < mNumSamples; ++ i)
 	{
-		int tries = 0, totalTries = 0;
+		int tries = 0;
 
 		// repeat until valid sample was found
@@ -51,8 +58,10 @@
 			++ totalTries;
 
-			r[0] = RandomValue(0, mRadius);
-			r[1] = RandomValue(0, mRadius);
-			//halton.GetNext(2, r);
+			// note: should use halton, but seems somewhat broken
+			//r[0] = RandomValue(.0f, mRadius);
+			//r[1] = RandomValue(.0f, mRadius);
+			sHalton.GetNext(2, r);
 
+			// scale to -1 .. 1
 			const float rx = r[0] * 2.0f - 1.0f;
 			const float ry = r[1] * 2.0f - 1.0f;
@@ -68,8 +77,8 @@
 			{
 				const float dist = 
-					sqrt((s[j].x - rx) * (s[j].x - rx) +
-					     (s[j].y - ry) * (s[j].y - ry));
+					(s[j].x - rx) * (s[j].x - rx) +
+					(s[j].y - ry) * (s[j].y - ry);
 			
-				if (dist < minDist)
+				if (dist < sqrMinDist)
 					sampleValid = false;
 			}
@@ -84,5 +93,5 @@
 			if (tries > maxTries)
 			{
-				minDist *= f_reduction;
+				sqrMinDist *= f_reduction;
 				tries = 0;
 			}
@@ -90,14 +99,14 @@
 	}
 
-	//cout << "minDist after= " << minDist << endl;
+	//cout << "minDist after= " << sqrt(sqrMinDist) << " #tries: " << totalTries << endl;
 }
 
 
-PseudoRandomGenerator::PseudoRandomGenerator(int numSamples, float radius):
+RandomSampleGenerator2::RandomSampleGenerator2(int numSamples, float radius):
 SampleGenerator(numSamples, radius)
 {}
 
 
-void PseudoRandomGenerator::Generate(float *samples) const
+void RandomSampleGenerator2::Generate(float *samples) const
 {
 	Sample2 *s = (Sample2 *)samples;
@@ -105,8 +114,14 @@
 	int numSamples = 0;
 
+	float r[2];
+
 	while (numSamples < mNumSamples)
 	{
-		const float rx = RandomValue(-mRadius, +mRadius);
-		const float ry = RandomValue(-mRadius, +mRadius);
+		//r[0] = RandomValue(-mRadius, mRadius);
+		//r[1] = RandomValue(-mRadius, mRadius);
+		sHalton.GetNext(2, r);
+		
+		const float rx = r[0] * 2.0f - 1.0f;
+		const float ry = r[1] * 2.0f - 1.0f;
 
 		// check if in disk, else exit early
@@ -122,10 +137,10 @@
 
 
-SphericalSampleGenerator::SphericalSampleGenerator(int numSamples, float radius):
+SphericalSampleGenerator3::SphericalSampleGenerator3(int numSamples, float radius):
 SampleGenerator(numSamples, radius)
 {}
 
 
-void SphericalSampleGenerator::Generate(float *samples) const
+void SphericalSampleGenerator3::Generate(float *samples) const
 {
 	float r[2];
@@ -136,6 +151,6 @@
 		r[0] = RandomValue(0, 1);
 		r[1] = RandomValue(0, 1);
+
 		//sHalton.GetNext(2, r);
-		//r[0] = pSamples[i].x; r[1] = pSamples[i].y;
 
 		// create stratified samples over sphere
@@ -147,5 +162,30 @@
 		s[i].z = mRadius * cos(theta);
 	}
+}
 
-	//delete [] pSamples;
+
+QuadraticDiscSampleGenerator2::QuadraticDiscSampleGenerator2(int numSamples, float radius):
+SampleGenerator(numSamples, radius)
+{}
+
+
+void QuadraticDiscSampleGenerator2::Generate(float *samples) const
+{
+	float r[2];
+	Sample2 *s = (Sample2 *)samples;
+
+	for (int i = 0; i < mNumSamples; ++ i)
+	{
+		//r[0] = samples[i * 2];
+		//r[1] = samples[i * 2 + 1];
+		sHalton.GetNext(2, r);
+
+		// create samples over disc: the sample density
+		// decreases quadratically with the distance to the origin
+		s[i].x = mRadius * r[1] * sin(2.0f * M_PI * r[0]);
+		s[i].y = mRadius * r[1] * cos(2.0f * M_PI * r[0]);
+
+		//s[i].x = mRadius * r[1] * r[1] * sin(2.0f * M_PI * r[0]);
+		//s[i].y = mRadius * r[1] * r[1] * cos(2.0f * M_PI * r[0]);
+	}
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2928)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2930)
@@ -53,5 +53,5 @@
 	void SetUseTemporalCoherence(bool temporal);
 
-	enum SAMPLING_METHOD {POISSON, GAUSS};
+	enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT};
 	enum SHADING_METHOD {DEFAULT, SSAO, GI};
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 2911)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 2930)
@@ -47,9 +47,9 @@
 
 
-class PseudoRandomGenerator: public SampleGenerator
+class RandomSampleGenerator2: public SampleGenerator
 {
 public:
 	
-	PseudoRandomGenerator(int numSamples, float radius);
+	RandomSampleGenerator2(int numSamples, float radius);
 
 	virtual void Generate(float *samples) const;
@@ -65,9 +65,9 @@
 	according to some d related to the number of samples.
 */
-class PoissonDiscSampleGenerator: public SampleGenerator
+class PoissonDiscSampleGenerator2: public SampleGenerator
 {
 public:
 	
-	PoissonDiscSampleGenerator(int numSamples, float radius);
+	PoissonDiscSampleGenerator2(int numSamples, float radius);
 
 	virtual void Generate(float *samples) const;
@@ -78,11 +78,30 @@
 };
 
-/** This class generates random spherical samples.
+
+/** This class generates random samples on a disc
+	that have the property that their density decreases quadratically
+	with the distance
 */
-class SphericalSampleGenerator: public SampleGenerator
+class QuadraticDiscSampleGenerator2: public SampleGenerator
 {
 public:
 	
-	SphericalSampleGenerator(int numSamples, float radius);
+	QuadraticDiscSampleGenerator2(int numSamples, float radius);
+
+	virtual void Generate(float *samples) const;
+
+protected:
+
+	static HaltonSequence sHalton;
+};
+
+
+/** This class generates random spherical samples.
+*/
+class SphericalSampleGenerator3: public SampleGenerator
+{
+public:
+	
+	SphericalSampleGenerator3(int numSamples, float radius);
 
 	virtual void Generate(float *samples) const;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2929)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2930)
@@ -171,5 +171,5 @@
 bool useLODs = true;
 
-DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::POISSON;
+DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::SAMPLING_POISSON;
 
 bool useAdvancedShading = false;
@@ -1180,8 +1180,6 @@
 	case 'P':
 	case 'p':
-		if (samplingMethod == DeferredRenderer::GAUSS)
-			samplingMethod = DeferredRenderer::POISSON;
-		else
-			samplingMethod = DeferredRenderer::GAUSS;
+		samplingMethod = DeferredRenderer::SAMPLING_METHOD((samplingMethod + 1) % 3);
+		cout << "ssao sampling method: " << samplingMethod << endl;
 		break;
 	case 'Y':
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2928)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2930)
@@ -138,22 +138,20 @@
 	switch (sampling)
 	{
-	case DeferredRenderer::POISSON:
+	case DeferredRenderer::SAMPLING_POISSON:
 		{
-			PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f);
+			PoissonDiscSampleGenerator2 poisson(NUM_SAMPLES, 1.0f);
 			poisson.Generate((float *)samples2);
 		}
 		break;
-	case DeferredRenderer::GAUSS:
+	case DeferredRenderer::SAMPLING_QUADRATIC:
 		{
-			//PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f);
-			//poisson.Generate((float *)samples2);
-
-			PseudoRandomGenerator pseudo(NUM_SAMPLES, 1.0f);
-			pseudo.Generate((float *)samples2);
+			QuadraticDiscSampleGenerator2 g(NUM_SAMPLES, 1.0f);
+			g.Generate((float *)samples2);
 		}
 		break;
-	default:
-		cout << "should not come here" << endl;
-		break;
+	default: // SAMPLING_DEFAULT
+
+		RandomSampleGenerator2 g(NUM_SAMPLES, 1.0f);
+		g.Generate((float *)samples2);
 	}
 #endif
@@ -225,5 +223,5 @@
 mUseTemporalCoherence(true),
 mRegenerateSamples(true),
-mSamplingMethod(POISSON),
+mSamplingMethod(SAMPLING_POISSON),
 mShadingMethod(DEFAULT),
 mFboIndex(0)
