Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3196)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3198)
@@ -6,14 +6,10 @@
 //-- ssao + gi parameters
 
-//#define NUM_SAMPLES 8
+#define NUM_SAMPLES 8
 //#define NUM_SAMPLES 16
-#define NUM_SAMPLES 24
+//#define NUM_SAMPLES 24
 
-// for quadratic falloff
-//#define SAMPLE_INTENSITY 0.9f
-//#define SAMPLE_INTENSITY 2.0f
-
-//#define SAMPLE_INTENSITY 0.075f
-#define SAMPLE_INTENSITY 0.2f
+#define SAMPLE_INTENSITY 0.5f
+//#define SAMPLE_INTENSITY 1.0f
 
 #define SAMPLE_RADIUS 8e-1f
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg	(revision 3168)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg	(revision 3198)
@@ -103,6 +103,41 @@
 	// hack: no translational component anyway
 	OUT.oldWorldPos = oldOffs;
+	//OUT.oldWorldPos = float4(1e20f, 1e20f, 1e20f, oldOffs.w);
 	OUT.worldPos = offs;
 
 	return OUT;
 }
+
+/*
+
+pixel fragtex(fragin IN, 
+			  uniform sampler2D tex: TEXUNIT0,
+			  uniform float4x4 viewMatrix
+			  )
+{
+	float4 texColor = tex2D(tex, IN.texCoord.xy);
+
+	// account for alpha blending
+	if (texColor.w < 0.5f) discard;
+
+	pixel pix;
+
+	// save color in first render target
+	// hack: use combination of emmisive + diffuse (emmisive used as constant ambient term)
+	pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor; 
+	// save world space normal in rt => transform back into world space by
+	// multiplying with inverse view. since transforming normal with T means to 
+	// multiply with the inverse transpose of T, we multiple with 
+	// Transp(Inv(Inv(view))) = Transp(view)
+	pix.norm = normalize(mul(transpose(viewMatrix), IN.normal).xyz);
+	//pix.norm = IN.normal.xyz;
+	// compute eye linear depth
+	pix.col.w = 1e20f;//length(IN.eyePos.xyz);
+
+	// the scene entity id
+	//pix.id = glstate.fog.color.xyz;
+	// the offset to the world pos from old frame
+	pix.offsVec = IN.oldWorldPos.xyz - IN.worldPos.xyz;
+
+	return pix;
+}*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3197)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3198)
@@ -203,5 +203,5 @@
 inline float PixelValid(sampler2D oldTex,
 						float4 color,
-						float3 diffVec,
+						float3 difVec,
 						float2 texCoord,
 						float3 viewDir,
@@ -229,5 +229,5 @@
 
 	// compute position from old frame for dynamic objects + translational portion
-	const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz;
+	const float3 translatedPos = difVec - oldEyePos + worldPos.xyz;
 
 
@@ -254,5 +254,5 @@
 	
 	const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth);
-	const float squaredLen = SqrLen(diffVec);
+	const float squaredLen = SqrLen(difVec);
 	
 	// test if this pixel was not valid in the old frame
@@ -280,7 +280,6 @@
 
 
-pixel PrepareSsao(fragment IN,
+float4 PrepareSsao(fragment IN,
 				   uniform sampler2D colorsTex,
-				   uniform sampler2D normalsTex,
 				   uniform sampler2D diffVals,
 				   uniform sampler2D oldTex,
@@ -292,46 +291,11 @@
 				   uniform float3 oldtr,
 				   uniform float3 oldEyePos
-				   )
+				   ): COLOR0
 {   
-	pixel pix;
-
-	const float3 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0 ,0)).xyz;
-
-	const float3 viewDir = IN.view;
 	float4 color = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0));
-
-	
-	/*float4 dummy;
-	const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f;
-	//const float xoffs = 1.0f / 1024.0f; const float yoffs = 1.0f / 768.0f;
-
-	dummy.x = tex2Dlod(colorsTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).w;
-	dummy.y = tex2Dlod(colorsTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).w;
-	dummy.z = tex2Dlod(colorsTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).w;
-	dummy.w = tex2Dlod(colorsTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).w;
-	color.w = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w));
-	//color.w = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w));
-	*/
-	
-	//const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0 ,0)).xyz);
-
-	float3 dummy[4];
-	const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f;
-	//const float xoffs = 1.0f / 1024.0f; const float yoffs = 1.0f / 768.0f;
-
-	dummy[0] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).xyz;
-	dummy[1] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).xyz;
-	dummy[2] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).xyz;
-	dummy[3] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).xyz;
-	
-	float dot1 = dot(dummy[0], dummy[3]);
-	float dot2 = dot(dummy[1], dummy[2]);
-
-	float isEdge = step(.0f, dot1) * step(.0f, dot2);
-
-	const float3 normal = isEdge * normalize(dummy[0] + dummy[1] + dummy[2] + dummy[3]);
-
 	// store scaled view vector so wie don't have to normalize for e.g., ssao
 	color.w /= length(IN.view);
