Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3246)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3247)
@@ -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
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3246)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3247)
@@ -162,5 +162,5 @@
 
 		// the filtered ssao value
-		ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr);
+		//ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr);
 	}
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3231)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3247)
@@ -22,5 +22,6 @@
 };
 
-
+// this function is inspired from the paper of shamulgaan in order
+// to get a physical expression for the occlusion culling
 inline float occlusionPower(float radius, float dist)
 {
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 3235)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 3247)
@@ -172,5 +172,6 @@
 
 QuadraticDiscSampleGenerator2D::QuadraticDiscSampleGenerator2D(int numSamples, float radius):
-PoissonDiscSampleGenerator2D(numSamples, radius)
+//PoissonDiscSampleGenerator2D(numSamples, radius)
+RandomSampleGenerator2D(numSamples, radius)
 {}
 
@@ -193,5 +194,6 @@
 #else
 
-	PoissonDiscSampleGenerator2D::Generate(samples);
+	//PoissonDiscSampleGenerator2D::Generate(samples);
+	RandomSampleGenerator2D::Generate(samples);
 
 	Sample2 *s = (Sample2 *)samples;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 3230)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h	(revision 3247)
@@ -78,5 +78,6 @@
 	with the distance
 */
-class QuadraticDiscSampleGenerator2D: public PoissonDiscSampleGenerator2D
+//class QuadraticDiscSampleGenerator2D: public PoissonDiscSampleGenerator2D
+class QuadraticDiscSampleGenerator2D: public RandomSampleGenerator2D
 {
 public:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3246)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3247)
@@ -142,4 +142,6 @@
 ViewCell *viewCell = NULL;
 
+bool useSkylightForIllum = true;
+
 static int globalVisibleId = 0;
 
@@ -456,4 +458,6 @@
 		env.GetBoolParam(string("usePvs"), usePvs);
 
+		env.GetBoolParam(string("useSkylightForIllum"), useSkylightForIllum);
+
 		//env.GetStringParam(string("modelPath"), model_path);
 		//env.GetIntParam(string("numSssaoSamples"), numSsaoSamples);
@@ -488,5 +492,5 @@
 		cout << "use PVS: " << usePvs << endl;
 		cout << "visibilitySolution: " << visibilitySolution << endl;
-		
+		cout << "useSkylightForIllum" << useSkylightForIllum << endl;
 
 		//cout << "model path: " << model_path << endl;
@@ -571,5 +575,4 @@
 
 	//LoadModel("fisch.dem", dynamicObjects);
-	//LoadModel("hbuddha.dem", dynamicObjects);
 
 	//LoadModel("venusm.dem", dynamicObjects);
@@ -577,36 +580,41 @@
 	//LoadModel("toyplane2.dem", dynamicObjects);
 	//LoadModel("elephal.dem", dynamicObjects);
-
+	LoadModel("sibenik.dem", dynamicObjects);
+
+#if 1
+	LoadModel("hbuddha.dem", dynamicObjects);
+
+	buddha = dynamicObjects.back();
+	
+	const Vector3 sceneCenter(470.398f, 240.364f, 181.7f);
+	//const Vector3 sceneCenter(470.398f, 240.364f, 180.3);
+	
+	Matrix4x4 transl = TranslationMatrix(sceneCenter);
+	buddha->GetTransform()->SetMatrix(transl);
+
+	for (int i = 0; i < 10; ++ i)
+	{
+		SceneEntity *ent = new SceneEntity(*buddha);
+		resourceManager->AddSceneEntity(ent);
+
+		Vector3 offs = Vector3::ZERO();
+
+		offs.x = RandomValue(.0f, 50.0f);
+		offs.y = RandomValue(.0f, 50.0f);
+
+		Vector3 newPos = sceneCenter + offs;
+
+		transl = TranslationMatrix(newPos);
+		Transform3 *transform = resourceManager->CreateTransform(transl);
+
+		ent->SetTransform(transform);
+		dynamicObjects.push_back(ent);
+	}
+#endif
+
+	
 	resourceManager->mUseNormalMapping = false;
 	resourceManager->mUseSpecialColors = false;
 
