Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln	(revision 3207)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln	(revision 3212)
@@ -14,4 +14,7 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrradianceMapping", "IrradianceMapping.vcproj", "{91680C49-A358-48AE-A02C-66CB884B7D7F}"
+	ProjectSection(ProjectDependencies) = postProject
+		{03661866-4093-4B02-B26A-028EA91AF023} = {03661866-4093-4B02-B26A-028EA91AF023}
+	EndProjectSection
 EndProject
 Global
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3209)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3212)
@@ -7,23 +7,15 @@
 
 //#define NUM_SAMPLES 8
-//#define NUM_SAMPLES 16
+#define NUM_SAMPLES 16
 //#define NUM_SAMPLES 24
-#define NUM_SAMPLES 48
+//#define NUM_SAMPLES 96
 
-#define SAMPLE_INTENSITY 0.15f
-//#define SAMPLE_INTENSITY 2.0f
-
-#define SAMPLE_RADIUS 8e-1f
-//#define SAMPLE_RADIUS 15e-1f
-
-//#define DISTANCE_SCALE 1e-1f
 #define DISTANCE_SCALE 1e-2f
 
 //#define ILLUM_INTENSITY 8e-2f
 #define ILLUM_INTENSITY 5e-3f
-
+/// scale factor that takes angle of sample normal into account 
 #define VIEW_CORRECTION_SCALE 1.0f
 
-//#define NUM_SSAO_FILTERSAMPLES 80
 #define NUM_SSAO_FILTER_SAMPLES 16
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.h	(revision 3147)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.h	(revision 3212)
@@ -16,6 +16,7 @@
 public:
 	
+	// available texture formats
 	enum {FORMAT_INVALID, FORMAT_RGB, FORMAT_RGBA};
-	
+	// texture uv modes
 	enum {CLAMP, REPEAT};
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3209)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3212)
@@ -125,6 +125,5 @@
 
 		aoSample = tex2Dlod(ssaoTex, sampleTexCoord);
-		//sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz;
-
+		
 		// check spatial discontinuity
 		// note: using the depth from the color texture is not 100% correct as depth was
@@ -136,7 +135,9 @@
 		spatialFactor = 1.0f / max(len, 1e-3f);
 
+		convergenceFactor = aoSample.y + 1.0f;
+
+		//sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz;
 		//normalFactor = max(step(.2f, dot(sampleNorm, centerNormal)), 1e-2f);
-		convergenceFactor = aoSample.y + 1.0f;
-		
+
 		// combine the weights
 		w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor;
@@ -232,30 +233,2 @@
 	return OUT;
 }
-
-
-/** Function combining image and indirect illumination buffer using a 
-	depth and normal aware discontinuity filter.
-*/
-pixel SmoothSsao(fragment IN, 
-				 uniform sampler2D ssaoTex)
-{
-	pixel OUT;
-
-	float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));
-
-	float4 dummy;
-	const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f;
-
-	// get positions exactly between old texel centers
-	dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y;
-	dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y;
-	dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y;
-	dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y;
-
-	const float m1 = min(dummy.x, dummy.y);
-	const float m2 = min(dummy.z, dummy.w);
-
-	ao.y = min(ao.y, min(m1, m2));
-
-	return OUT;
-}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3209)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3212)
@@ -108,6 +108,4 @@
 	const float ssao = oldPixel.x;
 
-#if USE_EYESPACE_DEPTH
-
 	// calculate eye space position of sample in old frame
 	const float oldEyeSpaceDepth = oldPixel.w;
@@ -120,15 +118,4 @@
 	
 	const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth);
-
-#else
-
-	// calculate eye space position of sample in old frame
-	const float oldDepth = oldPixel.w;
-	// the depth projected into the old frame
-	const float projectedDepth = projPos.z;
-	// calculate depth difference 
-	const float depthDif = abs(projectedDepth - oldDepth);
-
-#endif
 
 	const float xOffs = 1.0f / 1024.0f;
@@ -176,5 +163,6 @@
 			 float3 tr, 
 			 float3 viewDir,