+
+	const float4 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0, 0));
 
 	// do reprojection and filter out the pixels that are not save
@@ -340,5 +304,5 @@
 							  difVec.xyz,
 							  IN.texCoord,
-							  viewDir,
+							  IN.view,
 							  oldEyePos,
 							  modelViewProj,
@@ -347,11 +311,7 @@
 							  );
 
-	pix.color = color;
-	pix.color.x = pValid;
-
-	pix.normal = normal;
-	pix.diffVal = difVec;
-
-	return pix;
+	color.x = pValid;
+
+	return color;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3197)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3198)
@@ -122,5 +122,5 @@
 	for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i)
 	{
-		sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0);
+		sampleTexCoord = float4(texCoord + filterOffs[i] * scale, .0f, .0f);
 
 		aoSample = tex2Dlod(ssaoTex, sampleTexCoord);
@@ -128,5 +128,6 @@
 
 		// check spatial discontinuity
-		// using the depth from the color texture is not 100% correct as depth was
+
+		// note: using the depth from the color texture is not 100% correct as depth was
 		// not scaled with the interpolated view vector depth yet ...
 		samplePos = ReconstructSamplePos(colorsTex, sampleTexCoord.xy, bl, br, tl, tr);
@@ -134,17 +135,12 @@
 
 		len = min(SqrLen(centerPos - samplePos), 1e2f);
-
 		spatialFactor = 1.0f / max(len, 1e-3f);
 
 		//normalFactor = max(step(.0f, dot(sampleNorm, centerNormal)), 1e-2f);
-		//normalFactor = max(dot(sampleNorm, samplePos), 1e-3f);
 		convergenceFactor = aoSample.y + 1.0f;
-		//convergenceFactor = max(step(0.5f + NUM_SAMPLES, aoSample.y), 1e-2f);
-		//convergenceFactor = aoSample.y;
-
+		
 		// combine the weights
 		w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor;
-		//w = spatialFactor * normalFactor;
-
+		
 		average += aoSample.x * w;
 		total_w += w;
@@ -178,20 +174,25 @@
 	float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));
 
