Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 2999)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 3002)
@@ -22,14 +22,14 @@
 float4 DownSample(frag IN,
 				  uniform sampler2D colors,
-				  float2 downSampleOffs[16]) : COLOR
+				  float2 downSampleOffs[4]) : COLOR
 {    
     float4 average = .0f;
 
-    for(int i = 0; i < 16; ++ i)
+    for(int i = 0; i < 4; ++ i)
     {
         average += tex2D(colors, IN.texCoord + downSampleOffs[i]);
     }
         
-    average *= 1.0f / 16.0f;
+    average *= 1.0f / 4.0f;
 
     return average;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3001)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3002)
@@ -668,8 +668,8 @@
 	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST);
 	// the positions buffer
-	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST);
+	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST);
 	//fbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST);
 	// the normals buffer
-	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST);
+	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST);
 	// another color buffer
 	fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3001)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3002)
@@ -36,4 +36,5 @@
 static CGparameter sColorsTexLogLumParam;
 
+static CGparameter sDownSampleOffsetParam;
 
 
@@ -276,5 +277,12 @@
 	mFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
 	mFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
-}
+
+	mDownSampleFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE);
+	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
+	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
+	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
+	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
+}
+
 
 
@@ -535,5 +543,5 @@
 								"src/shaders/tonemap.cg", 
 								RenderState::sCgFragmentProfile,
-								"GreyScaleDownSample",
+								"DownSample",
 								NULL);
 
@@ -543,5 +551,21 @@
 
 		// we need size of texture for scaling
-		sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors");  
+		sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors"); 
+		sDownSampleOffsetParam = cgGetNamedParameter(sCgDownSampleProgram, "downSampleOffs");
+		
+		float downSampleOffsets[8];
+
+		float w = 1028;
+		float h = 768;
+
+		float xoffs = 1 / w;
+		float yoffs = 1 / h;
+
+		downSampleOffsets[0] =  xoffs; downSampleOffsets[1] =  yoffs;
+		downSampleOffsets[2] =  xoffs; downSampleOffsets[3] = -yoffs;
+		downSampleOffsets[4] = -xoffs; downSampleOffsets[5] = -yoffs;
+		downSampleOffsets[6] = -xoffs; downSampleOffsets[7] =  yoffs;
+
+		cgGLSetParameterArray2f(sDownSampleOffsetParam, 0, 4, (const float *)downSampleOffsets);
 	}
 	else
@@ -602,4 +626,5 @@
 		break;
 	case GI:
+		DownSample(fbo);
 		ComputeGlobIllum(fbo, tempCohFactor, oldProjViewMatrix);
 		CombineIllum(fbo);
@@ -1244,4 +1269,7 @@
 void DeferredRenderer::DownSample(FrameBufferObject *fbo)
 {
+	glPushAttrib(GL_VIEWPORT_BIT);
+	glViewport(0, 0, mWidth, mHeight);
+
 	ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx);
 	GLuint colorsTex = colorBuffer->GetTexture();
@@ -1277,5 +1305,6 @@
 	FrameBufferObject::Release();
 
-	PrintGLerror("ToneMapParams");
+	glPopAttrib();
+	PrintGLerror("downsample");
 }
 