-			 sampler2D normalTex
+			 sampler2D normalTex,
+			 float sampleIntensity
 			 )
 {
@@ -224,5 +212,5 @@
 		cosAngle *= step(0.0f, dot(dirSample, normal));
 	
-		const float aoContrib = SAMPLE_INTENSITY / sqrLen;
+		const float aoContrib = sampleIntensity / sqrLen;
 		//const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f;
 
@@ -270,5 +258,5 @@
 			float3 viewDir,
 			float newWeight,
-			bool isMovingObject
+			float sampleIntensity
 			)
 {
@@ -310,5 +298,5 @@
 		// angle between current normal and direction to sample controls AO intensity.
 		const float cosAngle = max(dot(dirSample, normal), .0f);
-		const float aoContrib = SAMPLE_INTENSITY / sqrLen;
+		const float aoContrib = sampleIntensity / sqrLen;
 		//const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f;
 
@@ -338,16 +326,10 @@
 
 		//if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break;
-		if ((validSamples < 1.0f) && (numSamples >= 8) && !isMovingObject 
-			|| (newWeight > NUM_SAMPLES * 5) && (numSamples >= 8) && isMovingObject
-			)
-		{
-			break;
-		}
+		//if ((validSamples < 1.0f) && (numSamples >= 8)) break;
 	}
 
 	total_ao /= numSamples;
 
-	//return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples);
-	return float3(total_ao, validSamples, numSamples);
+	return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples);
 }
 
@@ -374,5 +356,7 @@
 		   uniform float3 oldtl,
 		   uniform float3 oldtr,
-		   uniform sampler2D attribsTex
+		   uniform sampler2D attribsTex,
+		   uniform float kernelRadius,
+		   uniform float sampleIntensity
 		   )
 {
@@ -396,8 +380,5 @@
 	const float invw = 1.0f / projPos.w;
 	projPos *= invw;
-	float scaleFactor = SAMPLE_RADIUS * invw;
-
-	const float sqrMoveSpeed = SqrLen(diffVec);
-	const bool isMovingObject = (sqrMoveSpeed > DYNAMIC_OBJECTS_THRESHOLD);
+	float scaleFactor = kernelRadius * invw;
 
 	
@@ -422,6 +403,6 @@
 	if (eyeSpaceDepth < 1e10f)
 	{
-		ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, isMovingObject);
-		//ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals);
+		ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity);
+		//ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity);
 	}
 	else
@@ -430,17 +411,16 @@
 	}
 
-	// equals the number of sampled shot in this pass
-	const float newWeight = ao.z;
+	const float squaredLen = SqrLen(diffVec);
 
 	// check if we have to reset pixel because one of the sample points was invalid
-	if (!isMovingObject)
-    //if (sqrMoveSpeed <= DYNAMIC_OBJECTS_THRESHOLD)
+	if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD)
 	{
 		if (ao.y > 4.0f) 
 			oldWeight = 0; 
 		else if (ao.y > 1.0f)
-			oldWeight = min(oldWeight, 4.0f * newWeight);
-	}
-
+			oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES);
+	}
+
+	const float newWeight = ao.z;
 	const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence);
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3210)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3212)
@@ -261,7 +261,4 @@
 	const bool oldDynamic = (squaredLen > DYNAMIC_OBJECTS_THRESHOLD);
 	const bool newDynamic = (oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD);
-
-	//const float xOffs = 1.0f / 1024.0f;	const float yOffs = 1.0f / 768.0f;
-	//const float eps = 1e-6f;
 
 	// actually 0 means pixel is valid
@@ -334,4 +331,6 @@
 	pix.color = color;
 	pix.color.xy = pValid.xy;
+	pix.color.z = color.w;
+
 	pix.normal = normal;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/lenseFlare.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/lenseFlare.cg	(revision 3212)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/lenseFlare.cg	(revision 3212)
@@ -0,0 +1,25 @@
+#include "../shaderenv.h"
+
+struct fragment
+{
+	float2 texCoords:  TEXCOORD0; 
+};
+
+float4 main(fragment IN, 
+			uniform sampler2D colors,
+			uniform sampler2D ,
+			): COLOR
+{
+	// center color
+	const float4 centerColor = tex2Dlod(colors, float4(IN.texCoords, 0, 0));
+	// center depth
+	const float4 centerDepth = float4(centerColor.w);
+	
+	const float2 lt = IN.texCoords + offsets[0];
+	const float2 rb = IN.texCoords + offsets[1];
+	const float2 rt = IN.texCoords + offsets[2];
+	const float2 lb = IN.texCoords + offsets[3];
+
+
+	return col;
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3168)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3212)
@@ -65,6 +65,7 @@
 				   uniform float3 br,
 				   uniform float3 tl,
