Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h	(revision 3284)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h	(revision 3285)
@@ -11,9 +11,13 @@
 class Bvh;
 
+#define USE_TIMESTAMPS
+
 struct PvsEntry
 {
 	PvsEntry(SceneEntity *ent, float t): 
 	mEntity(ent)
-	//, mTimeStamp(t) 
+#ifdef USE_TIMESTAMPS
+	, mTimeStamp(t)
+#endif
 	{}
 
@@ -24,5 +28,7 @@
 
 	SceneEntity *mEntity;
-	//float mTimeStamp;
+#ifdef USE_TIMESTAMPS
+	float mTimeStamp;
+#endif
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h	(revision 3279)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h	(revision 3285)
@@ -24,5 +24,9 @@
 	VisibilitySolutionLoader(): mNumNodes(0) {};
 
-	ViewCellsTree *Load(const std::string &filename, Bvh *bvh, float viewCellsScaleFactor = 1.0f);
+	ViewCellsTree *Load(const std::string &filename, 
+		                Bvh *bvh,
+						float &totalSamples,
+						float &totalTime,
+						float viewCellsScaleFactor = 1.0f);
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3275)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3285)
@@ -7,6 +7,6 @@
 
 //#define NUM_SAMPLES 8
-#define NUM_SAMPLES 16
-//#define NUM_SAMPLES 24
+//#define NUM_SAMPLES 16
+#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 3271)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3285)
@@ -115,5 +115,5 @@
 	float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));
 
-#if 1 // use half resolution
+#if 0 // for half resolution
 
 	// the following has to be done for half resolution ssao:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp	(revision 3284)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp	(revision 3285)
@@ -18,5 +18,8 @@
 ViewCellsTree *VisibilitySolutionLoader::Load(const std::string &filename,
 											  Bvh *bvh,
-											  float viewCellsScaleFactor)
+											  float &totalSamples,
+											  float &totalTime,
+											  float viewCellsScaleFactor
+											  )
 {
 	FILE *fr = fopen(filename.c_str(), "rb");
@@ -30,7 +33,4 @@
 	}
 
-	float totalSamples;
-	float totalTime;
-
 	fread(&totalSamples, sizeof(float), 1, fr);
 	fread(&totalTime, sizeof(float), 1, fr);
@@ -157,5 +157,5 @@
 	CreateIdSortedList2(bvh->GetStaticRoot(), nodes);
 	//CreateIdSortedList(bvh, nodes);
-	ofstream outstream("test.log");
+/*	ofstream outstream("test.log");
 
 	BvhNode *f = ((BvhInterior *)bvh->GetStaticRoot())->GetFront();
@@ -179,7 +179,10 @@
 		}
 	}
-		
+*/		
 	for (int i = 0; i < number; ++ i) 
 	{
+		if ((i % number / 10) ==  (number / 10 - 1))
+			cout << 100 * (i + 1) / 100 << "percent loaded" << endl;
+
 		fread(&entries, sizeof(int), 1, fw);
 
@@ -193,11 +196,10 @@
 	
 			BvhNode *node = nodes[objectId];
-			if (i == 100)
-				outstream << "t " << time << " ";
+			//if (i == 100) outstream << "t " << time << " ";
 			mViewCells[i]->mPvs.AddEntry(bvh, node, time);
 		}
 	}
 
-	outstream.close();
+	//outstream.close();
 
 	return true;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3284)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3285)
@@ -384,4 +384,7 @@
 void LoadPompeiiFloor();
 
+float pvsTotalSamples = .0f;
+float pvsTotalTime = .0f;
+
 
 // new view projection matrix of the camera
@@ -1131,5 +1134,5 @@
 #endif
 
