Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2896)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 2896)
@@ -0,0 +1,104 @@
+#ifndef _DeferredRenderer_H__
+#define _DeferredRenderer_H__
+
+#include "common.h"
+#include "glInterface.h"
+
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
+
+
+namespace CHCDemoEngine 
+{ 
+
+class FrameBufferObject;
+class Vector3;
+class Camera;
+class Matrix4x4;
+class ShadowMap;
+
+
+/** This class implements a deferred shading algorithm that takes
+	a frame buffer object as input and outputs an image in the given size
+*/
+class DeferredRenderer
+{
+public:
+	/** Constructor for a deferred shader taking the requested output image size,
+		the current camera,	and a scaling factor.
+			
+		The parameter scaleFactor must be reciprocal value of the 
+		scale factor used for creating the positions texture. It is used recover the 
+		exact scene size that was scaled in order to improve floating point precision.
+	*/
+	DeferredRenderer(int w, int h, Camera *cam, float scaleFactor);
+	/** The algorithm renders the scene given an fbo consists of 1 color buffer, 
+		1 position buffer, and 1 normal buffer.
+		We also need the  projection view matrix of the last frame for reprojection, and
+		a smoothing factor for temporal coherence
+	*/
+	void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor, ShadowMap *shadowMap = NULL);
+
+	/** Initialises the deferred shader and loads the required shaders:
+		This function has to be called only once.
+	*/
+	static void Init(CGcontext context);
+
+	~DeferredRenderer();
+
+	void SetUseTemporalCoherence(bool temporal);
+
+	enum SAMPLING_METHOD {POISSON, GAUSS};
+	enum SHADING_METHOD {DEFAULT, SSAO, GI};
+
+	void SetSamplingMethod(SAMPLING_METHOD s);
+
+	void SetShadingMethod(SHADING_METHOD s) { mShadingMethod = s; }
+
+protected:
+
+	void ComputeSsao(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix);
+
+	void ComputeGlobIllum(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix);
+
+	void FirstPass(FrameBufferObject *fbo);
+
+	void FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap);
+
+	void CombineSsao(FrameBufferObject *fbo);
+	void CombineIllum(FrameBufferObject *fbo);
+
+	void AntiAliasing(FrameBufferObject *fbo);
+
+	/** Helper method that computes the view vectors in the corners of the current view frustum.
+	*/
+	void ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br);
+
+
+	////////////
+
+	int mWidth;
+	int mHeight;
+
+	/// this is just a scale factor for the scene depth in order to get better float precision in the shader
+	float mScaleFactor;
+
+	Camera *mCamera;
+
+	//FrameBufferObject *mOldFbo;
+	//FrameBufferObject *mNewFbo;
+	FrameBufferObject *mFbo;
+
+	bool mUseTemporalCoherence;
+
+	int mSamplingMethod;
+	int mFboIndex;
+
+	int mShadingMethod;
+
+	bool mRegenerateSamples;
+};
+
+} // namespace 
+
+#endif // _SsaoShader_H__
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2895)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2896)
@@ -33,5 +33,5 @@
 #include "SampleGenerator.h"
 #include "FrameBufferObject.h"
-#include "SsaoShader.h"
+#include "DeferredRenderer.h"
 #include "ShadowMapping.h"
 #include "Light.h"
@@ -168,6 +168,6 @@
 bool useLODs = true;
 
-SsaoShader::SAMPLING_METHOD samplingMethod = SsaoShader::POISSON;
-SsaoShader::SHADING_METHOD shadingMethod = SsaoShader::DEFAULT;
+DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::POISSON;
+DeferredRenderer::SHADING_METHOD shadingMethod = DeferredRenderer::DEFAULT;
 
 bool showShadowMap = false;
@@ -225,5 +225,5 @@
 void InitFBO();
 
-SsaoShader *ssaoShader = NULL;
+DeferredRenderer *ssaoShader = NULL;
 
 static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
@@ -431,5 +431,5 @@
 	InitCg();
 