-				   uniform float3 tr
-				   , uniform float3 viewDir
+				   uniform float3 tr, 
+				   float3 viewDir,
+				   float sampleIntensity
 				   )
 {
@@ -125,5 +126,5 @@
 		const float denom = (DISTANCE_SCALE + magSample * magSample);
 
-		float2 intensity = float2(SAMPLE_INTENSITY, ILLUM_INTENSITY);
+		float2 intensity = float2(sampleIntensity, ILLUM_INTENSITY);
 		intensity /= denom;
 
@@ -161,10 +162,12 @@
 		   uniform float3 br,
 		   uniform float3 tl,
-		   uniform float3 tr
+		   uniform float3 tr,
+		   uniform float kernelRadius,
+		   uniform float sampleIntensity
 		   )
 {
 	pixel2 OUT;
 
-	const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0));
+	const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)).xyz;
 
 	
@@ -180,5 +183,5 @@
 	float4 currentPos = mul(modelViewProj, eyeSpacePos);
 
-	const float w = SAMPLE_RADIUS / currentPos.w;
+	const float w = kernelRadius / currentPos.w;
 	currentPos /= currentPos.w;
 	
@@ -188,5 +191,5 @@
 	//-- compute color bleeding + ao
 
-	GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view));
+	GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view), sampleIntensity);
 	
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 3189)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h	(revision 3212)
@@ -58,4 +58,9 @@
 
 	void SetSortSamples(bool sortSamples) { mSortSamples = sortSamples; }
+
+	void SetSampleIntensity(float sampleIntensity);
+
+	void SetKernelRadius(float kernelRadius);
+
 
 	// hack: store the color buffer idx for the currently used flip flop-MRT here
@@ -150,4 +155,7 @@
 
 	bool mSortSamples;
+
+	float mKernelRadius;
+	float mSampleIntensity;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3203)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3212)
@@ -147,11 +147,18 @@
 float turbitity = 5.0f;
 
+// ssao parameters
+float ssaoKernelRadius = 1e-8f;
+float ssaoSampleIntensity = 0.2f;
+float ssaoTempCohFactor = 255.0;
+bool sortSamples = true;
+
 int shadowSize = 2048;
+
 /// the hud font
 glfont::GLFont myfont;
 
 // rendertexture
-static int texWidth = 1024;
-static int texHeight = 768;
+int texWidth = 1024;
+int texHeight = 768;
 
 int renderedObjects = 0;
@@ -211,9 +218,7 @@
 
 PerfTimer frameTimer, algTimer;
-/// the performance window
+/// the performance graph window
 PerformanceGraph *perfGraph = NULL;
 
-float ssaoTempCohFactor = 255.0;
-bool sortSamples = true;
 int sCurrentMrtSet = 0;
 
@@ -384,6 +389,12 @@
 		env.GetIntParam(string("renderMethod"), renderMethod);
 
+		env.GetFloatParam(string("ssaoKernelRadius"), ssaoKernelRadius);
+		env.GetFloatParam(string("ssaoSampleIntensity"), ssaoSampleIntensity);
+
 		//env.GetStringParam(string("modelPath"), model_path);
 		//env.GetIntParam(string("numSssaoSamples"), numSsaoSamples);
+
+		texWidth = winWidth;
+		texHeight = winHeight;
 
 		cout << "assumedVisibleFrames: " << assumedVisibleFrames << endl; 
@@ -398,5 +409,4 @@
 		cout << "useLODs: " << useLODs << endl;
 		cout << "camPosition: " << camPos << endl;
-		cout << "temporal coherence: " << ssaoTempCohFactor << endl;
 		cout << "shadow size: " << shadowSize << endl;
 		cout << "render method: " << renderMethod << endl;