-	float4 dummy;
-	//const float xoffs = .5f / 1024.0f;	const float yoffs = .5f / 768.0f;
-	const float xoffs = 1.0f / 1024.0f;	const float yoffs = 1.0f / 768.0f;
-
-	dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).w;
-	dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).w;
-	dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).w;
-	dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).w;
-
-	/*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 convergence = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w));
-	//const float convergence = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w));
+	// get the minimum convergence by exactly sampling the 4 surrounding
+	// texels in the old texture, otherwise flickering because convergence
+	// will be interpolated when upsampling and filter size does not match!
+	float4 texelCenterConv;
+	const float w = 512.0f; const float h = 384.0f;
+	const float xoffs = .5f / w; const float yoffs = .5f / h;
+
+	// get position exactly between old texel centers
+	float2 center;
+	center.x = float(floor(IN.texCoord.x * w - .5f) + 1.0f) / w;
+	center.y = float(floor(IN.texCoord.y * h - .5f) + 1.0f) / h;
+
+	texelCenterConv.x = tex2Dlod(ssaoTex, float4(center + float2(xoffs, yoffs), 0, 0)).y;
+	texelCenterConv.y = tex2Dlod(ssaoTex, float4(center + float2(xoffs, -yoffs), 0, 0)).y;
+	texelCenterConv.z = tex2Dlod(ssaoTex, float4(center + float2(-xoffs, yoffs), 0, 0)).y;
+	texelCenterConv.w = tex2Dlod(ssaoTex, float4(center + float2(-xoffs, -yoffs), 0, 0)).y;
+
+	const float m1 = min(texelCenterConv.x, texelCenterConv.y);
+	const float m2 = min(texelCenterConv.z, texelCenterConv.w);
+
+	const float convergence = min(m1, m2);
 	//const float convergence = ao.y;
 
@@ -201,17 +202,13 @@
 	// filter up to a certain convergance value and leave out background (sky) by checking depth
 	if ((convergence < thres) && (col.w < 1e10f))
-	//if (col.w < 1e10f)
 	{
-		//const float eyeSpaceDepth = col.w; const float distanceScaleWeight = 2.0f;
-		//const float distanceScale = distanceScaleWeight / (eyeSpaceDepth + distanceScaleWeight);
 		const float distanceScale = 1.0f;
 
 		const float convergenceWeight = thres / (SSAO_FILTER_WIDTH - 1.0f);
 		const float convergenceScale = convergenceWeight / (convergence + convergenceWeight);
-
 		const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale;
 
 		// the filtered ssao value
-		//ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr);
+		ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr);
 	}
 
@@ -221,7 +218,6 @@
 		OUT.illum_col.xyz = col.xyz;
 
-	//OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1);
-	//const float mydummy = ao.w * 1e-3f;
-	OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x);
+	//OUT.illum_col.xyz = float3(ao.x, ao.x, step(thres, convergence));
+	//OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x);
 	//OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1);
 	//OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1);
@@ -230,2 +226,31 @@
 	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/antialiasing.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg	(revision 3189)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg	(revision 3198)
@@ -47,5 +47,5 @@
 	// weight the influence of normal discontinuities
 	//const float ne = saturate(dot(nd, weights.x));
-	const float ne = nd.x * nd.y *nd.z * nd.w * weights.x;
+	const float ne = nd.x * nd.y * nd.z * nd.w * weights.x;
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 3149)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 3198)
@@ -99,5 +99,5 @@
 	float logLum = logLumScaled * LOGLUM_RANGE + MINLOGLUM;
 
-	float newImageKey = max(exp(logLum), 1e-6f);
+	float newImageKey = max(exp(logLum), 1e-3f);
 
 	// adjust to middle gray
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg	(revision 3195)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg	(revision 3198)
@@ -127,6 +127,6 @@
 	//const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz * 2.0f - float3(1.0f);
 	const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz;
-	pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm);
-	//pix.normal = tangentSpaceNorm;
+	//pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm);
+	pix.normal = normalize(mul(tangToWorldTrafo, tangentSpaceNorm));
 	
 	return pix;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3197)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3198)
@@ -292,6 +292,5 @@
 		float3 dirSample = samplePos - centerPosition;
 
-		const float sqrLen = max(SqrLen(dirSample), 1e-3f);
-		//const float lengthToSample = max(length(dirSample), 1e-2f);
+		const float sqrLen = max(SqrLen(dirSample), 1e-2f);
 		const float lengthToSample = sqrt(sqrLen);
 
@@ -395,4 +394,5 @@
 
 	// cull background note: this should be done with the stencil buffer
+	//if (SqrLen(diffVec < 1e6f) && (eyeSpaceDepth < 1e10f))
 	if (eyeSpaceDepth < 1e10f)
 	{
@@ -402,5 +402,5 @@
 	else
 	{
-		 ao = float3(1.0f, .0f, .0f);
+		 ao = float3(1.0f, 1.0f, 1.0f);
 	}
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3197)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 3198)
@@ -10,4 +10,5 @@
 #include "Light.h"
 #include "ShaderManager.h"
+#include <math.h>
 
 #include <IL/il.h>
@@ -41,4 +42,5 @@
 	assert(ilGetError() == IL_NO_ERROR);
 }
+
 
 namespace CHCDemoEngine
@@ -111,4 +113,15 @@
 		fprintf(stderr,"OpenGL ERROR: %s: %s\n", errStr, msg);
 	}
+}
+
+
+static Sample2 UnitTest2(float x, float y, int wi, int he)
+{
+	Sample2 s;
+
+	s.x = float(floor(x * (float)wi - 0.5f) + 1.0f) / (float)wi;
+	s.y = float(floor(y * (float)he - 0.5f) + 1.0f) / (float)he;
+
+	return s;
 }
 
@@ -309,20 +322,10 @@
 
 	///////////////
-	//-- the downsampled ssao + color bleeding textures: as gi is inherently low frequency, we can use these to improve 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);
-	//mDownSampleFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
 	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_LINEAR);
-	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST);
-	// downsample buffer for the offset texture
-	//mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR);
-	mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST);
-
-	for (int i = 0; i < 3; ++ i)
-	{
-		FrameBufferObject::InitBuffer(mDownSampleFbo, i);
-	}
+
+	FrameBufferObject::InitBuffer(mDownSampleFbo, 0);
 
 	mFBOs.push_back(mDownSampleFbo);
@@ -343,4 +346,13 @@
 
 	InitCg();
+
+	float x = 400.5f / w;
+	float y = 100.5f / h;
+	
+	Sample2 res = UnitTest2(x, y, dsw, dsh);
+
+	cout << "input  : " << x << ", " << y << endl;
+	cout << "result : " << res.x << " " << res.y << endl;
+	cout << "result2: " << res.x * w << " " << res.y * h << endl;
 }
 
@@ -447,9 +459,9 @@
 	
 	string prepareSsaoParams[] = 
-		{"colorsTex", "normalsTex", "diffVals", "oldTex", 
+		{"colorsTex", "diffVals", "oldTex", 
 		 "oldEyePos", "modelViewProj", "oldModelViewProj",
 		 "oldbl", "oldbr", "oldtl", "oldtr"};
 
-	sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 11);
+	sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 10);
 
 
@@ -634,16 +646,10 @@
 
 	if (0)
-	{
 		colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();
-		normalsTex = fbo->GetColorBuffer(1)->GetTexture();
-		attribsTex = fbo->GetColorBuffer(2)->GetTexture();
-	}
 	else
-	{
 		colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture();
-		normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture();
-		attribsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture();
-		//attribsTex = fbo->GetColorBuffer(2)->GetTexture();
-	}
+	
+	normalsTex = fbo->GetColorBuffer(1)->GetTexture();
+	attribsTex = fbo->GetColorBuffer(2)->GetTexture();
 
 	// flip flop between illumination buffers
@@ -1017,17 +1023,12 @@
 void DeferredRenderer::PrepareSsao(FrameBufferObject *fbo)
 {
-	GLuint colorsTex, normalsTex, diffVals, oldTex;
-
-	colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();
-	normalsTex = fbo->GetColorBuffer(1)->GetTexture();
-	diffVals = fbo->GetColorBuffer(2)->GetTexture();
-
+	GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();
+	GLuint diffVals = fbo->GetColorBuffer(2)->GetTexture();
 	// flip flop between illumination buffers
-	oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture();
+	GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture();
 
 	int i = 0;
 
 	sCgPrepareSsaoProgram->SetTexture(i ++, colorsTex);
-	sCgPrepareSsaoProgram->SetTexture(i ++, normalsTex);
 	sCgPrepareSsaoProgram->SetTexture(i ++, diffVals);
 	sCgPrepareSsaoProgram->SetTexture(i ++, oldTex);
@@ -1051,5 +1052,5 @@
 	mDownSampleFbo->Bind();
 
-	glDrawBuffers(3, mrt + 0);
+	glDrawBuffers(1, mrt);
 
 	DrawQuad(sCgPrepareSsaoProgram);
@@ -1189,4 +1190,3 @@
 }
 
-
 } // namespace
