Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2848)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2897)
@@ -148,5 +148,5 @@
 	++ mFrameId;
 
-	mBvh->InitFrame();
+	mBvh->InitFrame(mCamera);
 
 	mStats.Reset();
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2893)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2897)
@@ -114,5 +114,5 @@
 		   const uniform float4x4 oldModelViewProj,
 		   uniform float maxDepth,
-		   uniform float expFactor
+		   uniform float temporalCoherence
 		   )
 {
@@ -157,17 +157,25 @@
 	const float depthDif = 1.0f - newDepth / oldDepth;
 
-
-	if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 
+	float oldWeight = clamp(oldCol.z, 0, temporalCoherence);
+	float newWeight;
+
+	if ((temporalCoherence > 0) &&
+		(tex.x >= 0.0f) && (tex.x < 1.0f) && 
 		(tex.y >= 0.0f) && (tex.y < 1.0f) && 
-		(abs(depthDif) < 1e-3f))
+		(abs(depthDif) < 1e-4f))
 	{
-		OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor);
+		newWeight = oldWeight + 1;
+
+		//OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor);
+		OUT.illum_col = (float4)(ao + oldCol.x * oldWeight) / newWeight;
 	}
 	else
 	{
 		OUT.illum_col = (float4)ao;
+		newWeight = 0;
 	}
 
-	//OUT.illum_col.xyz = viewDir;
+
+	OUT.illum_col.z = newWeight;
 	OUT.illum_col.w = currentDepth;
 
@@ -188,4 +196,5 @@
 	//OUT.illum_col = ao;
 
+	//OUT.illum_col.z = ao.z;
 	OUT.illum_col.w = ao.w;
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 2892)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 2897)
@@ -121,5 +121,5 @@
 		   const uniform float4x4 oldModelViewProj,
 		   uniform float maxDepth,
-		   uniform float expFactor
+		   uniform float temporalCoherence
 		   )
 {
@@ -167,18 +167,30 @@
 	const float depthDif = 1.0f - newDepth / oldDepth;
 
-
-	if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 
+	float oldWeight = clamp(oldSsao.z, 0, temporalCoherence);
+	float newWeight;
+
+	if ((temporalCoherence > 0.0f) &&
+		(tex.x >= 0.0f) && (tex.x < 1.0f) && 
 		(tex.y >= 0.0f) && (tex.y < 1.0f) && 
 		(abs(depthDif)  < 1e-3f))
 	{
-		OUT.ssao_col.x = new_color.w * expFactor + oldSsao.x * (1.0f - expFactor);
-		OUT.illum_col = new_color * expFactor + oldIllum * (1.0f - expFactor);
+		newWeight = oldWeight + 1;
+
+		//OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor);
+		OUT.ssao_col.x = (new_color.w + oldSsao.x * oldWeight) / newWeight;
+		OUT.illum_col  = (new_color + oldIllum * oldWeight) / newWeight;
+
+		//OUT.ssao_col.x = new_color.w * expFactor + oldSsao.x * (1.0f - expFactor);
+		//OUT.illum_col = new_color * expFactor + oldIllum * (1.0f - expFactor);
 	}
 	else
 	{
+		newWeight = 0;
+
 		OUT.ssao_col.x = new_color.w;
 		OUT.illum_col = new_color;
 	}
 
+	OUT.ssao_col.z = newWeight;
 	OUT.ssao_col.w = currentDepth;
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2892)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2897)
@@ -137,4 +137,5 @@
 
 	orthoCam->SetNear(0.0f);
+	orthoCam->Yaw(.5 * M_PI);
 	orthoCam->SetDirection(Vector3(0, 0, -1));
 
@@ -155,19 +156,20 @@
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	glFrontFace(GL_CCW);
-	glCullFace(GL_BACK);
-	
-	glEnable(GL_CULL_FACE);
+	glDisable(GL_CULL_FACE);
 
 	glShadeModel(GL_FLAT);
 	glEnable(GL_DEPTH_TEST);
 
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix();
+	glLoadIdentity();
+
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
+	glLoadIdentity();
 
 	glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 
 
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
 
 	orthoCam->SetupCameraView();
@@ -175,9 +177,18 @@
 	mDepth = new float[texHeight * texWidth];
 
+	Camera *oldCam = renderer->GetCamera();
+	renderer->SetCamera(orthoCam);
+
 	renderer->RenderScene();
-	
+
+	renderer->SetCamera(oldCam);
+	
+
+	glEnable(GL_CULL_FACE);
+
+	glMatrixMode(GL_MODELVIEW);
 	glPopMatrix();