@@ -404,4 +414,7 @@
 		cout << "use advanced shading: " << useAdvancedShading << endl;
 		cout << "turbitity: " << turbitity << endl;
+		cout << "temporal coherence: " << ssaoTempCohFactor << endl;
+		cout << "sample intensity: " << ssaoSampleIntensity << endl;
+		cout << "kernel radius: " << ssaoKernelRadius << endl;
 
 		//cout << "model path: " << model_path << endl;
@@ -1151,4 +1164,6 @@
 		deferredShader->SetShadingMethod(shadingMethod);
 		deferredShader->SetSamplingMethod(samplingMethod);
+		deferredShader->SetKernelRadius(ssaoKernelRadius);
+		deferredShader->SetSampleIntensity(ssaoSampleIntensity);
 		deferredShader->SetUseTemporalCoherence(useTemporalCoherence);
 		deferredShader->SetSortSamples(sortSamples);
@@ -1203,4 +1218,5 @@
 	{
 	case 27:
+		// write out current position on exit
 		Debug << "camPosition=" << camera->GetPosition().x << " " << camera->GetPosition().y << " " << camera->GetPosition().z << endl;
 		Debug << "camDirection=" << camera->GetDirection().x << " " << camera->GetDirection().y << " " << camera->GetDirection().z << endl;
@@ -1247,6 +1263,5 @@
 		break;
 	case '3':
-		if (trianglesPerVirtualLeaf >= 100)
-			trianglesPerVirtualLeaf -= 100;
+		if (trianglesPerVirtualLeaf >= 100) trianglesPerVirtualLeaf -= 100;
 		bvh->SetVirtualLeaves(trianglesPerVirtualLeaf);
 		break;
@@ -1269,5 +1284,16 @@
 	case '8':
 		ssaoTempCohFactor *= 2.0f;
-		//if (ssaoTempCohFactor > 1.0f) ssaoExpFactor = 1.0f;
+		break;
+	case '9':
+		ssaoKernelRadius *= 0.8f;
+		break;
+	case '0':
+		ssaoKernelRadius *= 1.2f;
+		break;
+	case 'n':
+		ssaoSampleIntensity *= 0.9f;
+		break;
+	case 'N':
+		ssaoSampleIntensity *= 1.1f;
 		break;
 	case 'l':
@@ -1344,7 +1370,8 @@
 		useAntiAliasing = !useAntiAliasing;
 		break;
-	case '9':
+	/*case '?':
 		sortSamples = !sortSamples;
 		break;
+	*/
 	default:
 		return;
@@ -2003,5 +2030,6 @@
 	
 	preetham->RenderSkyDome(-light->GetDirection(), camera, &renderState, !useToneMapping);
-	/// once again reset the renderState
+
+	/// once again reset the renderState just to make sure
 	renderState.Reset();
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3206)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3212)
@@ -76,6 +76,36 @@
 static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES];
 
+static GLuint sBurstTex;
+static GLuint sHaloTex[4];
 
 int DeferredRenderer::colorBufferIdx = 0;
+
+
+static void PrepareLenseFlare()
+{
+	sBurstTex = new Texture("burst.jpg");
+
+	Texture(const std::string &filename);
+
+	glEnable(GL_TEXTURE_2D);
+	glGenTextures(1, &sBurstTex);
+	glBindTexture(GL_TEXTURE_2D, sBurstTex);
+		
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals);
+
+	glBindTexture(GL_TEXTURE_2D, 0);
+	glDisable(GL_TEXTURE_2D);
+
+	delete [] randomNormals;
+
+	cout << "prepared lense flare textures" << endl;
+
+	PrintGLerror("prepare lense flare");
+}
 
 
@@ -300,11 +330,13 @@
 mShadingMethod(DEFAULT),
 mIllumFboIndex(0),
-mSortSamples(true)
+mSortSamples(true),
+mKernelRadius(1e-8f),
+mSampleIntensity(0.2f)
 {
 	///////////
 	//-- the flip-flop fbos
 
-	const int dsw = w / 2; const int dsh = h / 2;
-	//const int dsw = w; const int dsh = h;
+	//const int dsw = w / 2; const int dsh = h / 2;
+	const int dsw = w; const int dsh = h;
 
 	mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE);
