Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2735)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2736)
@@ -43,5 +43,5 @@
 -gvs_initial_samples=16 \
 -gvs_max_viewcells=3 \
--gvs_min_contribution=100 \
+-gvs_min_contribution=200 \
 -gvs_per_viewcell=true \
 -preprocessor_detect_empty_viewspace+ \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2735)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2736)
@@ -258,5 +258,5 @@
 	void CastRayBundles4(const SimpleRayContainer &rays, VssRayContainer &vssRays);
 	
-	void CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays);
+	void CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays, float scale);
 
 	/** Generates a ray bundle of 4 jittered rays and casts them using optimized 4 eye ray casting.
@@ -270,5 +270,5 @@
 	void Cast4Rays(float *dist, Vector3 *dirs, Vector3 *origs, VssRayContainer &vssRays, const AxisAlignedBox3 &box);
 
-	void CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays);
+	void CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays, float scale);
 
 	virtual void ComputeRenderError();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2729)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2736)
@@ -1328,16 +1328,14 @@
 										const SimpleRay &mainRay,
 										int number,
-										int pertubType) const
-{
-	//rayBundle.push_back(mainRay);
-	//const float pertubOrigin = 0.0f;
-	const float pertubDir = 0.01f;
+										int pertubType,
+										float scale) const
+{
 	Vector3 pertub;
 
 	for (int i = 0; i < number; ++ i)
 	{
-		pertub.x = RandomValue(-pertubDir, pertubDir);
-		pertub.y = RandomValue(-pertubDir, pertubDir);
-		pertub.z = RandomValue(-pertubDir, pertubDir);
+		pertub.x = RandomValue(-scale, scale);
+		pertub.y = RandomValue(-scale, scale);
+		pertub.z = RandomValue(-scale, scale);
 
 		Vector3 newDir = mainRay.mDirection + pertub;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2730)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2736)
@@ -377,5 +377,5 @@
 			im.save(qstr, "PNG");
 
-			if (0)
+			if (1)
 			{
 				///////////
@@ -391,10 +391,10 @@
 
 				KdNode::NewMail2();
-				//Intersectable::NewMail();
 
 				++ mCurrentFrame;
 
 				// render pvs once
-				RenderPvs(pvs);
+				//RenderPvs(pvs);
+				_RenderColoredPvs(pvs);
 				// hack for gvs visualization
 				//RenderTrianglePvs();
@@ -405,5 +405,5 @@
 
 				im = toImage();
-				sprintf_s(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount);
+				sprintf_s(filename, "error-frame-%05d-%05d-%08d-pvs.png", viewcell->GetId(), mFrame, pixelCount);
 				str = mSnapPrefix + filename;
 				qstr = str.c_str();
@@ -713,5 +713,5 @@
 				_RenderPvs();
 			else
-				_RenderColoredPvs();
+				_RenderColoredPvs(mPvsCache.mPvs);
 		}
 
@@ -2634,47 +2634,4 @@
 
 
-void QtGlRendererWidget::_RenderColoredPvs()
-{
-	// note: could be done more efficiently using color buffers
-	mPvsSize = mPvsCache.mPvs.GetSize();
-
-	ObjectPvsIterator it = mPvsCache.mPvs.GetIterator();
-
-	PvsData pvsData;
-
-	while (it.HasMoreEntries())
-	{
-		Intersectable *obj = it.Next(pvsData);
-
-		RgbColor color;
-
-		//cerr << "sumpdf: " << pvsData.mSumPdf << endl;
-		if (mUseRandomColorPerPvsObject)
-		{
-			if (obj->Type() == Intersectable::KD_INTERSECTABLE)
-			{
-				KdIntersectable *kdint = static_cast<KdIntersectable *>(obj);
-
-				if (kdint->mGenericIdx == -1)
-				{
-					kdint->mGenericIdx = (int)mColors.size();
-					mColors.push_back(RandomColor(0, 1));
-				}
-				color = mColors[kdint->mGenericIdx];
-			}
-		} 
-		else
-		{
-			color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1));
-		}
-
-		glColor3f(color.r, color.g, color.b);
-
-		mUseForcedColors = true;
-		RenderIntersectable(obj);
-		mUseForcedColors = false;
-	}
-}
-
 
 void QtGlRendererWidget::UpdateDynamicObjects()
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2730)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2736)
@@ -239,6 +239,4 @@
 	int mCurrentPvsCost;
 
-	vector<RgbColor> mColors;
-
 	bool mUseRandomColorPerPvsObject;
 
@@ -590,7 +588,4 @@
 	*/
 	void _RenderPvs();
-	/** Render pvs using false colors.
-	*/
-	void _RenderColoredPvs();
 
 	float ComputeRenderCost(ViewCell *vc);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2726)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2736)
@@ -144,5 +144,6 @@
 							 const SimpleRay &mainRay,
 							 int number,