+	
 	glMatrixMode(GL_PROJECTION);
-	
 	glPopMatrix();
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2895)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2897)
@@ -166,15 +166,17 @@
 
 	//////////////
-	//-- these members define the current state
+	//-- members that define the current state
 
 	/// stores the visibility related info 
 	VisibilityInfo mVisibility[NUM_STATES];
-
-	/////////
-	//-- used for view frustum culling
-
+	
+	/// used for view frustum culling
 	int mPlaneMask[NUM_STATES];
 	int mPreferredPlane[NUM_STATES];
 
+	/// when the node was last rendered
+	int mLastRenderedFrame[NUM_STATES];
+
+
 	// the current state
 	static int sCurrentState;
@@ -184,11 +186,11 @@
 
 
+	/// #leaves under this node
+	int mNumLeaves;
+
+
 	////////////
 	//-- rendering related options
 	
-	/// when the node was last rendered
-	int mLastRenderedFrame;
-	/// #leaves under this node
-	int mNumLeaves;
 	
 	// Indices to first and last triangle in the triangle array
@@ -322,7 +324,8 @@
 }
 
+
 int BvhNode::GetLastRenderedFrame() const 
 { 
-	return mLastRenderedFrame; 
+	return mLastRenderedFrame[sCurrentState]; 
 }
 	
@@ -330,5 +333,5 @@
 void BvhNode::SetLastRenderedFrame(int lastRenderedFrame)
 {
-	mLastRenderedFrame = lastRenderedFrame;
+	mLastRenderedFrame[sCurrentState] = lastRenderedFrame;
 }
 	
@@ -468,5 +471,5 @@
 	/** Sets the scene camera
 	*/
-	void SetCamera(Camera * camera) { mCamera = camera; }
+	//void SetCamera(Camera * camera) { mCamera = camera; }
 
 	///////////////
@@ -516,5 +519,5 @@
 	/** Sets frame dependent values
 	*/
-	void InitFrame();
+	void InitFrame(Camera *camera);
 	/** This gives the orthogonal distance from the viewpoint to the nearest bounding box vertex
 		note that negative values can appear because culling is done only afterwards
@@ -640,7 +643,4 @@
 	/// #of entities
 	size_t mGeometrySize;
-
-	/// the current camera
-	Camera *mCamera;
 
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h	(revision 2895)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h	(revision 2897)
@@ -29,10 +29,10 @@
 		The shadow map has resolution size * size.
 	*/
-	ShadowMap(int size, const AxisAlignedBox3 &sceneBox, Camera *cam);
+	ShadowMap(Light *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam);
 
 	~ShadowMap();
 	/** Computes the shadow map
 	*/
-	void ComputeShadowMap(Light *light, RenderTraverser *traverser);
+	void ComputeShadowMap(RenderTraverser *traverser);
 	/** Returns computed shadow texture.
 	*/
@@ -49,4 +49,7 @@
 	*/
 	int GetSize() const { return mSize; }
+
+	Camera *GetShadowCamera() const { return mShadowCam; }
+
 
 protected:
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 2897)
@@ -54,5 +54,5 @@
 	void SetSamplingMethod(SAMPLING_METHOD s);
 
-	void SetShadingMethod(SHADING_METHOD s) { mShadingMethod = s; }
+	void SetShadingMethod(SHADING_METHOD s);
 
 protected:
@@ -86,6 +86,4 @@
 	Camera *mCamera;
 
-	//FrameBufferObject *mOldFbo;
-	//FrameBufferObject *mNewFbo;
 	FrameBufferObject *mFbo;
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2895)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2897)
@@ -77,5 +77,4 @@
 mAxis(-1), 
 mDepth(0), 
-mLastRenderedFrame(-999),
 mFirst(-1), 
 mLast(-1),
@@ -91,4 +90,5 @@
 		mPlaneMask[i] = 0;
 		mPreferredPlane[i]= 0;
+		mLastRenderedFrame[i] = -1;
 	}
 }
@@ -105,7 +105,8 @@
 	{
 		mVisibility[i].Reset();
-	}
-
-	mLastRenderedFrame = -999;
+		mLastRenderedFrame[i] = -1;
+		mPlaneMask[i] = 0;
+		mPreferredPlane[i]= 0;
+	}
 }
 