@@ -321,5 +353,6 @@
 
 	///////////////
-	//-- the downsampled ssao + color bleeding textures: as GI is mostly low frequency, we can use lower resolution toimprove performance
+	//-- the downsampled ssao + color bleeding textures: 
+	//-- as GI is mostly low frequency, we can use lower resolution toimprove performance
 
 	mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE);
@@ -327,5 +360,6 @@
 	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
 	// downsample buffer for the normal texture
-	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST);
+	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
+
 
 	for (int i = 0; i < 2; ++ i)
@@ -395,6 +429,6 @@
 		 "samples", "bl", "br", "tl", "tr", 
 		 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 
-		 "oldtl", "oldtr", "attribsTex"};
-	sCgSsaoProgram->AddParameters(ssaoParams, 0, 18);
+		 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"};
+	sCgSsaoProgram->AddParameters(ssaoParams, 0, 20);
 	
 	string giParams[] = 
@@ -702,7 +736,11 @@
 
 	for (int j = 0; j < 4; ++ j, ++ i)
+	{
 		sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z);
+	}
 
 	sCgSsaoProgram->SetTexture(i ++, attribsTex);
+	sCgSsaoProgram->SetValue1f(i ++, mKernelRadius);
+	sCgSsaoProgram->SetValue1f(i ++, mSampleIntensity);
 
 
@@ -957,4 +995,26 @@
 
 
+#if TODO
+
+void DeferredRenderer::SetNumSamples(int numSamples)
+{
+	mNumSamples = numSamples;
+}
+
+#endif
+
+
+void DeferredRenderer::SetSampleIntensity(float sampleIntensity)
+{
+	mSampleIntensity = sampleIntensity;
+}
+
+
+void DeferredRenderer::SetKernelRadius(float kernelRadius)
+{
+	mKernelRadius = kernelRadius;
+}
+
+
 void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo, 
 											 DirectionalLight *light,
@@ -1058,5 +1118,5 @@
 	mDownSampleFbo->Bind();
 
-// prepare downsampled color and normal texture for ssao
+	// prepare downsampled depth and normal texture for ssao
 	glDrawBuffers(2, mrt);
 
@@ -1066,5 +1126,4 @@
 	PrintGLerror("prepareSsao");
 }
-
 
 
@@ -1197,3 +1256,23 @@
 }
 
+
+void DeferredRenderer::LenseFlare(FrameBufferObject *fbo)
+{
+	ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx);
+
+	FlipFbos(fbo);
+
+	sCgLenseFlareProgram->SetTexture(0, colorsTex);
+	sCgLenseFlareProgram->SetTexture(1, sBurstTex);
+	sCgLenseFlareProgram->SetTexture(2, sHaloTex[0]);
+	sCgLenseFlareProgram->SetTexture(3, sHaloTex[1]);
+	sCgLenseFlareProgram->SetValue1f(4, sHaloTex[2]);
+	sCgLenseFlareProgram->SetValue1f(5, sHaloTex[3]);
+
+	DrawQuad(sCgLenseFlareProgram);
+
+	PrintGLerror("LenseFlare");
+}
+
+
 } // namespace
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3202)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3212)
@@ -772,4 +772,8 @@
 			</File>
 			<File
+				RelativePath=".\src\shaders\lenseFlare.cg"
+				>
+			</File>
+			<File
 				RelativePath=".\src\shaders\mrt.cg"
 				>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3203)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3212)
@@ -45,4 +45,6 @@
 
 3) normal mapping
+
+working but already done!
 
 
@@ -120,2 +122,13 @@
    q: is it good to choose new weight as we do? (approx 4 frames)
    or shouldn't we just completely reset sample?
+
+
+
+shading todo:
+
+bloom
+dof
+lense flar
+god rays
+sun disc
+environment lighting
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3202)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3212)
@@ -57,4 +57,7 @@
 # window options
 
+//winWidth=800
+//winHeight=600
+
 winWidth=1024
 winHeight=768
@@ -89,2 +92,6 @@
 //camPosition=465.626 248.788 184.978
 //camDirection=0.0592959 0.998021 0.0209425
+
+ssaoKernelRadius=8e-1f
+
+ssaoSampleIntensity=0.2f
