Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 2972)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 2972)
@@ -0,0 +1,80 @@
+#include "../shaderenv.h"
+
+
+struct fragment
+{
+	 // normalized screen position
+	float4 pos: WPOS;
+	float4 texCoord: TEXCOORD0; 
+};
+
+
+
+float3 ToneMap(float imageKey, float whiteLum, float middleGrey, float3 color)
+{
+	float3 outCol;
+	const float pixLum = 0.2125f * color.x + 0.7154f * color.y + 0.0721f * color.z;
+	
+	// adjust to middle gray
+	const float lum = middleGrey * pixLum / imageKey;
+	 
+	// map to range and calc burnout
+	const float burnedLum = lum * (1.0f + lum / whiteLum * whiteLum) / (1.0f + lum);
+	
+	outCol = color * burnedLum / pixLum;
+
+	return outCol;
+}
+
+
+
+float4 DownSample(fragment IN,
+				  uniform sampler2D colors,
+				  float2 downSampleOffs[16]) : COLOR
+{    
+    float4 average = .0f;
+
+    for(int i = 0; i < 16; ++ i)
+    {
+        average += tex2D(colors, IN.texCoord + float2(downSampleOffs[i].x, downSampleOffs[i].y) );
+    }
+        
+    average *= 1.0f / 16.0f;
+
+    return average;
+}
+    
+
+float4 GreyScaleDownSample(fragment IN,
+						   uniform sampler2D colors,
+						   float2 offs[16]): COLOR
+{
+
+	// Compute the average of the 4 necessary samples
+	float average = 0.0f;
+	float maximum = -1e20;
+
+	float4 color = 0.0f;
+	
+	// the rgb weights
+	const float3 w = float3(0.299f, 0.587f, 0.114f);
+	//float3 w = float3(0.2125f, 0.7154f, 0.0721f);
+
+	for (int i = 0; i < 4; ++ i)
+	{
+		color = tex2D(colors, IN.texcoord + float2(offs[i].x, offs[i].y));
+
+		const float intensity = dot(color.rgb, W);
+
+		maximum = max(maximum, intentsity);
+		average += (0.25f * log(1e-5f + GreyValue));
+	}
+
+	average = exp(average);
+
+	// Output the luminance to the render target
+	return float4(average, maximum, 0.0f, 1.0f);
+}
+
+    
+    
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2970)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2972)
@@ -75,4 +75,8 @@
 	void FirstPassShadow(FrameBufferObject *fbo, DirectionalLight *light, ShadowMap *shadowMap);
 
+	void ComputeToneParameters(FrameBufferObject *fbo);
+	void ToneMap(FrameBufferObject *fbo, DirectionalLight *light);
+
+
 	void CombineSsao(FrameBufferObject *fbo);
 	void CombineIllum(FrameBufferObject *fbo);
@@ -83,4 +87,7 @@
 	void ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br);
 	
+	void DownSample(FrameBufferObject *fbo);
+
+
 
 	////////////
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2971)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2972)
@@ -36,4 +36,9 @@
 
 
+static CGprogram sCgInitialIntensityProgram;
+static CGprogram sCgDownSampleProgram;
+static CGprogram sCgToneProgram;
+
+
 ///////////////////////////////////////
 
@@ -100,4 +105,10 @@
 static CGparameter sMiddleGreyParam;
 static CGparameter sWhiteLumParam;
+
+
+static CGparameter sColorsTexInitialParam;
+static CGparameter sColorsTexToneParam;
+static CGparameter sIntensityTexDownSampleParam;
+
 
 //#define USE_3D_SSAO