@@ -179,5 +180,4 @@
 void Bvh::Init()
 {
-	mCamera = NULL;
 	mRoot = NULL;
 	mVertices = NULL;
@@ -364,14 +364,14 @@
 
 
-void Bvh::InitFrame()
+void Bvh::InitFrame(Camera *cam)
 {
 	// = 0011 1111 which means that at the beginning, all six planes have to frustum culled
 	mRoot->mPlaneMask[BvhNode::sCurrentState] = 0x3f;
 
-	mCamera->CalcFrustum(sFrustum);
+	cam->CalcFrustum(sFrustum);
 	sFrustum.CalcNPVertexIndices(sClipPlaneAABBVertexIndices);
 
 	// store near plane
-	sNearPlane = Plane3(mCamera->GetDirection(), mCamera->GetPosition());
+	sNearPlane = Plane3(cam->GetDirection(), cam->GetPosition());
 }
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp	(revision 2894)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp	(revision 2897)
@@ -79,6 +79,6 @@
 
 
-ShadowMap::ShadowMap(int size, const AxisAlignedBox3 &sceneBox, Camera *cam):
-mSceneBox(sceneBox), mSize(size), mCamera(cam)
+ShadowMap::ShadowMap(Light *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam):
+mSceneBox(sceneBox), mSize(size), mCamera(cam), mLight(light)
 {
 	mFbo = new FrameBufferObject(size, size, FrameBufferObject::DEPTH_32, true);
@@ -94,21 +94,19 @@
 {
 	DEL_PTR(mFbo);
-}
-
-
-
-void ShadowMap::ComputeShadowMap(Light *light, RenderTraverser *traverser)
-{
-	mLight = light;
-
+	DEL_PTR(mShadowCam);
+}
+
+
+void ShadowMap::ComputeShadowMap(RenderTraverser *renderer)
+{
 	const float xlen = Magnitude(mSceneBox.Diagonal() * 0.5f);
 	const float ylen = Magnitude(mSceneBox.Diagonal() * 0.5f);
 	
-	mShadowCam->SetDirection(light->GetDirection());
+	mShadowCam->SetDirection(mLight->GetDirection());
 	
 	// set position so that we can see the whole scene
 	Vector3 pos = mSceneBox.Center();
 
-	pos -= light->GetDirection() * Magnitude(mSceneBox.Diagonal() * 0.5f);
+	pos -= mLight->GetDirection() * Magnitude(mSceneBox.Diagonal() * 0.5f);
 	mShadowCam->SetPosition(pos);
 
@@ -142,9 +140,9 @@
 	glMatrixMode(GL_MODELVIEW);
 	glPushMatrix();
-
 	glLoadIdentity();
 
 	// setup shadow camera
 	mShadowCam->SetupCameraView();
+
 
 	//////////////
@@ -168,5 +166,6 @@
 	//-- render scene into shadow map
 
-	traverser->RenderScene();
+	renderer->RenderScene();
+
 	
 	glDisable(GL_POLYGON_OFFSET_FILL);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2896)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2897)
@@ -83,4 +83,8 @@
 RenderQueue *renderQueue = NULL;
 
+// traverses and renders the hierarchy
+RenderTraverser *shadowTraverser = NULL;
+
+
 /// these values get scaled with the frame rate
 static float keyForwardMotion = 30.0f;
@@ -211,5 +215,6 @@
 void MiddleMotion(int x, int y);
 void CalcDecimalPoint(string &str, int d);
-void ResetTraverser();
+
+RenderTraverser *CreateTraverser(Camera *cam);
 
 void KeyHorizontalMotion(float shift);
@@ -427,5 +432,5 @@
 	bvh->SetVirtualLeaves(trianglesPerVirtualLeaf);
 
-	bvh->SetCamera(camera);
+	//bvh->SetCamera(camera);
 	
 	InitCg();
@@ -435,8 +440,9 @@
 
 	// initialize the render traverser
-	ResetTraverser();
+	traverser = CreateTraverser(camera);
 
 	visualization = new Visualization(bvh, camera, NULL, &state);
-
+	
+	state.SetRenderType(RenderState::FIXED);
 	sceneQuery = new SceneQuery(bvh->GetBox(), traverser);
 
@@ -691,8 +697,8 @@
 
 
-void ResetTraverser()
-{
-	DEL_PTR(traverser);
-
+RenderTraverser *CreateTraverser(Camera *cam)
+{
+	RenderTraverser *tr;
+	
 	bvh->ResetNodeClassifications();
 
@@ -700,33 +706,35 @@
 	{
 	case RenderTraverser::CULL_FRUSTUM:
-		traverser = new FrustumCullingTraverser();
+		tr = new FrustumCullingTraverser();
 		break;
 	case RenderTraverser::STOP_AND_WAIT:
-		traverser = new StopAndWaitTraverser();
+		tr = new StopAndWaitTraverser();
 		break;
 	case RenderTraverser::CHC:
-		traverser = new CHCTraverser();
+		tr = new CHCTraverser();
 		break;
 	case RenderTraverser::CHCPLUSPLUS:
-		traverser = new CHCPlusPlusTraverser();
+		tr = new CHCPlusPlusTraverser();
 		break;
 	
 	default:
-		traverser = new FrustumCullingTraverser();
-	}
-
-	traverser->SetCamera(camera);
-	traverser->SetHierarchy(bvh);
-	traverser->SetRenderQueue(renderQueue);
-	traverser->SetRenderState(&state);
-	traverser->SetUseOptimization(useOptimization);
-	traverser->SetUseRenderQueue(useRenderQueue);
-	traverser->SetVisibilityThreshold(threshold);
-	traverser->SetAssumedVisibleFrames(assumedVisibleFrames);
-	traverser->SetMaxBatchSize(maxBatchSize);
-	traverser->SetUseMultiQueries(useMultiQueries);
-	traverser->SetUseTightBounds(useTightBounds);
-	traverser->SetUseDepthPass(renderType == RenderState::DEPTH_PASS);
-	traverser->SetRenderQueue(renderQueue);
+		tr = new FrustumCullingTraverser();
+	}
+
+	tr->SetCamera(cam);
+	tr->SetHierarchy(bvh);
+	tr->SetRenderQueue(renderQueue);
+	tr->SetRenderState(&state);
+	tr->SetUseOptimization(useOptimization);
+	tr->SetUseRenderQueue(useRenderQueue);
+	tr->SetVisibilityThreshold(threshold);
+	tr->SetAssumedVisibleFrames(assumedVisibleFrames);
+	tr->SetMaxBatchSize(maxBatchSize);
+	tr->SetUseMultiQueries(useMultiQueries);
+	tr->SetUseTightBounds(useTightBounds);
+	tr->SetUseDepthPass(renderType == RenderState::DEPTH_PASS);
+	tr->SetRenderQueue(renderQueue);
+
+	return tr;
 }
 
@@ -866,9 +874,4 @@
 	}
 	
