Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.cpp	(revision 1926)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.cpp	(revision 1935)
@@ -21,4 +21,5 @@
 static CGcontext sCgContext = NULL;
 static CGprogram sCgFragmentProgram = NULL;
+static CGprogram sCgDepthPeelingProgram = NULL;
 static CGprofile sCgFragmentProfile;
 
@@ -140,4 +141,6 @@
 	if (sCgFragmentProgram)
 		cgDestroyProgram(sCgFragmentProgram);
+	if (sCgDepthPeelingProgram)
+		cgDestroyProgram(sCgDepthPeelingProgram);
 	if (sCgContext)
 		cgDestroyContext(sCgContext);
@@ -692,9 +695,5 @@
 	}
 
-
-
 	// at this point, if possible, go and do some other computation
-
-
 	
 	// 7. The number of visible pixels is the number of sample rays which see the source
@@ -739,8 +738,6 @@
 #endif
 
-
-
+	////////
 	//-- cleanup
-
 
 	// reset gl state
@@ -791,8 +788,56 @@
 
   
+void QtGlRendererBuffer::CastGlobalLine(Beam &beam, const int samples)
+{
+	// bind pixel shader implementing the front depth buffer functionality
+	cgGLBindProgram(sCgFragmentProgram);
+	cgGLEnableProfile(sCgFragmentProfile);
+
+	DepthPeeling(beam, samples);
+}
+
+
+void QtGlRendererBuffer::DepthPeeling(Beam &beam, const int samples)
+{
+/*	if (rtNew->IsDoubleBuffered()) 
+		glDrawBuffer(GL_BACK);
+	
+	rtNew->BeginCapture();
+	{
+		cgGLBindProgram(passthru);
+		glColor3f(0,0.0,0.0);
+		DrawGeometry();   //just random geomerty   
+	}
+	rtNew->EndCapture();
+
+	for(int l = 0; l < mCurrentDepth; l++) 
+	{
+		// Peel another layer
+		pingpong(); // switch pointer between rendertextures
+     
+		rtNew->BeginCapture();
+		{
+			if (rtNew->IsDoubleBuffered()) 
+				glDrawBuffer(GL_BACK);
+        
+			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);         
+			
+			cgGLBindProgram(fragmentProgram);
+			cgGLSetTextureParameter(input1, rtOld->GetDepthTextureID());
+			cgGLEnableTextureParameter(input1);
+
+            glColor3f(0,0.0,0.0);
+			DrawGeometry();
+			cgGLDisableTextureParameter(input1);
+		}
+		rtNew->EndCapture();
+   }*/
+}
+
+
 void QtGlRendererBuffer::InitGL()
 {
- makeCurrent(); 
- GlRenderer::InitGL();
+	makeCurrent(); 
+	GlRenderer::InitGL();
 
 #if 1
@@ -851,4 +896,23 @@
   Debug << "---- PROGRAM BEGIN ----\n" <<
 	  cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n";
+
+
+  sCgDepthPeelingProgram = 
+	  cgCreateProgramFromFile(sCgContext,
+							  CG_SOURCE, 
+							  "../src/depth_peeling.cg",
+							  sCgFragmentProfile,
+							  NULL, 
+							  NULL);
+
+  if (!cgIsProgramCompiled(sCgDepthPeelingProgram))
+  	  cgCompileProgram(sCgDepthPeelingProgram);
+
+  cgGLLoadProgram(sCgDepthPeelingProgram);
+  cgGLBindProgram(sCgDepthPeelingProgram);
+
+  Debug << "---- PROGRAM BEGIN ----\n" 
+	    << cgGetProgramString(sCgDepthPeelingProgram, CG_COMPILED_PROGRAM) 
+		<< "---- PROGRAM END ----\n";
 
 #endif
@@ -1742,5 +1806,4 @@
 
 
-
 void
 QtRendererControlWidget::FocusNextPvsErrorFrame(void)
@@ -1752,5 +1815,5 @@
 void
 QtRendererControlWidget::UpdatePvsErrorItem(int row,
-										  GlRendererBuffer::PvsErrorEntry &pvsErrorEntry)
+											GlRendererBuffer::PvsErrorEntry &pvsErrorEntry)
 {
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.h	(revision 1932)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.h	(revision 1935)
@@ -79,22 +79,27 @@
 
 	void SampleBeamContributions(
-		Intersectable *sourceObject,
-		Beam &beam,
-		const int samples,
-		BeamSampleStatistics &stat
+			Intersectable *sourceObject,
+			Beam &beam,
+			const int samples,
+			BeamSampleStatistics &stat
 		);
 
 	void
 		SampleViewpointContributions(
-		Intersectable *sourceObject,
-		const Vector3 viewPoint,
-		Beam &beam,
-		const int desiredSamples,
-		BeamSampleStatistics &stat
+			Intersectable *sourceObject,
+			const Vector3 viewPoint,
+			Beam &beam,
+			const int desiredSamples,
+			BeamSampleStatistics &stat
 		);
 
+	void CastGlobalLine(Beam &beam,
+						const int samples);
+
+	void DepthPeeling(Beam &beam, const int samples);
+
 	void InitGL();
 
-	/** Computes rays from information gained with hw sampling-
+	/** Computes rays from information gained with hw sampling
 	*/
 	void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1932)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1935)