-	/*
-	buddha = dynamicObjects.back();
-	
-	const Vector3 sceneCenter(470.398f, 240.364f, 181.7f);
-	//const Vector3 sceneCenter(470.398f, 240.364f, 180.3);
-	
-	Matrix4x4 transl = TranslationMatrix(sceneCenter);
-	buddha->GetTransform()->SetMatrix(transl);
-
-	for (int i = 0; i < 10; ++ i)
-	{
-		SceneEntity *ent = new SceneEntity(*buddha);
-		resourceManager->AddSceneEntity(ent);
-
-		Vector3 offs = Vector3::ZERO();
-
-		offs.x = RandomValue(.0f, 50.0f);
-		offs.y = RandomValue(.0f, 50.0f);
-
-		Vector3 newPos = sceneCenter + offs;
-
-		transl = TranslationMatrix(newPos);
-		Transform3 *transform = resourceManager->CreateTransform(transl);
-
-		ent->SetTransform(transform);
-		dynamicObjects.push_back(ent);
-	}
-	*/
 
 /*	int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects);
@@ -942,26 +950,27 @@
 	Vector3 sunDiffuse;
 
-#if 1
-	preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse, !useHDRValues);
-
-	ambient[0] = sunAmbient.x;
-	ambient[1] = sunAmbient.y;
-	ambient[2] = sunAmbient.z;
-
-	diffuse[0] = sunDiffuse.x;
-	diffuse[1] = sunDiffuse.y;
-	diffuse[2] = sunDiffuse.z;
-
-#else
-	
-	ambient[0] = .2f;
-	ambient[1] = .2f;
-	ambient[2] = .2f;
-
-	diffuse[0] = 1.0f;
-	diffuse[1] = 1.0f;
-	diffuse[2] = 1.0f;
-
-#endif
+	if (useSkylightForIllum)
+	{
+		preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse, !useHDRValues);
+
+		ambient[0] = sunAmbient.x;
+		ambient[1] = sunAmbient.y;
+		ambient[2] = sunAmbient.z;
+
+		diffuse[0] = sunDiffuse.x;
+		diffuse[1] = sunDiffuse.y;
+		diffuse[2] = sunDiffuse.z;
+	}
+	else
+	{
+
+		ambient[0] = .2f;
+		ambient[1] = .2f;
+		ambient[2] = .2f;
+
+		diffuse[0] = 1.0f;
+		diffuse[1] = 1.0f;
+		diffuse[2] = 1.0f;
+	}
 
 	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
@@ -1088,5 +1097,5 @@
 #endif
 
-
+/*
 		/////////////////////////
 		//-- update animations
@@ -1096,7 +1105,8 @@
 
 		Matrix4x4 rotMatrix = RotationZMatrix(rotAngle);
-		dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix);
+		dynamicObjects[2]->GetTransform()->MultMatrix(rotMatrix);
 
 		motionPath->Move(0.01f);
+		*/
 	}
 
@@ -1189,5 +1199,6 @@
 	{
 		if (!viewCellsTree) LoadVisibilitySolution();
-		LoadPvs();	
+
+		LoadPvs();
 	}
 
@@ -1309,7 +1320,14 @@
 		FrameBufferObject::Release();
 
-		if (!deferredShader) deferredShader = 
-			new DeferredRenderer(texWidth, texHeight, camera, ssaoUseFullResolution);
-		
+		if (!deferredShader) 
+		{
+			deferredShader = 
+				new DeferredRenderer(texWidth, texHeight, camera, ssaoUseFullResolution);
+
+			deferredShader->SetKernelRadius(ssaoKernelRadius);
+			deferredShader->SetSampleIntensity(ssaoSampleIntensity);
+			deferredShader->SetSsaoFilterRadius(ssaoFilterRadius);
+		}
+
 		DeferredRenderer::SHADING_METHOD shadingMethod;
 
@@ -1331,7 +1349,5 @@
 		deferredShader->SetShadingMethod(shadingMethod);
 		deferredShader->SetSamplingMethod(samplingMethod);
-		deferredShader->SetKernelRadius(ssaoKernelRadius);
-		deferredShader->SetSampleIntensity(ssaoSampleIntensity);
-		deferredShader->SetSsaoFilterRadius(ssaoFilterRadius);
+		
 		deferredShader->SetUseTemporalCoherence(useTemporalCoherence);
 		//deferredShader->SetSortSamples(sortSamples);
@@ -1475,23 +1491,29 @@
 		ssaoKernelRadius *= 0.8f;
 		cout << "new ssao kernel radius: " << ssaoKernelRadius << endl;
+		if (deferredShader) deferredShader->SetKernelRadius(ssaoKernelRadius);
 		break;
 	case '0':
 		ssaoKernelRadius *= 1.0f / 0.8f;
+		if (deferredShader) deferredShader->SetKernelRadius(ssaoKernelRadius);
 		cout << "new ssao kernel radius: " << ssaoKernelRadius << endl;
 		break;
 	case 'n':
 		ssaoSampleIntensity *= 0.9f;
+		if (deferredShader) deferredShader->SetSampleIntensity(ssaoSampleIntensity);
 		cout << "new ssao sample intensity: " << ssaoSampleIntensity << endl;
 		break;
 	case 'N':
 		ssaoSampleIntensity *= 1.0f / 0.9f;
+		if (deferredShader) deferredShader->SetSampleIntensity(ssaoSampleIntensity);
 		cout << "new ssao sample intensity: " << ssaoSampleIntensity << endl;
 		break;
 	case 'o':
 		ssaoFilterRadius *= 0.9f;
+		if (deferredShader) deferredShader->SetSsaoFilterRadius(ssaoFilterRadius);
 		cout << "new ssao filter radius: " << ssaoFilterRadius << endl;
 		break;
 	case 'O':
 		ssaoFilterRadius *= 1.0f / 0.9f;
+		if (deferredShader) deferredShader->SetSsaoFilterRadius(ssaoFilterRadius);
 		cout << "new ssao filter radius: " << ssaoFilterRadius << endl;
 		break;
@@ -2587,4 +2609,11 @@
 
 	viewCellsTree = visLoader.Load(vis_filename, bvh);
+
+	if (!viewCellsTree)
+	{
+		cerr << "loading pvs failed" << endl;
+		CleanUp();
+		exit(0);
+	}
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3246)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3247)
@@ -1426,4 +1426,5 @@
 {
 	mSampleIntensity = sampleIntensity;
+	mRegenerateSamples = true;
 }
 
@@ -1432,4 +1433,5 @@
 {
 	mKernelRadius = kernelRadius;
+	mRegenerateSamples = true;
 }
 
@@ -1438,4 +1440,5 @@
 {
 	mSsaoFilterRadius = ssaoFilterRadius;
+	mRegenerateSamples = true;
 }
 