-	if (showShadowMap && !shadowMap)
-	{
-		const float shadowSize = 4096;
-		shadowMap = new ShadowMap(shadowSize, bvh->GetBox(), camera);
-	}
 
 	// render without shading
@@ -908,9 +911,18 @@
 	case RenderState::DEFERRED:
 
-		// change CHC state (must be done for each change of camera)
-		BvhNode::SetCurrentState(1);
-
-		if (showShadowMap && shadowChanged)
+		if (showShadowMap)// && shadowChanged)
 		{
+			if (!shadowMap)
+			{
+				const float shadowSize = 4096;
+				shadowMap = new ShadowMap(light, shadowSize, bvh->GetBox(), camera);
+			}
+
+			// change CHC state (must be done for each change of camera)
+			BvhNode::SetCurrentState(1);
+
+			if (!shadowTraverser)
+				shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera());
+
 			shadowChanged = false;
 
@@ -921,5 +933,5 @@
 
 			// the scene is rendered withouth any shading	
-			shadowMap->ComputeShadowMap(light, traverser);
+			shadowMap->ComputeShadowMap(shadowTraverser);
 
 			// change back state
@@ -1073,5 +1085,14 @@
 	case 32: //space
 		renderMode = (renderMode + 1) % RenderTraverser::NUM_TRAVERSAL_TYPES;
-		ResetTraverser();
+
+		DEL_PTR(traverser);
+		traverser = CreateTraverser(camera);
+
+		if (shadowTraverser && shadowMap) 
+		{
+			DEL_PTR(shadowTraverser);
+			//shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera());
+		}
+
 		break;
 	case 'h':
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2896)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2897)
@@ -50,6 +50,5 @@
 static CGparameter sNoiseTexParam;
 static CGparameter sNoiseMultiplierParam;
-static CGparameter sExpFactorParam;
-
+static CGparameter sTemporalCoherenceParam;
 
 
@@ -69,5 +68,5 @@
 static CGparameter sNoiseTexGiParam;
 static CGparameter sNoiseMultiplierGiParam;
-static CGparameter sExpFactorGiParam;
+static CGparameter sTemporalCoherenceGiParam;
 
 
@@ -299,5 +298,4 @@
 		cgGLLoadProgram(sCgSsaoProgram);
 
-		// we need size of texture for scaling
 		sPositionsTexParam = cgGetNamedParameter(sCgSsaoProgram, "positions");  
 		sColorsTexParam = cgGetNamedParameter(sCgSsaoProgram, "colors");  
@@ -308,5 +306,5 @@
 		sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj");
 		sMaxDepthParam = cgGetNamedParameter(sCgSsaoProgram, "maxDepth");