-	SsaoShader::Init(sCgContext);
+	DeferredRenderer::Init(sCgContext);
 
 
@@ -1014,5 +1014,5 @@
 		cgGLDisableProfile(RenderState::sCgFragmentProfile);
 
-		if (!ssaoShader) ssaoShader = new SsaoShader(texWidth, texHeight, camera, myfar / 10.0f);
+		if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, myfar / 10.0f);
 		
 		ssaoShader->SetShadingMethod(shadingMethod);
@@ -1134,8 +1134,8 @@
 	case 'P':
 	case 'p':
-		if (samplingMethod == SsaoShader::GAUSS)
-			samplingMethod = SsaoShader::POISSON;
+		if (samplingMethod == DeferredRenderer::GAUSS)
+			samplingMethod = DeferredRenderer::POISSON;
 		else
-			samplingMethod = SsaoShader::GAUSS;
+			samplingMethod = DeferredRenderer::GAUSS;
 
 		break;
@@ -1280,5 +1280,5 @@
 		break;
 	case GLUT_KEY_F8:
-		shadingMethod = (SsaoShader::SHADING_METHOD)((shadingMethod + 1) % 3);
+		shadingMethod = (DeferredRenderer::SHADING_METHOD)((shadingMethod + 1) % 3);
 		
 		break;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2895)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2896)
@@ -1,3 +1,3 @@
-#include "SsaoShader.h"
+#include "DeferredRenderer.h"
 #include "FrameBufferObject.h"
 #include "RenderState.h"
@@ -123,5 +123,5 @@
 	switch (sampling)
 	{
-	case SsaoShader::POISSON:
+	case DeferredRenderer::POISSON:
 		{
 			static PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f);
@@ -129,5 +129,5 @@
 		}
 		break;