-							 int shuffleType) const;
+							 int shuffleType,
+							 float scale) const;
 
 	virtual void CastRays(SimpleRayContainer &rays,
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2731)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2736)
@@ -840,16 +840,8 @@
 GlRenderer::RenderKdNode(KdNode *node)
 {
-  if (node->IsLeaf()) 
-	{
-#if !EVAL_ERROR
+	if (node->IsLeaf()) 
+	{
 		RenderKdLeaf(static_cast<KdLeaf *>(node));
-#else
-		KdLeaf *leaf = static_cast<KdLeaf *>(node);
-		for (int i=0; i < leaf->mObjects.size(); i++) 
-		  {
-			RenderIntersectable(leaf->mObjects[i]);
-			
-		  }
-#endif
+
 	} 
 	else 
@@ -1946,4 +1938,46 @@
 
 
-
-}
+void GlRenderer::_RenderColoredPvs(const ObjectPvs &pvs)
+{
+	// note: could be done more efficiently using color buffers
+	ObjectPvsIterator it = pvs.GetIterator();
+
+	PvsData pvsData;
+
+	while (it.HasMoreEntries())
+	{
+		Intersectable *obj = it.Next(pvsData);
+
+		RgbColor color;
+
+		//cerr << "sumpdf: " << pvsData.mSumPdf << endl;
+		if (1)//mUseRandomColorPerPvsObject)
+		{
+			if (obj->Type() == Intersectable::KD_INTERSECTABLE)
+			{
+				KdIntersectable *kdint = static_cast<KdIntersectable *>(obj);
+
+				if (kdint->mGenericIdx == -1)
+				{
+					kdint->mGenericIdx = (int)mColors.size();
+					mColors.push_back(RandomColor(0, 1));
+				}
+				color = mColors[kdint->mGenericIdx];
+			}
+		} 
+		else
+		{
+			color = RainbowColorMapping(log10(pvsData.mSumPdf + 1));
+		}
+
+		glColor3f(color.r, color.g, color.b);
+
+		mUseForcedColors = true;
+		RenderIntersectable(obj);
+		mUseForcedColors = false;
+	}
+}
+
+
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2730)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2736)
@@ -8,4 +8,6 @@
 #include "Renderer.h"
 #include "Beam.h"
+#include <vector>
+#include "Material.h"
 
 
@@ -221,4 +223,7 @@
   bool GetUseVbos() const { return mUseVbos; }
 
+  /** Render pvs using false colors.
+  */
+  void _RenderColoredPvs(const ObjectPvs &pvs);
 
 public:
@@ -296,4 +301,6 @@
 
 	int mRenderedNodes;
+
+	std::vector<RgbColor> mColors;
 };
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2735)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2736)
@@ -192,8 +192,10 @@
 	else
 	{
+		float scale = 0.01f;
+
 		if (0)
 			CastRayBundle4(simpleRay, reverseRays, mViewCellsManager->GetViewSpaceBox());
 		else
-			CastRayBundle16(simpleRay, reverseRays);
+			CastRayBundle16(simpleRay, reverseRays, scale);
 	}
 
@@ -502,5 +504,5 @@
 										  1.0f);
 			
-			GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0);
+			GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f);
 		}
 		else
@@ -625,5 +627,5 @@
 								  SamplingStrategy::GVS, 1.0f);
 
-	GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0);
+	GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f);
 	//GenerateRays(numRandomRays, *mDistribution, simpleRays, sInvalidSamples);
 
@@ -799,5 +801,5 @@
 	generationTimer.Entry();
 
-	if (mUseProbablyVisibleSampling && (RandomValue(0, 1) > 0.5))
+	if (mUseProbablyVisibleSampling)// && (RandomValue(0, 1) > 0.5))
 	{
 		ProbablyVisibleDistribution distr(*this, mCurrentViewCell, &mProbablyVisibleTriangles);
@@ -827,9 +829,10 @@
 	else
 	{
+		float scale = 0.1f;
 		if (0)
 			// casting bundles of 4 rays generated from the simple rays
 			CastRayBundles4(simpleRays, vssRays);
 		else
-			CastRayBundles16(simpleRays, vssRays);
+			CastRayBundles16(simpleRays, vssRays, scale);
 	}
 
@@ -1820,5 +1823,5 @@
 
 
-void GvsPreprocessor::CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays)
+void GvsPreprocessor::CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays, float scale)
 {
 	static SimpleRayContainer simpleRays;
@@ -1826,5 +1829,5 @@
 
 	simpleRays.push_back(ray);
-	GenerateJitteredRays(simpleRays, ray, 15, 0);
+	GenerateJitteredRays(simpleRays, ray, 15, 0, scale);
 
 	CastRays(simpleRays, vssRays, false, false);
@@ -1832,10 +1835,10 @@
 
 
-void GvsPreprocessor::CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays)
+void GvsPreprocessor::CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays, float scale)
 {
 	SimpleRayContainer::const_iterator it, it_end = rays.end();
 
 	for (it = rays.begin(); it != it_end; ++ it)
-		CastRayBundle16(*it, vssRays);
+		CastRayBundle16(*it, vssRays, scale);
 }
 