-		sExpFactorParam = cgGetNamedParameter(sCgSsaoProgram, "expFactor");
+		sTemporalCoherenceParam = cgGetNamedParameter(sCgSsaoProgram, "temporalCoherence");
 
 		sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex");  
@@ -339,5 +337,5 @@
 		sOldModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "oldModelViewProj");
 		sMaxDepthGiParam = cgGetNamedParameter(sCgGiProgram, "maxDepth");
-		sExpFactorGiParam = cgGetNamedParameter(sCgGiProgram, "expFactor");
+		sTemporalCoherenceGiParam = cgGetNamedParameter(sCgGiProgram, "temporalCoherence");
 
 		sSamplesGiParam = cgGetNamedParameter(sCgGiProgram, "samples");
@@ -437,15 +435,16 @@
 
 void DeferredRenderer::Render(FrameBufferObject *fbo, 
-						const Matrix4x4 &oldProjViewMatrix,
-						float expFactor,
-						ShadowMap *shadowMap)
-{
-	
+							  const Matrix4x4 &oldProjViewMatrix,
+							  float expFactor,
+							  ShadowMap *shadowMap)
+{
 	// switch roles of old and new fbo
 	// the algorihm uses two input fbos, where the one
 	// contais the color buffer from the last frame, 
 	// the other one will be written
+
+	mFboIndex = 2 - mFboIndex;
 	//swap(mNewFbo, mOldFbo);	
-	mFboIndex = 2 - mFboIndex;
+
 	FrameBufferObject::Release();
 
@@ -463,10 +462,10 @@
 	glLoadIdentity();
 
+	const float offs = 0.5f;
+	glOrtho(-offs, offs, -offs, offs, 0, 1);
+
 	glMatrixMode(GL_MODELVIEW);
 	glPushMatrix();
 	glLoadIdentity();
-
-	const float offs = 0.5f;
-	glOrtho(-offs, offs, -offs, offs, 0, 1);
 
 	if (shadowMap)
@@ -557,4 +556,5 @@
 	cgGLSetParameter1f(sMaxDepthParam, mScaleFactor);
 	
+	cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255 : 0);
 
 	if (mUseTemporalCoherence || mRegenerateSamples)
@@ -570,6 +570,4 @@
 	}
 
-	cgGLSetParameter1f(sExpFactorParam, mUseTemporalCoherence ? expFactor : 1.0f);
-
 	Vector3 tl, tr, bl, br;
 	ComputeViewVectors(tl, tr, bl, br);
@@ -782,4 +780,6 @@
 	cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor);
 
+	cgGLSetParameter1f(sTemporalCoherenceGiParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255 : 0);
+
 
 	if (mUseTemporalCoherence || mRegenerateSamples)
@@ -787,5 +787,4 @@
 		mRegenerateSamples = false;
 		cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f));
-		cgGLSetParameter1f(sExpFactorGiParam, expFactor);
 
 		// q: should we generate new samples or only rotate the old ones?
@@ -796,5 +795,4 @@
 	}
 
-	cgGLSetParameter1f(sExpFactorParam, mUseTemporalCoherence ? expFactor : 1.0f);
 
 	Vector3 tl, tr, bl, br;
@@ -1004,3 +1002,13 @@
 }
 
+
+void DeferredRenderer::SetShadingMethod(SHADING_METHOD s)
+{
+	if (s != mShadingMethod)
+	{
+		mShadingMethod = s; 
+		mRegenerateSamples = true;
+	}
+}
+
 } // namespace
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2802)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2897)
@@ -76,11 +76,8 @@
 	/** Sets the camera.
 	*/
-	void SetCamera(Camera *cam)  {mCamera = cam;}
+	void SetCamera(Camera *cam) { mCamera = cam;}
 	/** Sets the render queue.
 	*/
 	void SetRenderQueue(RenderQueue *rq) {mRenderQueue =rq;}
-	/** Renders a visualization of the hierarchy
-	*/
-	void RenderVisualization();
 	/** Sets the current render state
 	*/
@@ -133,4 +130,8 @@
 	*/
 	const SceneEntityContainer &GetVisibleObjects() const { return mVisibleObjects; }
+	/** Returns the current camera.
+	*/
+	Camera *GetCamera() const { return mCamera; }
+
 
 protected:
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 2892)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 2897)
@@ -10,5 +10,5 @@
 winHeight=768
 camPosition=483.398f 242.364f 186.078f
-camDirection=1 0 0
+camDirection=0 1 0
 useFullScreen=0
 useLODs=1