-	case SsaoShader::GAUSS:
+	case DeferredRenderer::GAUSS:
 		{
 			const float radius = 1.0f;
@@ -202,5 +202,5 @@
 
 
-SsaoShader::SsaoShader(int w, int h, Camera *cam, float scaleFactor):
+DeferredRenderer::DeferredRenderer(int w, int h, Camera *cam, float scaleFactor):
 mWidth(w), mHeight(h), 
 mCamera(cam),
@@ -240,5 +240,5 @@
 
 
-SsaoShader::~SsaoShader() 
+DeferredRenderer::~DeferredRenderer() 
 {
 	if (sCgSsaoProgram)	cgDestroyProgram(sCgSsaoProgram);
@@ -256,5 +256,5 @@
 
 
-void SsaoShader::SetUseTemporalCoherence(bool temporal)
+void DeferredRenderer::SetUseTemporalCoherence(bool temporal)
 {
 	mUseTemporalCoherence = temporal;
@@ -262,5 +262,5 @@
 
 
-void SsaoShader::Init(CGcontext context)
+void DeferredRenderer::Init(CGcontext context)
 {	
 	sCgDeferredProgram = 
@@ -436,5 +436,5 @@
 
 
-void SsaoShader::Render(FrameBufferObject *fbo, 
+void DeferredRenderer::Render(FrameBufferObject *fbo, 
 						const Matrix4x4 &oldProjViewMatrix,
 						float expFactor,
@@ -507,5 +507,5 @@
 
 
-void SsaoShader::ComputeSsao(FrameBufferObject *fbo, 
+void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, 
 							 float expFactor,
 							 const Matrix4x4 &oldProjViewMatrix
@@ -601,5 +601,5 @@
 
 
-void SsaoShader::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br)
+void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br)
 {
 	Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
@@ -630,5 +630,5 @@
 
 
-void SsaoShader::AntiAliasing(FrameBufferObject *fbo)
+void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo)
 {
 	GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();
@@ -670,5 +670,5 @@
 
 
-void SsaoShader::FirstPass(FrameBufferObject *fbo)
+void DeferredRenderer::FirstPass(FrameBufferObject *fbo)
 {
 	GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture();
@@ -721,5 +721,5 @@
 
 
-void SsaoShader::ComputeGlobIllum(FrameBufferObject *fbo, 
+void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo, 
 								  float expFactor,
 								  const Matrix4x4 &oldProjViewMatrix
@@ -827,5 +827,5 @@
 
 
-void SsaoShader::CombineIllum(FrameBufferObject *fbo)
+void DeferredRenderer::CombineIllum(FrameBufferObject *fbo)
 {
 	GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture();
@@ -884,5 +884,5 @@
 
 
-void SsaoShader::CombineSsao(FrameBufferObject *fbo)
+void DeferredRenderer::CombineSsao(FrameBufferObject *fbo)
 {
 	GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture();
@@ -933,5 +933,5 @@
 
 
-void SsaoShader::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap)
+void DeferredRenderer::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap)
 {
 	GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture();
@@ -995,5 +995,5 @@
 
 
-void SsaoShader::SetSamplingMethod(SAMPLING_METHOD s) 
+void DeferredRenderer::SetSamplingMethod(SAMPLING_METHOD s) 
 { 
 	if (s != mSamplingMethod)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h	(revision 2891)
+++ 	(revision )
@@ -1,95 +1,0 @@
-#ifndef _SsaoShader_H__
-#define _SsaoShader_H__
-
-#include "common.h"
-#include "glInterface.h"
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-
-namespace CHCDemoEngine 
-{ 
-
-class FrameBufferObject;
-class Vector3;
-class Camera;
-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 SsaoShader
-{
-public:
-	/** Constructor for a deferred shader taking the requested output image size,
-		the current camera,	and a scaling factor.
-			
-		The parameter scaleFactor must be reciprocal value of the 
-		scale factor used for creating the positions texture. It is used recover the 
-		exact scene size that was scaled in order to improve floating point precision.
-	*/
-	SsaoShader(int w, int h, Camera *cam, float scaleFactor);
-	/** The algorithm renders the scene given an fbo consists of 1 color buffer, 
-		1 position buffer, and 1 normal buffer.
-		We also need the  projection view matrix of the last frame for reprojection, and
-		a smoothing factor for temporal coherence
-	*/
-	void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor);
-
-	/** Initialises the deferred shader and loads the required shaders:
-		This function has to be called only once.
-	*/
-	static void Init(CGcontext context);
-
-	~SsaoShader();
-
-	void SetUseGlobIllum(bool useGlobIllum);
-	void SetUseTemporalCoherence(bool temporal);
-
-	enum SAMPLING_METHOD {POISSON, GAUSS};
-
-	void SetSamplingMethod(int s) { mSampling = s;}
-
-
-protected:
-
-	void ComputeSsao(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix);
-
-	void ComputeGlobIllum(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix);
-
-	void FirstPass(FrameBufferObject *fbo);
-
-	void CombineSsao(FrameBufferObject *fbo);
-	void CombineIllum(FrameBufferObject *fbo);
-
-	void AntiAliasing(FrameBufferObject *fbo);
-
-	/** Helper method that computes the view vectors in the corners of the current view frustum.
-	*/
-	void ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br);
-
-
-	////////////
-
-	int mWidth;
-	int mHeight;
-
-	/// this is just a scale factor for the scene depth in order to get better float precision in the shader
-	float mScaleFactor;
-
-	Camera *mCamera;
-
-	//FrameBufferObject *mOldFbo;
-	//FrameBufferObject *mNewFbo;
-	FrameBufferObject *mFbo;
-
-	bool mUseGlobIllum;
-	bool mUseTemporalCoherence;
-
-	int mSampling;
-	int mFboIndex;
-};
-
-} // namespace 
-
-#endif // _SsaoShader_H__
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2895)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2896)
@@ -531,5 +531,5 @@
 				</File>
 				<File
-					RelativePath=".\src\DeferredRenderer.cpp"
+					RelativePath=".\src\DeferredRenderer.h"
 					>
 				</File>
@@ -638,4 +638,8 @@
 				<File
 					RelativePath=".\src\chcdemo.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\DeferredRenderer.cpp"
 					>
 				</File>
