Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg	(revision 2982)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg	(revision 3005)
@@ -31,5 +31,5 @@
 {
   float4 col: COLOR0;
-  float4 pos: COLOR1;
+  float3 pos: COLOR1;
   float4 norm: COLOR2;
 };
@@ -112,13 +112,11 @@
 
 	pix.col = IN.color2;
-	pix.pos = 1e20f;
+	pix.col.w = 2.0f;
 
 	pix.norm.xyz = IN.normal;
+	pix.norm.w = IN.mypos.w;
+
+	pix.pos = 1e20f;
 	
-	pix.norm.w = IN.mypos.w;
-	pix.pos.w = 1e20f;
-	
-	pix.col.w = 2.0f;
-
 	return pix;
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2992)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 3005)
@@ -48,10 +48,10 @@
 	float4 outColor;
 
-	if (position.w > 1e19f) outColor = color;
+	// hack: prevent shading the sky
+	if (position.z > 1e19f) outColor = color;
 	//if (emmisive > 1.5f) outColor = color;
 	else outColor = (ambient + diffuse) * color;
 
 	return outColor;
-	//return saturate((((ambient + diffuse)) * (1.0f - emmisive) + emmisive) * color);
 }
 
@@ -188,6 +188,5 @@
 	// calc diffuse illumination + shadow term
 	//if ((emmisive < 1.5f) // hack: prevent shadowing the sky	
-	if (
-		(position.w < 1e19f)
+	if ((position.z < 1e19f)
 		&& (angle > 1e-3f) // shadow only if diffuse color has some minimum intensity
 		)
@@ -209,5 +208,5 @@
 	// base lighting
 	//OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color;
-	OUT.color = (position.w > 1e19f) ? color: (ambient + diffuse) * color;
+	OUT.color = (position.z > 1e19f) ? color: (ambient + diffuse) * color;
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 3004)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 3005)
@@ -37,8 +37,8 @@
 struct pixel
 {
-  float4 col: COLOR0;
-  //float4 pos: COLOR1;
-  float4 pos: COLOR1;
-  float4 norm: COLOR2;
+	float4 col: COLOR0;
+	//float4 pos: COLOR1;
+	float3 pos: COLOR1;
+	float4 norm: COLOR2;
 };
 
@@ -113,8 +113,8 @@
 	pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth / magView;
 
+#if 1
 	// save world position in second render target
-	pix.pos = IN.worldPos * maxDepth;
-	// store the projected depth
-	pix.pos.w = projPos.z;
+	pix.pos = IN.worldPos.xyz * maxDepth;
+#endif
 
 	return pix;
@@ -150,7 +150,7 @@
 	pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth / magView;
 
-	pix.pos = IN.worldPos * maxDepth;
-	// store the projected depth
-	pix.pos.w = projPos.z;
+#if 1
+	pix.pos = IN.worldPos.xyz * maxDepth;
+#endif
 
 	return pix;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 3003)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg	(revision 3005)
@@ -22,5 +22,5 @@
 float4 DownSample(frag IN,
 				  uniform sampler2D colors,
-				  float2 downSampleOffs[4]) : COLOR
+				  uniform float2 downSampleOffs[4]): COLOR
 {    
     float4 average = .0f;
@@ -130,5 +130,5 @@
 	float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset;
 
-	if (oldLogLum > 1e-5f) // too hight log lum
+	if (oldLogLum > 1e-5f) // too bright
 		OUT.col.w = lerp(oldLogLum, logLumScaled, 0.1f);
 	else
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3004)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg	(revision 3005)
@@ -170,24 +170,30 @@
 
 
-	// the current world position
-	const float4 centerPosition = tex2D(positions, IN.texCoord.xy);
-
 #if USE_EYE_SPACE_DEPTH
 	/// reconstruct position from the eye space depth
 	float3 viewDir = IN.view;
 	const float eyeDepth = tex2D(colors, IN.texCoord.xy).w;
-	float4 centerPosition2;
-
-	centerPosition2.xyz = eyePos - viewDir * eyeDepth;
-	centerPosition2.w = centerPosition.w;
-
-	const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition2, w, eyePos, bl, br, tl, tr);
+
+	float4 centerPosition;
+	centerPosition.xyz = eyePos - viewDir * eyeDepth;
+	centerPosition.w = centerPosition.w;
+
+	const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr);
 #else
 
+	// the current world position
+	const float4 centerPosition = tex2D(positions, IN.texCoord.xy);
+
 	const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr);
 
 #endif
 
-	// get the current depth
+	/////////////////
+	//-- compute temporally smoothing
+
+	float4 realPos = centerPosition * maxDepth;
+	realPos.w = 1.0f;
+
+	// calulcate the current depth
 	//const float currentDepth = centerPosition.w;
 	
@@ -198,11 +204,4 @@
 	
 
-	/////////////////
-	//-- compute temporally smoothing
-
-	float4 realPos = centerPosition * maxDepth;
-	realPos.w = 1.0f;
-
-
 	///////////
 	//-- reprojection new frame into old one 
@@ -210,5 +209,5 @@
 	// calculate projected depth
 	float4 projPos = mul(oldModelViewProj, realPos);
-	projPos /= oldPos.w;
+	projPos /= projPos.w;
 
 	// the current depth projected into the old frame
