Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2870)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 2871)
@@ -27,5 +27,6 @@
 struct pixel
 {
-	float4 color: COLOR0;
+	float4 illum_col: COLOR0;
+	float4 combined_col: COLOR1;
 };
 
@@ -33,14 +34,13 @@
 float2 reflect(float2 pt, float2 n)
 {
-  // distance to plane
-  float d = dot(n, pt);
-  // reflect around plane
-  float2 rpt = pt - d * 2.0f * n;
-
-  return rpt;
-}
-
-
-float2 rotate(float2 pt, float2 n)
+	// distance to plane
+	float d = dot(n, pt);
+	// reflect around plane
+	float2 rpt = pt - d * 2.0f * n;
+	return rpt;
+}
+
+
+/*float2 rotate(float2 pt, float2 n)
 {
 	float2 ptTransformed;
@@ -49,5 +49,5 @@
 
 	return ptTransformed;
-}
+}*/
 
 
@@ -121,4 +121,5 @@
 /** Computes ambient occlusion + diffuse reflections
 */
+/*
 float4 globIllum(fragment IN,
 				 uniform sampler2D colors,
@@ -149,5 +150,5 @@
 
 		//sample noisetex; r stores costheta, g stores sintheta
-		float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;
+		float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy;
 
 		// rotation
@@ -157,6 +158,6 @@
 		float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w;
 
-		float3 sample_position = tex2D(positions, texcoord).xyz;
-		float3 sample_color = tex2D(colors, texcoord).xyz;
+		float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz;
+		float3 sample_color = tex2D(colors, float4(texcoord, 0, 1)).xyz;
 
 		float3 vector_to_sample = sample_position - centerPosition.xyz;
@@ -176,10 +177,11 @@
 
 		total_ao += cos_angle * distance_intensity * view_correction;
-		total_color += cos_angle * distance_intensity * view_correction * sample_color * 0.3f;
+		float scale_factor = 0.3f;
+		total_color += cos_angle * distance_intensity * view_correction * sample_color * scale_factor;
 	}
 
 	return float4(total_color, 1.0f - total_ao);
 }
-
+*/
 
 /** The mrt shader for screen space ambient occlusion
@@ -200,26 +202,28 @@
 	pixel OUT;
 
-	float4 normal = tex2D(normals, IN.texCoord.xy);
+	float4 norm = tex2D(normals, IN.texCoord.xy);
 	
 	// the ambient term
-	float amb = normal.w;
+	const float amb = norm.w;
 
 	// expand normal
-	normal = normalize(normal);// * 2.0f - 1.0f);
+	float3 normal = normalize(norm.xyz);// * 2.0f - 1.0f);
 	/// the current view direction
 	float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f));
 
 	// the current world position
-	float4 centerPosition = tex2D(positions, IN.texCoord.xy);
+	const float4 centerPosition = tex2D(positions, IN.texCoord.xy);
 	
 	// the current color
-	float4 currentCol = tex2D(colors, IN.texCoord.xy);
-	float currentDepth = currentCol.w;
-
-	float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition);
-
-	//float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 
+	const float4 currentCol = tex2D(colors, IN.texCoord.xy);
+	const float currentDepth = currentCol.w;
+
+	float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);
+	//float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 
 	
-	// compute temporally smoothed color
+
+	/////////////////
+	//-- compute temporally smoothed value
+
 	float4 realPos = centerPosition * maxDepth;
 	realPos.w = 1.0f;
@@ -227,11 +231,11 @@
 	float4 oldPos = mul(oldModelViewProj, realPos);
 
-	float newDepth = oldPos.z / oldPos.w;
+	const float newDepth = oldPos.z / oldPos.w;
 
 	float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f;
 	float4 oldCol = tex2D(oldTex, tex);
 
-	float oldDepth = oldCol.w;
-	float depthDif = 1.0f - newDepth / oldDepth;
+	const float oldDepth = oldCol.w;
+	const float depthDif = 1.0f - newDepth / oldDepth;
 
 	if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 
@@ -239,21 +243,20 @@
 		(abs(depthDif)  < 1e-4f))
 	{
-		OUT.color = float4(ao * expFactor + oldCol * float4(1.0f - expFactor));
+		OUT.illum_col = new_col * expFactor + oldCol * float4(1.0f - expFactor);
 	}
 	else
 	{
-		OUT.color = (float4)ao;
-	}
-
-
-	//OUT.color.xyz = viewDir;
-	//OUT.color = attenuated_color;
-	
-	OUT.color.w = currentDepth;
+		OUT.illum_col = new_col;
+	}
+
+
+	OUT.combined_col = currentCol * OUT.illum_col;
+
+	OUT.illum_col.w = currentDepth;
 
 	return OUT;
 }
 
-
+/*
 pixel combined(fragment IN, 
 			   uniform sampler2D colors,
@@ -265,8 +268,8 @@
 	float4 col = tex2D(colors, IN.texCoord.xy);
 	float4 ao = tex2D(ssaoTex, IN.texCoord.xy);
-
-	OUT.color = float4(1,0,0,0);
-	OUT.color = col * ao;
+	//float4 illum = tex2D(ssaoTex, IN.texCoord.xy);
+
+	OUT.illum_col = col * ao;
 
 	return OUT;
-}
+}*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp	(revision 2869)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp	(revision 2871)
@@ -87,7 +87,9 @@
 	// the diffuse color buffer
 	mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);
+	mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);
 	
 	mOldFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);
 	// the diffuse color buffer
+	mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);
 	mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);
 	
@@ -140,5 +142,5 @@
 
 
-	sCgCombineProgram = 
+	/*sCgCombineProgram = 
 		cgCreateProgramFromFile(context, 
 								CG_SOURCE,
@@ -158,5 +160,5 @@
 	else
 		cerr << "combined program failed to load" << endl;
-
+*/
 
 	///////////////
@@ -257,5 +259,5 @@
 	FirstPass(fbo);
 	ComputeSsao(fbo, expFactor);
-	Combine(fbo);
+	//Combine(fbo);
 	AntiAliasing(fbo);
 
@@ -291,5 +293,5 @@
 	// read the second buffer, write to the first buffer
 	mNewFbo->Bind();
-	glDrawBuffers(1, mymrt);
+	glDrawBuffers(2, mymrt);
 
 	GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture();
@@ -443,6 +445,6 @@
 void SsaoShader::AntiAliasing(FrameBufferObject *fbo)
 {
-	GLuint colorsTex = mFbo4->GetColorBuffer(0)->GetTexture();
-	//GLuint colorsTex = mNewFbo->GetColorBuffer(0)->GetTexture();
+	//GLuint colorsTex = mFbo4->GetColorBuffer(0)->GetTexture();
+	GLuint colorsTex = mNewFbo->GetColorBuffer(1)->GetTexture();
 	GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture();
 	