-/*
+		/*
 		/////////////////////////
 		//-- update animations
@@ -1230,10 +1233,10 @@
 	glEnableClientState(GL_VERTEX_ARRAY);
 
-	if (1 && usePvs)
+	if (usePvs)
 	{
 		if (!viewCellsTree)	
 		{
+			LoadVisibilitySolution();
 			applicationTimer.Start();
-			LoadVisibilitySolution();
 		}
 
@@ -1471,4 +1474,5 @@
 		Debug << "camPosition=" << camera->GetPosition().x << " " << camera->GetPosition().y << " " << camera->GetPosition().z << endl;
 		Debug << "camDirection=" << camera->GetDirection().x << " " << camera->GetDirection().y << " " << camera->GetDirection().z << endl;
+		Debug << "lightDirection=" << light->GetDirection().x << " " << light->GetDirection().y << " " << light->GetDirection().z << endl;
 
 		CleanUp();
@@ -1787,5 +1791,9 @@
 		{
 			cout << "replaying path" << endl;
+
 			currentReplayFrame = -1;
+
+			// hack: load pvs on replay (remove later!)
+			usePvs = true;
 		}
 		else
@@ -2211,9 +2219,7 @@
 	static float rTime = 1000.0f;
 
-	// the render time used up purely for the traversal algorithm using glfinish
-	if (showAlgorithmTime)
-	{
-		if (algTime < 500) renderTime = algTime * expFactor + (1.0f - expFactor) * renderTime;
-	}
+	// the render time is used only for the traversal algorithm using glfinish
+	if (algTime < 500) renderTime = algTime * expFactor + (1.0f - expFactor) * renderTime;
+	
 
 	accumulatedTime += elapsedTime;
@@ -2224,5 +2230,4 @@
 
 		if (frameTime) fps = 1e3f / (float)frameTime;
-
 		rTime = renderTime;
 
@@ -2376,5 +2381,5 @@
 			, "CHC"
 			, "CHC ++"
-//			, "Collector"
+            //, "Collector"
 		};
 	
@@ -2396,5 +2401,6 @@
 		int mrays = (int)shotRays / 1000000;
 		sprintf(msg[7], "%s:  %04d M rays", alg_str[renderMode], mrays);	
-		myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color);
+		//myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color);
+		myfont.DrawString(msg[7], 1.3f, winWidth - 350, winHeight - 30.0f);//, top_color, bottom_color);
 #endif
 	}
@@ -2658,6 +2664,9 @@
 	viewCell = viewCellsTree->GetViewCell(camera->GetPosition());
 
-	// assume 60 FPS and 1M rays per second
-	const float scale = 1e6f / 60.0f;
+	// assume 60 FPS
+	const float raysPerMs = pvsTotalSamples / pvsTotalTime;
+	const float scale = renderTime * raysPerMs;
+
+	cout << "rays per sec: " << raysPerMs << endl;
 
 	//const float elapsedAlgorithmTime = applicationTimer.Elapsedms(false);
@@ -2669,6 +2678,9 @@
 	{
 		PvsEntry entry = viewCell->mPvs.GetEntry(i);
-
-		if (1)//(entry.mTimeStamp < 0.0f) || (entry.mTimeStamp <= shotRays))
+#ifdef USE_TIMESTAMPS
+		if ((entry.mTimeStamp < 0.0f) || (entry.mTimeStamp <= shotRays))
+#else
+		if (1)
+#endif
 		{
 			entry.mEntity->SetVisibleId(globalVisibleId);
@@ -2692,5 +2704,9 @@
 	VisibilitySolutionLoader visLoader;
 
-	viewCellsTree = visLoader.Load(vis_filename, bvh, viewCellsScaleFactor);
+	viewCellsTree = visLoader.Load(vis_filename, 
+		                           bvh,
+								   pvsTotalSamples,
+								   pvsTotalTime,
+								   viewCellsScaleFactor);
 
 	if (!viewCellsTree)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.cpp	(revision 3284)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.cpp	(revision 3285)
@@ -10,6 +10,9 @@
 bool operator<(const PvsEntry &a, const PvsEntry &b) 
 {
-   //return a.mTimeStamp < b.mTimeStamp;
+#ifdef USE_TIMESTAMPS
+	return a.mTimeStamp < b.mTimeStamp;
+#else
 	return true;
+#endif
 }
 
@@ -29,4 +32,5 @@
 void Pvs::Sort()
 {
+	// TODO
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3284)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3285)
@@ -21,5 +21,5 @@
 shadowSize=4096
 # the filenames given to recorded frames (+ number.bmp)
-recordedFramesSuffix=image
+recordedFramesSuffix=frames/vienna_frame
 # the filename for the statistics
 statsFilename=mystats
@@ -80,15 +80,15 @@
 
 #lightDirection=-0.8f 1.0f -0.7f
-lightDirection=-0.3f 0.2f -0.7f
-
+#lightDirection=-0.3f 0.2f -0.7f
+lightDirection=-0.14002 0.812842 -0.565404
 
 #####################
 ## window options
 
-#winWidth=800
-#winHeight=600
+winWidth=800
+winHeight=600
 
-winWidth=1024
-winHeight=768
+#winWidth=1024
+#winHeight=768
 
 useFullScreen=0
@@ -121,5 +121,5 @@
 
 # use full resolution ssao (vs. half resoltion)
-ssaoUseFullResolution=0
+ssaoUseFullResolution=1
 # ssao kernel radius
 #ssaoKernelRadius=8e-1f
@@ -141,6 +141,8 @@
 #bvhname=PowerPlantM
 #keyForwardMotion=500.0f
+#mouseMotion=10.0f
 #visibilitySolution=power-plant-2c-xx-1000b-pgv2
 #visibilitySolution=power-plant-2c-xx-1000d-pgv
+#visibilitySolution=power-plant-2c-xx-1000b-spgvu
 #camPosition=-1320.57 -6306.34 3603
 #camDirection=0.292156 0.9556 0.0383878
