Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2982)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg	(revision 2984)
@@ -48,6 +48,6 @@
 	float4 outColor;
 
-	//if (color.w > 1e19f) outColor = color;
-	if (emmisive > 1.5f) outColor = color;
+	if (position.w > 1e19f) outColor = color;
+	//if (emmisive > 1.5f) outColor = color;
 	else outColor = (ambient + diffuse) * color;
 
@@ -181,5 +181,7 @@
 
 	// calc diffuse illumination + shadow term
-	if ((emmisive < 1.5f) // hack: prevent shadowing the sky	
+	//if ((emmisive < 1.5f) // hack: prevent shadowing the sky	
+	if (
+		(position.w > 1e19f)
 		&& (angle > 1e-3f) // shadow only if diffuse color has some minimum intensity
 		)
@@ -200,5 +202,6 @@
 	
 	// base lighting
-	OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color;
+	//OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color;
+	OUT.color = (position.w > 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 2982)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 2984)
@@ -68,5 +68,6 @@
 			  uniform sampler2D dirtTex,
 			  uniform float maxDepth,
-			  uniform sampler2D tex)
+			  uniform sampler2D tex,
+			  uniform float3 currentPos)
 {
 	pixel pix;
@@ -93,6 +94,6 @@
 
 	// hack: squeeze some information about ambient into the texture
-	pix.col.w = glstate.material.emission.x;
-	//pix.col.w = length(currentPos - IN.worldPos)
+	//pix.col.w = glstate.material.emission.x;
+	pix.col.w = length(currentPos - IN.worldPos);
 
 	return pix;
@@ -100,6 +101,5 @@
 
 
-pixel frag(fragin IN, 
-		   uniform float maxDepth)
+pixel frag(fragin IN, uniform float maxDepth, uniform float3 currentPos)
 {
 	pixel pix;
@@ -117,5 +117,6 @@
 	
 	// hack: squeeze some information about the ambient term into the target
-	pix.col.w = glstate.material.emission.x;
+	//pix.col.w = glstate.material.emission.x;
+	pix.col.w = length(currentPos - IN.worldPos);
 
 	return pix;
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2983)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2984)
@@ -272,4 +272,6 @@
 static CGparameter sMaxDepthParam;
 static CGparameter sMaxDepthParamTex;
+static CGparameter sCurrentPosParamTex;
+static CGparameter sCurrentPosParam;
 
 static Matrix4x4 oldViewProjMatrix;
@@ -591,4 +593,5 @@
 
 		sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth");
+		sCurrentPosParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "currentPos");
 		RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex");
 	
@@ -611,4 +614,5 @@
 
 		sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth");
+		sCurrentPosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "currentPos");
 		
 		cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist);
@@ -943,4 +947,8 @@
 	cgGLBindProgram(RenderState::sCgMrtFragmentProgram);
 
+	Vector3 pos = camera->GetPosition();
+	cgGLSetParameter3f(sCurrentPosParam, pos.x, pos.y, pos.z);
+	cgGLSetParameter3f(sCurrentPosParamTex, pos.x, pos.y, pos.z);
+
 	// draw to 3 color buffers
 	// a color, normal, and positions buffer
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2978)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp	(revision 2984)
@@ -582,5 +582,5 @@
 
 	float imageKey, whiteLum, middleGrey;
-
+/*
 	glPixelStorei(GL_PACK_ALIGNMENT, 1);
 	// generate mip map levels for average loglum and tone mapping 
@@ -590,5 +590,5 @@
 	ComputeToneParameters(fbo, light, imageKey, whiteLum, middleGrey);
 	ToneMap(fbo, light, imageKey, whiteLum, middleGrey);
-
+*/
 	AntiAliasing(fbo, light);
 