@@ -1097,4 +1108,128 @@
 
 
+void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo)
+{
+	ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx);
+
+	GLuint colorsTex = colorBuffer->GetTexture();
+	
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	cgGLEnableProfile(RenderState::sCgFragmentProfile);
+	cgGLBindProgram(sCgInitialIntensityProgram);
+	
+	cgGLSetTextureParameter(sColorsTexInitialParam, colorsTex);
+	cgGLEnableTextureParameter(sColorsTexInitialParam);
+
+	// first pass: create high res intensity texture
+	glColor3f(1.0f, 1.0f, 1.0f);
+
+	float offs2 = 0.5f;
+
+	glBegin(GL_QUADS);
+
+	// the neighbouring texels
+	float x_offs = 1.0f / mWidth;
+	float y_offs = 1.0f / mHeight;
+
+	SetVertex(0, 0, x_offs, y_offs);
+	SetVertex(1, 0, x_offs, y_offs);
+	SetVertex(1, 1, x_offs, y_offs);
+	SetVertex(0, 1, x_offs, y_offs);
+
+	glEnd();
+
+	cgGLDisableTextureParameter(sColorsTexToneParam);
+
+	
+	////////////
+	//-- second phase: down sample the texture in order to compute the average
+	
+	// q: required passes for computing 1x1 texture?
+	int passes = 32;
+
+	for (int i = 0; i < 32; ++ i)
+	{
+		DownSample(fbo);
+	}
+
+	PrintGLerror("antialiasing");
+}
+
+
+void DeferredRenderer::DownSample(FrameBufferObject *fbo)
+{
+	GLuint intensityTex;
+	
+	cgGLEnableProfile(RenderState::sCgFragmentProfile);
+	cgGLBindProgram(sCgDownSampleProgram);
+	
+	cgGLSetTextureParameter(sIntensityTexDownSampleParam, intensityTex);
+	cgGLEnableTextureParameter(sIntensityTexDownSampleParam);
+}
+
+
+void DeferredRenderer::ToneMap(FrameBufferObject *fbo, DirectionalLight *light)
+{
+	ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx);
+
+	// we assume that we have a floating point rgba texture
+	float *pixels = (float *)colorBuffer->ReadTexture();
+
+	const int w = colorBuffer->GetHeight();
+	const int h = colorBuffer->GetWidth();
+
+	const float imageKey = ToneMapper().CalcImageKey(pixels, w, h);
+	const float whiteLum = 1.0f * ToneMapper().CalcMaxLuminance(pixels, w, h);
+
+	//const float minKey = 0.18f;
+	//const float maxKey = 0.72f;
+
+	//const float minKey = 0.0045f;
+	const float minKey = 0.09f;
+	const float maxKey = 0.5f;
+
+	const float lightIntensity = DotProd(-light->GetDirection(), Vector3::UNIT_Z());
+	const float middleGrey = lightIntensity * maxKey + (1.0f - lightIntensity) * minKey;
+
+	//cout << "middlegrey: " << middleGrey << endl;
+	delete [] pixels;
+
+	GLuint colorsTex = colorBuffer->GetTexture();
+	
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	cgGLEnableProfile(RenderState::sCgFragmentProfile);
+	cgGLBindProgram(sCgToneProgram);
+	
+	cgGLSetTextureParameter(sColorsTexToneParam, colorsTex);
+	cgGLEnableTextureParameter(sColorsTexToneParam);
+
+	cgGLSetParameter1f(sImageKeyParam, imageKey);
+	cgGLSetParameter1f(sWhiteLumParam, whiteLum);
+	cgGLSetParameter1f(sMiddleGreyParam, middleGrey);
+
+	glColor3f(1.0f, 1.0f, 1.0f);
+
+	float offs2 = 0.5f;
+
+	glBegin(GL_QUADS);
+
+	// the neighbouring texels
+	float x_offs = 1.0f / mWidth;
+	float y_offs = 1.0f / mHeight;
+
+	SetVertex(0, 0, x_offs, y_offs);
+	SetVertex(1, 0, x_offs, y_offs);
+	SetVertex(1, 1, x_offs, y_offs);
+	SetVertex(0, 1, x_offs, y_offs);
+
+	glEnd();
+
+	cgGLDisableTextureParameter(sColorsTexToneParam);
+
+	PrintGLerror("antialiasing");
+}
+
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h	(revision 2894)
+++ 	(revision )
@@ -1,60 +1,0 @@
-#ifndef _DeferredShader_H__
-#define _DeferredShader_H__
-
-#include "common.h"
-#include "glInterface.h"
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-
-namespace CHCDemoEngine 
-{ 
-
-class FrameBufferObject;
-class ShadowMap;
-class Matrix4x4;
-
-
-/** This class implements a deferred shading algorithm that takes
-	a frame buffer object as input and outputs an image in the given size
-*/
-class DeferredShader
-{
-public:
-	/** constructor for a deferred shader taking the requested output image size
-	*/
-	DeferredShader(int w, int h, float maxDepth);
-
-	~DeferredShader();
-	/** The algorithm renders the scene given an fbo.
-		The fbo must have color buffer, position buffer, normal buffer.
-	*/
-	void Render(FrameBufferObject *fbo);
-
-	/** Initialises the deferred shader and loads the required shaders:
-		This function has to be called only once.
-	*/
-	static void Init(CGcontext context);
-
-	void Render(FrameBufferObject *fbo, ShadowMap *shadowMap);
-
-
-protected:
-
-	void FirstPass(FrameBufferObject *fbo);
-
-	void FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap);
-
-	void AntiAliasing(FrameBufferObject *fbo);
-
-
-	//////////////////
-
-	int mWidth;
-	int mHeight;
-
-	float mScaleFactor;
-};
-
-} // namespace 
-#endif // _DeferredShader_H__
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp	(revision 2895)
+++ 	(revision )
@@ -1,385 +1,0 @@
-#include "DeferredShader.h"
-#include "FrameBufferObject.h"
-#include "RenderState.h"
-#include "ShadowMapping.h"
-
-
-using namespace std;
-
-
-namespace CHCDemoEngine
-{
-
-
-static void PrintGLerror(char *msg)
-{
-	GLenum errCode;
-	const GLubyte *errStr;
-	
-	if ((errCode = glGetError()) != GL_NO_ERROR) 
-	{
-		errStr = gluErrorString(errCode);
-		fprintf(stderr,"OpenGL ERROR: %s: %s\n", errStr, msg);
-	}
-}
-
-
-static GLenum mymrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT,  GL_COLOR_ATTACHMENT3_EXT};
-
-
-static CGprogram sCgDeferredProgram;
-static CGprogram sCgDeferredShadowProgram;
-static CGprogram sCgAntiAliasingProgram;
-
-
-static CGparameter sColorsTexParam;
-static CGparameter sPositionsTexParam;
-static CGparameter sNormalsTexParam;
-
-static CGparameter sColorsTexAntiAliasingParam;
-static CGparameter sNormalsTexAntiAliasingParam;
-
-static CGparameter sShadowMapParam;
-static CGparameter sPositionsTexShadowParam;  
-static CGparameter sColorsTexShadowParam;  
-static CGparameter sNormalsTexShadowParam;
-
-static CGparameter sShadowMatrixParam;
-static CGparameter sMaxDepthParam;
-static CGparameter sSampleWidthParam;
-
-
-DeferredShader::DeferredShader(int w, int h, float scaleFactor):
-mWidth(w), mHeight(h), mScaleFactor(scaleFactor)
-{
-	//mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
-	//mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);
-}
-
-
-DeferredShader::~DeferredShader()
-{
-	if (sCgDeferredProgram)
-		cgDestroyProgram(sCgDeferredProgram);
-
-	//DEL_PTR(mFbo);
-}
-
-
-void DeferredShader::Init(CGcontext context)
-{
-	sCgDeferredProgram = 
-		cgCreateProgramFromFile(context, 
-								CG_SOURCE,
-								"src/shaders/deferred.cg", 
-								RenderState::sCgFragmentProfile,
-								"main",
-								NULL);
-
-	if (sCgDeferredProgram != NULL)
-	{
-		cgGLLoadProgram(sCgDeferredProgram);
-
-		// we need size of texture for scaling
-		sPositionsTexParam = cgGetNamedParameter(sCgDeferredProgram, "positions");  
-		sColorsTexParam = cgGetNamedParameter(sCgDeferredProgram, "colors");  
-		sNormalsTexParam = cgGetNamedParameter(sCgDeferredProgram, "normals"); 
-	}
-	else
-		cerr << "deferred program failed to load" << endl;
-
-	sCgAntiAliasingProgram = 
-		cgCreateProgramFromFile(context, 
-								CG_SOURCE,
-								"src/shaders/antialiasing.cg", 
-								RenderState::sCgFragmentProfile,
-								"main",
-								NULL);
-
-	if (sCgAntiAliasingProgram != NULL)
-	{
-		cgGLLoadProgram(sCgAntiAliasingProgram);
-
-		sColorsTexAntiAliasingParam = cgGetNamedParameter(sCgAntiAliasingProgram, "colors");  
-		sNormalsTexAntiAliasingParam = cgGetNamedParameter(sCgAntiAliasingProgram, "normals");
-	}
-	else
-		cerr << "antialiasing program failed to load" << endl;
-
-	sCgDeferredShadowProgram = 
-		cgCreateProgramFromFile(context, 
-								CG_SOURCE,
-								"src/shaders/deferred.cg", 
-								RenderState::sCgFragmentProfile,
-								"main_shadow",
-								NULL);
-
-	if (sCgDeferredShadowProgram != NULL)
-	{
-		cgGLLoadProgram(sCgDeferredShadowProgram);
-
-		// we need size of texture for scaling
-		sPositionsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "positions");  
-		sColorsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "colors");  
-		sNormalsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "normals");
-
-		sShadowMapParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMap");  
-		sMaxDepthParam = cgGetNamedParameter(sCgDeferredShadowProgram, "maxDepth");
-		sSampleWidthParam = cgGetNamedParameter(sCgDeferredShadowProgram, "sampleWidth");
-		sShadowMatrixParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMatrix");
-	}
-	else
-		cerr << "deferred program failed to load" << endl;
-
-	PrintGLerror("init");
-}
-
-
-void DeferredShader::Render(FrameBufferObject *fbo)
-{
-	cgGLEnableProfile(RenderState::sCgFragmentProfile);
-
-	glDisable(GL_ALPHA_TEST);
-	glDisable(GL_TEXTURE_2D);
-	glDisable(GL_LIGHTING);
-
-	glPushAttrib(GL_VIEWPORT_BIT);
-	glViewport(0, 0, mWidth, mHeight);
-
-	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
-	glLoadIdentity();
-
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glLoadIdentity();
-
-	const float offs = 0.5f;
-	glOrtho(-offs, offs, -offs, offs, 0, 1);
-
-	FirstPass(fbo);
-	AntiAliasing(fbo);
-
-	glEnable(GL_LIGHTING);
-		
-	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
-
-	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
-
-	glPopAttrib();
-
-	cgGLDisableProfile(RenderState::sCgFragmentProfile);
-	FrameBufferObject::Release();
-}
-
-
-void DeferredShader::Render(FrameBufferObject *fbo, 
-							ShadowMap *shadowMap)
-{
-	FrameBufferObject::Release();
-
-	cgGLEnableProfile(RenderState::sCgFragmentProfile);
-
-	glDisable(GL_ALPHA_TEST);
-	glDisable(GL_TEXTURE_2D);
-	glDisable(GL_LIGHTING);
-	//glDepthMask(GL_FALSE);
-	
-
-	glPushAttrib(GL_VIEWPORT_BIT);
-	glViewport(0, 0, mWidth, mHeight);
-
-	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
-	glLoadIdentity();
-
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glLoadIdentity();
-
-	const float offs = 0.5f;
-	glOrtho(-offs, offs, -offs, offs, 0, 1);
-
-	FirstPassShadow(fbo, shadowMap);
-	AntiAliasing(fbo);
-
-	glEnable(GL_LIGHTING);
-	//glEnable(GL_TEXTURE_2D);
-	//glDepthMask(GL_TRUE);
-	
-	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
-
-	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
-
-	glPopAttrib();
-
-	cgGLDisableProfile(RenderState::sCgFragmentProfile);
-	FrameBufferObject::Release();
-}
-
-
-void DeferredShader::FirstPass(FrameBufferObject *fbo)
-{
-	GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture();
-	GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture();
-	GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture();
-
-	fbo->Bind();
-	glDrawBuffers(1, mymrt + 3);
-
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-	cgGLEnableProfile(RenderState::sCgFragmentProfile);
-	cgGLBindProgram(sCgDeferredProgram);
-
-	cgGLSetTextureParameter(sColorsTexParam, colorsTex);
-	cgGLEnableTextureParameter(sColorsTexParam);
-
-	cgGLSetTextureParameter(sPositionsTexParam, positionsTex);
-	cgGLEnableTextureParameter(sPositionsTexParam);
-
-	cgGLSetTextureParameter(sNormalsTexParam, normalsTex);
-	cgGLEnableTextureParameter(sNormalsTexParam);
-	
-	glColor3f(1.0f, 1.0f, 1.0f);
-	
-	glBegin(GL_QUADS);
-
-	float offs2 = 0.5f;
-
-	glTexCoord2f(0, 0); glVertex3f(-offs2, -offs2, -0.5f);
-	glTexCoord2f(1, 0); glVertex3f( offs2, -offs2, -0.5f);
-	glTexCoord2f(1, 1); glVertex3f( offs2,  offs2, -0.5f);
-	glTexCoord2f(0, 1); glVertex3f(-offs2,  offs2, -0.5f);
-
-	glEnd();
-
-	cgGLDisableTextureParameter(sColorsTexParam);
-	cgGLDisableTextureParameter(sPositionsTexParam);
-	cgGLDisableTextureParameter(sNormalsTexParam);
-	
-	FrameBufferObject::Release();
-
-	PrintGLerror("deferred shading");
-}
-
-
-static void SetVertex(float x, float y, float x_offs, float y_offs)
-{
-	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, x, y); // center
-	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, x - x_offs, y + y_offs); // left top
-	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, x + x_offs, y - y_offs); // right bottom
-	glMultiTexCoord2fARB(GL_TEXTURE3_ARB, x + x_offs, y + y_offs); // right top
-	glMultiTexCoord2fARB(GL_TEXTURE4_ARB, x - x_offs, y - y_offs); // left bottom
-
-	glMultiTexCoord4fARB(GL_TEXTURE5_ARB, x - x_offs, y, x + x_offs, y); // left right
-	glMultiTexCoord4fARB(GL_TEXTURE6_ARB, x, y + y_offs, x, y - y_offs); // top bottom
-
-	glVertex3f(x - 0.5f, y - 0.5f, -0.5f);
-}
-
-
-void DeferredShader::AntiAliasing(FrameBufferObject *fbo)
-{
-	GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture();
-	GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture();
-
-	
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-	cgGLBindProgram(sCgAntiAliasingProgram);
-
-	cgGLSetTextureParameter(sColorsTexAntiAliasingParam, colorsTex);
-	cgGLEnableTextureParameter(sColorsTexAntiAliasingParam);
-
-	cgGLSetTextureParameter(sNormalsTexAntiAliasingParam, normalsTex);
-	cgGLEnableTextureParameter(sNormalsTexAntiAliasingParam);
-	
-	glColor3f(1.0f, 1.0f, 1.0f);
-	
-	glBegin(GL_QUADS);
-
-	// the neighbouring texels
-	float x_offs = 1.0f / mWidth;
-	float y_offs = 1.0f / mHeight;
-
-	SetVertex(0, 0, x_offs, y_offs);
-	SetVertex(1, 0, x_offs, y_offs);
-	SetVertex(1, 1, x_offs, y_offs);
-	SetVertex(0, 1, x_offs, y_offs);
-
-	glEnd();
-
-	cgGLDisableTextureParameter(sColorsTexAntiAliasingParam);
-	cgGLDisableTextureParameter(sNormalsTexAntiAliasingParam);
-
-	PrintGLerror("antialiasing");
-}
-
-
-void DeferredShader::FirstPassShadow(FrameBufferObject *fbo, 
-									 ShadowMap *shadowMap)
-{
-	GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture();
-	GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture();
-	GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture();
-	GLuint shadowTex = shadowMap->GetShadowTexture();
-
-	Matrix4x4 shadowMatrix;
-	shadowMap->GetTextureMatrix(shadowMatrix);
-
-	fbo->Bind();
-	glDrawBuffers(1, mymrt + 3);
-
-	
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-	cgGLBindProgram(sCgDeferredShadowProgram);
-
-	cgGLSetTextureParameter(sColorsTexShadowParam, colorsTex);
-	cgGLEnableTextureParameter(sColorsTexShadowParam);
-
-	cgGLSetTextureParameter(sPositionsTexShadowParam, positionsTex);
-	cgGLEnableTextureParameter(sPositionsTexShadowParam);
-
-	cgGLSetTextureParameter(sNormalsTexShadowParam, normalsTex);
-	cgGLEnableTextureParameter(sNormalsTexShadowParam);
-	
-	cgGLSetTextureParameter(sShadowMapParam, shadowTex);
-	cgGLEnableTextureParameter(sShadowMapParam);
-
-	cgGLSetParameter1f(sMaxDepthParam, mScaleFactor);
-	cgGLSetParameter1f(sSampleWidthParam, 1.0f / shadowMap->GetSize());
-	 
-	cgGLSetMatrixParameterfc(sShadowMatrixParam, (const float *)shadowMatrix.x);
-
-	glColor3f(1.0f, 1.0f, 1.0f);
-	
-	glBegin(GL_QUADS);
-
-	float offs2 = 0.5f;
-
-	glTexCoord2f(0, 0); glVertex3f(-offs2, -offs2, -0.5f);
-	glTexCoord2f(1, 0); glVertex3f( offs2, -offs2, -0.5f);
-	glTexCoord2f(1, 1); glVertex3f( offs2,  offs2, -0.5f);
-	glTexCoord2f(0, 1); glVertex3f(-offs2,  offs2, -0.5f);
-
-	glEnd();
-
-	cgGLDisableTextureParameter(sColorsTexShadowParam);
-	cgGLDisableTextureParameter(sPositionsTexShadowParam);
-	cgGLDisableTextureParameter(sNormalsTexShadowParam);
-	cgGLDisableTextureParameter(sShadowMapParam);
-
-	FrameBufferObject::Release();
-
-	PrintGLerror("deferred shading");
-}
-
-
-
-} // namespace
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2965)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2972)
@@ -799,4 +799,8 @@
 				>
 			</File>
+			<File
+				RelativePath=".\src\shaders\tonemap.cg"
+				>
+			</File>
 		</Filter>
 		<Filter
