Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2729)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2730)
@@ -42,6 +42,6 @@
 -gvs_total_samples=1000000 \
 -gvs_samples_per_pass=1000000 \
--gvs_initial_samples=4 \
--gvs_max_viewcells=2 \
+-gvs_initial_samples=1 \
+-gvs_max_viewcells=3 \
 -gvs_min_contribution=500 \
 -gvs_per_viewcell=true \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2729)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2730)
@@ -272,4 +272,8 @@
 	void CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays);
 
+	virtual void ComputeRenderError();
+
+	SimpleRay GenerateJitteredSample(const SimpleRay &ray);
+
 
 	//////////////////////
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2725)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2730)
@@ -174,4 +174,6 @@
 void QtGlRendererBuffer::RenderTrianglePvs()
 {
+	//Intersectable::NewMail;
+
 	ObjectContainer::const_iterator oit, oit_end = 
 		mViewCellsManager->GetPreprocessor()->mTrianglePvs.end();
@@ -179,13 +181,20 @@
 	//int sz = mViewCellsManager->GetPreprocessor()->mDummyBuffer.size();
 
-	int i = 0;
 	for (oit = mViewCellsManager->GetPreprocessor()->mTrianglePvs.begin();
-		 oit != oit_end; ++ oit, ++ i)
-	{
+		 oit != oit_end; ++ oit)
+	{
+		TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit);
+
 		//int dum = mViewCellsManager->GetPreprocessor()->mDummyBuffer[i];
 		//glColor3f(0, (float)dum / 20.0f, 1);
-		if (mUseFalseColors) SetupFalseColor((*oit)->mId);
-
-		RenderIntersectable(*oit);
+		if (mUseFalseColors) SetupFalseColor(triObj->mId);
+
+		RenderIntersectable(triObj);
+
+		/*if (!triObj->Mailed())
+			triObj->Mail();
+		else
+			cerr << "böser fehler" << endl;
+		*/
 	}
 }
@@ -194,5 +203,5 @@
 
 // reimplemented here so that we can snap the error windows
-float QtGlRendererBuffer::GetPixelError(int &pvsSize, int pass)
+float QtGlRendererBuffer::GetPixelError(int &pvsSize, int currentPass)
 {
 	MakeLive();
@@ -301,8 +310,11 @@
 
 	KdNode::NewMail2();
-	Intersectable::NewMail();
-
+	//Intersectable::NewMail();
+
+	//mUseFalseColors = true;
+	// hack for gvs
+	RenderTrianglePvs();
 	// render pvs once
-	RenderPvs(pvs);
+	//RenderPvs(pvs);
 
 	//glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
@@ -320,5 +332,5 @@
 
 	KdNode::NewMail2();
-	Intersectable::NewMail();
+	//Intersectable::NewMail();
 
 	query->BeginQuery();
@@ -357,5 +369,5 @@
 			//sprintf(filename, "error-frame-%04d-%05d.bmp", pass, mFrame);
 			//sprintf(filename, "error-frame-%05d-%0.5f.png", mFrame, pErrorPixels);
-			sprintf_s(filename, "error-frame-%05d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount);
+			sprintf_s(filename, "error-frame-%05d-%05d-%08d.png", viewcell->GetId(), mFrame, pixelCount);
 
 			QImage im = toImage();
@@ -379,5 +391,5 @@
 
 				KdNode::NewMail2();
-				Intersectable::NewMail();
+				//Intersectable::NewMail();
 
 				++ mCurrentFrame;
@@ -385,5 +397,5 @@
 				// render pvs once
 				RenderPvs(pvs);
-				// hack for gvs vis
+				// hack for gvs visualization
 				//RenderTrianglePvs();
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2725)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2730)
@@ -76,5 +76,5 @@
 	int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
 
-	/** quick hack in order to be able to render gvs pvs.
+	/** quick hack in order to be able to render gvs based triangle pvs.
 	*/
 	void RenderTrianglePvs();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2727)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2730)
@@ -1563,5 +1563,5 @@
 {
 	mPvsStat.Reset();
-	++ mPvsStat.pass;
+	++ mPvsStat.currentPass;
 
 	SetupProjection(GetWidth(), GetHeight());
@@ -1572,5 +1572,4 @@
 
 	int i = 0;
-
 	// $matt tmp: somehow this is not properly initialised
 	//ClearErrorBuffer();
@@ -1579,5 +1578,4 @@
 	{
 		SimpleRay sray = *sit;
-		
 		int pvsSize = -1;
 
@@ -1593,5 +1591,5 @@
 		{
 			// compute the pixel error
-			mPvsErrorBuffer[i].mError = GetPixelError(pvsSize, mPvsStat.pass);
+			mPvsErrorBuffer[i].mError = GetPixelError(pvsSize, mPvsStat.currentPass);
 			mPvsErrorBuffer[i].mPvsSize = pvsSize;
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2723)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2730)
@@ -42,7 +42,7 @@
   int frames;
   int errorFreeFrames;
-  int pass;
-
-  PvsRenderStatistics(): pass(0) { Reset(); }
+  int currentPass;
+
+  PvsRenderStatistics(): currentPass(0) { Reset(); }
   
   void Reset() 
@@ -53,4 +53,5 @@
 	errorFreeFrames = 0;
 	sumPvsSize = 0;
+	//cuurentPass = 0;
   }
 
