Index: trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 521)
+++ trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 522)
@@ -30,10 +30,10 @@
 	samplesPerPass  100000
 	initialSamples 300000
-	vssSamples 1000000
+	vssSamples 2000000
 	vssSamplesPerPass 100000
 	useImportanceSampling true
 	loadInitialSamples  false
 	storeInitialSamples false
-	useViewSpaceBox true
+	useViewSpaceBox false
 }
 
@@ -54,5 +54,5 @@
 	minSize		0.001
  	maxCostRatio	0.9
-	maxRayContribution 0.5
+	maxRayContribution 0.05
 	
 	maxTotalMemory	200
@@ -170,5 +170,5 @@
 ViewCells {
 	loadFromFile false
-	exportToFile false
+	exportToFile true
 	#type kdTree
 	#type vspKdTree
@@ -179,7 +179,7 @@
 	
 	height 5.0
-	maxViewCells 100
+	maxViewCells 100000
 	#percentage of total visible objects where pvs is considered invalid
-	maxPvsRatio 1
+	maxPvsRatio 0.05
 		
 	delayedConstruction true
@@ -188,5 +188,5 @@
 	PostProcess {
 		# how much samples are used for post processing
-		samples 100000
+		samples 200000
 	}
 
@@ -199,5 +199,5 @@
 		colorCode Random
 		exportRays false
-		exportGeometry true
+		exportGeometry false
 	}
 	
@@ -206,5 +206,5 @@
 #	filename ../data/vienna/viewcells-25.x3d
 #	filename ../data/vienna/viewcells-large-sel.x3d
-	filename ../scripts/viewcells_soda.xml
+	filename ../scripts/viewcells_vienna.xml
 }
 
@@ -246,5 +246,5 @@
 	PostProcess {
 		maxCostRatio 0.005
-		minViewCells 6000
+		minViewCells 200
 		maxPvsSize   50000
 	}
@@ -257,5 +257,5 @@
 VspBspTree {
 	Construction {
-		samples 500000
+		samples 900000
 		epsilon 0.005
 		randomize false
@@ -287,5 +287,5 @@
 	Termination {
 		# parameters used for autopartition
-		minRays 		1500
+		minRays 		500
 		minPolygons 		-1
 		maxDepth		30
@@ -293,7 +293,7 @@
 		minArea 		0.0001
 		#minArea 		0.000
-		maxRayContribution	0.05
-		maxCostRatio		0.9
-		missTolerance		2
+		maxRayContribution	0.3
+		maxCostRatio		0.93
+		missTolerance		3
 		#maxAccRayLength	100
 		
@@ -318,6 +318,6 @@
 	PostProcess {
 		maxCostRatio 0.1
-		minViewCells 150
-		maxPvsSize   1000
+		minViewCells 6000
+		maxPvsSize   10000
 		useRaysForMerge true
 	}
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp	(revision 513)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp	(revision 522)
@@ -65,2 +65,21 @@
   return result;
 }
+
+
+void Beam::ComputeFrustum(float &near, float &far,
+						  float &left, float &right,
+						  float &bottom, float &top,
+						  const AxisAlignedBox3 &sceneBBox)
+{
+	const float xDirRange = mDirBox.Max().x - mDirBox.Min().x;
+	const float yDirRange = mDirBox.Max().y - mDirBox.Min().y;
+
+	near = 1; // NOTE: what is the best value for near and far plane?
+	far = sceneBBox.Size(sceneBBox.Size().DrivingAxis());
+
+	left = 1.0f / tan(xDirRange * 0.5);
+	right = 1.0f / tan(xDirRange * 0.5);
+
+	bottom = 1.0f / tan(yDirRange * 0.5);
+	top = 1.0f / tan(yDirRange * 0.5);
+}
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h	(revision 513)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h	(revision 522)
@@ -35,7 +35,10 @@
 	  const AxisAlignedBox3 &dBox);
   
-  
-  int
-	  ComputeIntersection(const AxisAlignedBox3 &box);
+  void ComputeFrustum(float &near, float &far,
+					  float &left, float &right,
+					  float &bottom, float &top,
+					  const AxisAlignedBox3 &sceneBBox);
+
+  int ComputeIntersection(const AxisAlignedBox3 &box);
 
   bool IsValid() { return mFlags & VALID; }
@@ -45,5 +48,4 @@
   {
   }
-  
 };
 
Index: trunk/VUT/GtpVisibilityPreprocessor/src/dual_depth.cg
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/dual_depth.cg	(revision 522)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/dual_depth.cg	(revision 522)
@@ -0,0 +1,35 @@
+struct fragment
+{
+	float4 position  : POSITION;	//screen position
+	float4 color0    : COLOR0;
+	float4 color1    : COLOR1;		//lighting
+	float2 texcoord0 : TEXCOORD0;
+	float4 depthTexCoord: TEXCOORD1;
+	float3 normal	 : TEXCOORD2;
+};
+
+
+struct pixel
+{
+	float4 color : COLOR;	
+};
+
+
+pixel main(fragment IN,   
+           uniform sampler2D shadowMap: TEXUNIT1,
+           uniform float doTexturing)
+{
+	pixel OUT;
+	
+	float4 col = IN.color0;
+	
+	// the depth buffer	
+	float4 depth = tex2Dproj(shadowMap, IN.SMTexCoord);
+	float test = IN.depthTexCoord.z / IN.depthTexCoord.w;
+	
+	float shadow;
+	shadow = (test < depth.x) ? 1.0 : 0.0;
+	OUT.color = localcolor * shadow * IN.color1;
+
+	return OUT;
+}