@@ -3561,5 +3561,5 @@
 				if (p < raysOut)
 				{
-					if (0 && (*rit)->mFlags & VssRay::BorderSample)
+					if ((*rit)->mFlags & VssRay::BorderSample)
 					{
 						vcRays.push_back(*rit);
@@ -3567,8 +3567,7 @@
 					else if ((*rit)->mFlags & VssRay::ReverseSample)
 					{
-						cout << "l";
 						vcRays2.push_back(*rit);
 					}
-					else if(0)
+					else
 					{
 						vcRays3.push_back(*rit);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1931)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1935)
@@ -882,9 +882,4 @@
 
 
-
-
-
-
-
 void GlRendererBuffer::SampleBeamContributions(Intersectable *sourceObject,
 											   Beam &beam,
@@ -1015,8 +1010,6 @@
 	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, depthMapSize, depthMapSize);
 
-
 	// reset clear function
 	glClearDepth(clearDepth);
-
 	
 	
@@ -1099,7 +1092,5 @@
 #endif
 	
-   
-
-	// 6. Use occlusion queries for all viewcell meshes associated with the beam ->
+   	// 6. Use occlusion queries for all viewcell meshes associated with the beam ->
 	//     a fragment passes if the corresponding stencil fragment is set and its depth is
 	//     between origin and termination buffer
@@ -1132,10 +1123,6 @@
 	}
 
-
-
 	// at this point, if possible, go and do some other computation
 
-
-	
 	// 7. The number of visible pixels is the number of sample rays which see the source
 	//    object from the corresponding viewcell -> remember these values for later update
@@ -1179,8 +1166,5 @@
 #endif
 
-
-
 	//-- cleanup
-
 
 	// reset gl state
@@ -1189,4 +1173,5 @@
 	glEnable(GL_CULL_FACE);
 	glDisable(GL_STENCIL_TEST);
+
 #if USE_CG
 	cgGLDisableProfile(sCgFragmentProfile);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1934)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 1935)
@@ -15,5 +15,5 @@
 {
   
-#define GVS_DEBUG 0
+#define GVS_DEBUG 1
 
 struct VizStruct
@@ -435,5 +435,6 @@
 	// take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ?
 	// difficult to say!!
-	const Vector3 newOrigin = newPoint + newDir * -5000.0f;
+	const float offset = 0.5f;
+	const Vector3 newOrigin = newPoint - newDir * offset;
 
 	const SimpleRay simpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/depthPeeling.cg
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/depthPeeling.cg	(revision 1935)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/depthPeeling.cg	(revision 1935)
@@ -0,0 +1,13 @@
+
+float3 main(in float4 col : COL0,
+       in float3 pos : WPOS,
+        uniform samplerRECT curentDepth) : COLOR
+{
+   float zold = texRECT(currentDepth, pos.xy);
+   if(pos.z < (zold + .000001))
+      discard;
+   else;
+
+   return col;
+   
+} 