@@ -171,7 +172,7 @@
   
   /** Gets the pixel error of the current view point. 
-     returns the size of the pvs for the current view point. pass returns the 
-	 current pass of the evaluation.
-	 */
+	returns the size of the pvs for the current view point. pass returns the 
+	current pass of the evaluation.
+  */
   virtual float GetPixelError(int &pvsSize, int pass);
   
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2729)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2730)
@@ -14,4 +14,7 @@
 #include "IntersectableWrapper.h"
 #include "Timer/PerfTimer.h"
+#include "Vector2.h"
+#include "RndGauss.h"
+
 
 
@@ -1326,13 +1329,9 @@
 	// export the preprocessed information to a file
 	if (0 && mExportVisibility)
-	{
 		ExportPreprocessedData(mVisibilityFileName);
-	}
 	
 	// compute the pixel error of this visibility solution
-	if (mEvaluatePixelError)
-	{
+	if (0 && mEvaluatePixelError)
 		ComputeRenderError();
-	}
 
 	return true;
@@ -1424,4 +1423,7 @@
 	mGvsStats.mGvsSamples = 0;
 
+	//renderer->mPvsStat.currentPass = 0;
+	mPass = 0;
+
 	int oldContribution = 0;
 	int passSamples = 0;
@@ -1507,4 +1509,8 @@
 			mGvsStats.mPassContribution = 0;
 			passSamples = 0;
+			
+			// compute the pixel error of this visibility solution
+			if (mEvaluatePixelError)
+				ComputeRenderError();
 		}
 	}
@@ -1627,7 +1633,7 @@
 	cout << "raw cast time          : " << rawCastTime << endl;
 
-	float randomRaysPerSec = mGvsStats.mRandomSamples / (1e6f * initialTime);
-	float gvsRaysPerSec = mGvsStats.mGvsSamples / (1e6f * gvsTime);
-	float rawRaysPerSec = mGvsStats.mPerViewCellSamples / (1e6f * rawCastTime);
+	double randomRaysPerSec = mGvsStats.mRandomSamples / (1e6 * initialTime);
+	double gvsRaysPerSec = mGvsStats.mGvsSamples / (1e6 * gvsTime);
+	double rawRaysPerSec = mGvsStats.mPerViewCellSamples / (1e6 * rawCastTime);
 
 	cout << "cast " << randomRaysPerSec << " M random rays/s: " << endl;
@@ -1804,3 +1810,90 @@
 }
 
-}
+
+void GvsPreprocessor::ComputeRenderError()
+{
+	// compute rendering error	
+	if (renderer && renderer->mPvsStatFrames) 
+	{
+		if (!mViewCellsManager->GetViewCellPointsList()->empty()) 
+		{
+			ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList();
+			ViewCellPointsList::const_iterator vit = vcPoints->begin(),	vit_end = vcPoints->end();
+
+			SimpleRayContainer viewPoints;
+
+			for (; vit != vit_end; ++ vit) 
+			{
+				ViewCellPoints *vp = *vit;
+				
+				SimpleRayContainer::const_iterator rit = vp->second.begin(), rit_end = vp->second.end();
+			
+				for (; rit!=rit_end; ++rit)
+				{
+					ViewCell *vc = mViewCellsManager->GetViewCell((*rit).mOrigin);
+					if (vc == mCurrentViewCell)
+						viewPoints.push_back(*rit);
+				}
+			}
+
+			renderer->mPvsErrorBuffer.clear();
+
+			if (viewPoints.size() != renderer->mPvsErrorBuffer.size()) 
+			{
+				renderer->mPvsErrorBuffer.resize(viewPoints.size());
+				renderer->ClearErrorBuffer();
+			}
+
+			cout << "evaluating list of " << viewPoints.size() << " pts" << endl;
+			renderer->EvalPvsStat(viewPoints);
+		} 
+		else
+		{
+			cout << "evaluating random points" << endl;
+			renderer->EvalPvsStat();
+		}
+
+		mStats <<
+			"#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<<
+			"#AvgPixelError\n" <<renderer->GetAvgPixelError()<<endl<<
+			"#MaxPixelError\n" <<renderer->GetMaxPixelError()<<endl<<
+			"#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<<
+			"#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<<
+			"#AvgRenderPvs\n" <<renderer->mPvsStat.GetAvgPvs()<<endl;
+	}
+}
+
+
+SimpleRay GvsPreprocessor::GenerateJitteredSample(const SimpleRay &sray)
+{
+	// mutate the origin
+	Vector3 d = sray.mDirection;
+  
+	// Compute right handed coordinate system from direction
+	Vector3 U, V;
+	d.RightHandedBase(U, V);
+
+	float rr[2];
+
+	rr[0] = RandomValue(0, 1);
+	rr[1] = RandomValue(0, 1);
+
+	Vector2 vr2(rr[0], rr[1]);
+	Vector2 gaussvec2;
+
+	const float sigma = 0.2f;
+
+	GaussianOn2D(vr2, sigma, // input
+		         gaussvec2); // output
+	
+	Vector3 shift = gaussvec2.xx * U + gaussvec2.yy * V;
+	
+	d += shift;
+  
+	d.Normalize();
+
+	return SimpleRay(sray.mOrigin, d, SamplingStrategy::GVS, 1.0f);
+}
+
+
+}
