Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2810)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2811)
@@ -89,5 +89,5 @@
 
 static int winWidth = 1024;
-static int winHeight = 768;
+static int winHeight = 1024;
 static float winAspectRatio = 1.0f;
 
@@ -98,6 +98,6 @@
 
 // rendertexture
-const static int texWidth = 2048;
-const static int texHeight = 2048;
+const static int texWidth = 1024;
+const static int texHeight = 1024;
 
 int renderedObjects = 0;
@@ -331,5 +331,5 @@
 	//bvh = bvhLoader.Load("data/city/model/city.bvh", sceneEntities);
 
-	myfar = 10.0f * Magnitude(bvh->GetBox().Diagonal());
+	myfar = 1.0f * Magnitude(bvh->GetBox().Diagonal());
 
 	if (!bvh)
@@ -550,5 +550,5 @@
 	glGenRenderbuffersEXT(1, &normalsBuffer);
 	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, normalsBuffer);
-	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, texWidth, texHeight);
+	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight);
 	
 	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_RENDERBUFFER_EXT, normalsBuffer);
@@ -556,5 +556,5 @@
 	glGenTextures(1, &normalsTex);
 	glBindTexture(GL_TEXTURE_2D, normalsTex);
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL);
 	glGenerateMipmapEXT(GL_TEXTURE_2D);
 	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, normalsTex, 0);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2810)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2811)
@@ -57,6 +57,7 @@
 
   // the normal on the current position
-  float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz * 2.0f - 1.0f;
-
+  float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz;
+  normalize(centerNormal);
+  
   // Check in a circular area around the current position.
   // Shoot vectors to the positions there, and check the angle to these positions.
@@ -66,6 +67,6 @@
 
   //const float areaSize = 4.0f;  
-  const float areaSize = 5e-3f;
-  const float sampleIntensity = 0.1;
+  const float areaSize = 4e-3f;
+  const float sampleIntensity = 0.1f;
   
   for (int i = 0; i < SAMPLES; i ++) {
@@ -75,4 +76,5 @@
     float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f;
 
+    //    float2 offsetTransformed = offset;
     float2 offsetTransformed;
     offsetTransformed.x = noise.r*offset.x - noise.g*offset.y;
@@ -84,6 +86,7 @@
     
     float3 vector_to_sample = sample_position - centerPosition;
+    // vector_to_sample.z = -vector_to_sample.z;
     float length_to_sample = length(vector_to_sample);
-    float3 direction_to_sample = vector_to_sample / length_to_sample;
+    float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f);
     
     // Angle between current normal and direction to sample controls AO intensity.
@@ -92,7 +95,8 @@
     
     // distance between current position and sample position controls AO intensity.
-    const float scale = 5e-1f;
+    const float maxdist = 5e-1f;
+    //const float scale = 50.0f;
 
-    float distance_intensity = scale * (1.0f - length_to_sample);
+    float distance_intensity = maxdist - length_to_sample;
     distance_intensity = max(distance_intensity, 0.0f);
     
@@ -112,5 +116,6 @@
 {
   pixel OUT;
-  float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f);
+  //float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f);
+float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f);
   
   float4 color = tex2D(colors, IN.texCoord.xy);
@@ -121,5 +126,5 @@
   float4 position = tex2D(positions, IN.texCoord.xy);
 
-  float4 ambient = float4(0.3f);
+  float4 ambient = float4(0.1f);
 
   // float3 L = normalize(lightPosition - position);
@@ -132,5 +137,8 @@
   OUT.color = ao; //(ambient + diffuse) * color;
   //OUT.color = (ambient + diffuse) * color;
+  
   //float4 currentPos = tex2D(positions, IN.texCoord.xy);
+  //OUT.color = currentPos;
+  //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f;
   //OUT.color = currentPos;
   
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2810)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2811)
@@ -16,5 +16,5 @@
   float4 color: COLOR0;  
   float4 worldPos: TEXCOORD1; // world position
-  float3 norm: TEXCOORD2;
+  float3 normal: TEXCOORD2;
 };
 
@@ -29,5 +29,5 @@
   float4 color: COLOR0;  
   float4 worldPos: TEXCOORD1; // world position
-  float3 norm: TEXCOORD2;
+  float3 normal: TEXCOORD2;
 };
 
@@ -54,5 +54,5 @@
    // eye pos with linear depth
    //OUT.worldPos = OUT.position;
-   OUT.norm = IN.normal;
+   OUT.normal = IN.normal;
 
    return OUT;
@@ -66,5 +66,5 @@
   pix.col = tex2D(tex, IN.texCoord.xy);
   pix.pos = IN.worldPos * maxDepth;
-  pix.norm = IN.norm * 0.5f + 0.5f;
+  pix.norm = IN.normal;
 
   return pix;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2811)
@@ -171,5 +171,16 @@
 	}
 	else
+	{
 		texcoords = NULL;
+	}
+
+	for (int i = 0; i < vertexCount; i += 3)
+	{
+		Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]);
+		Vector3 n = tri.GetNormal();
+		normals[i + 0] = n;
+		normals[i + 1] = n;
+		normals[i + 2] = n;
+	}
 
 	return new Geometry(vertices, normals, texcoords, vertexCount, true);
