Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2950)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2955)
@@ -23,5 +23,6 @@
 mMode(RENDER),
 mRenderType(FIXED),
-mUseAlphaToCoverage(true)
+mUseAlphaToCoverage(true),
+mLockCullFaceEnabled(false)
 {
 	Reset(); 
@@ -82,15 +83,17 @@
 void RenderState::SetState(bool texturing, bool alphaTest, bool cullFace)
 {
-	if (mCullFaceEnabled && !cullFace) 
+	if (!mLockCullFaceEnabled)
 	{
-		mCullFaceEnabled = false;
-		glDisable(GL_CULL_FACE);
+		if (mCullFaceEnabled && !cullFace) 
+		{
+			mCullFaceEnabled = false;
+			glDisable(GL_CULL_FACE);
+		}
+		else if (!mCullFaceEnabled && cullFace)
+		{
+			mCullFaceEnabled = true;
+			glEnable(GL_CULL_FACE);
+		}
 	}
-	else if (!mCullFaceEnabled && cullFace)
-	{
-		mCullFaceEnabled = true;
-		glEnable(GL_CULL_FACE);
-	}
-
 	if (mAlphaTestEnabled && !alphaTest) 
 	{
@@ -144,5 +147,17 @@
 	mCurrentVboId = -1;
 
-	SetState(false, false, true);
+	mCullFaceEnabled = true;
+	glEnable(GL_CULL_FACE);
+	
+	mAlphaTestEnabled = false;
+	
+	glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
+	glDisable(GL_ALPHA_TEST);
+
+	mTexturesEnabled = false;
+
+	glDisable(GL_TEXTURE_2D);
+	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
 	SetState(RENDER);
 }
@@ -155,3 +170,21 @@
 
 
+void RenderState::SetRenderPassType(RenderPassType t) 
+{ 
+	mRenderType = t; 
 }
+
+
+RenderState::RenderPassType RenderState::GetRenderPassType() const 
+{
+	return mRenderType; 
+}
+
+
+void RenderState::LockCullFaceEnabled(bool lockCull)
+{ 
+	mLockCullFaceEnabled =  lockCull; 
+}
+
+
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp	(revision 2955)
@@ -197,5 +197,5 @@
 	for (int i = 0; i < mNumSamples; ++ i)
 	{
-		Sample2 spl = s[i];
+		Sample2 &spl = s[i];
 
 		float len = sqrt(spl.x * spl.x + spl.y * spl.y);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 2955)
@@ -1,7 +1,21 @@
 #include "SkyPreetham.h"
+#include "common.h"
+#include "Vector3.h"
+
+
 //#include <rendering/effect/FEffect.h>
 //#include <rendering/FVertexbuffer.h>
 
 
+inline float CBQ(float x)
+{
+	return x * x * x;
+}
+
+
+inline float SQR(float x)
+{
+	return x * x ;
+}
 
 
@@ -9,12 +23,12 @@
 
 
-SkyPreetham::SkyPreetham():
-	mEffect(NULL),
-	mTurbidity(4.0),
-	mSunEffect(NULL),
-	mSunTexture(NULL),
-	mSunQuad(NULL)
+SkyPreetham::SkyPreetham(float turbitity):
+//	mEffect(NULL),
+	mTurbidity(turbitity)
+//	mSunEffect(NULL),
+//	mSunTexture(NULL),
+//	mSunQuad(NULL)
 {
-	mEffect = D().getScene().getEffect("../effects/sky_preetham.fx");
+/*	mEffect = D().getScene().getEffect("../effects/sky_preetham.fx");
 
 	mVertexBuffer = D().getScene().getVertexBuffer("../models/sky.vbo");
@@ -22,6 +36,6 @@
 	mSunEffect = D().getScene().getEffect("../effects/sky_sun.fx");
 	mSunTexture = D().getScene().getTexture2D("../textures/sky_sun.png");
-
-	createSunQuad();
+*/
+	CreateSunQuad();
 }
 
@@ -29,44 +43,31 @@
 SkyPreetham::~SkyPreetham()
 {
-	FDelete(mSunQuad);
+	//DEL_PTR(mSunQuad);
 }
 
 
 
-void SkyPreetham::Compute()
+void SkyPreetham::Compute(const Vector3 &sunDir)
 {
+	float sun_theta[2];
 
-	FVector2 sun_theta;
-	FVector3 l_dir = D().getScene().getLight().getDirection();
-	mTurbidity = D().getScene().getLight().getTurbitity();
+	sun_theta[0] = acos(sunDir.y);
 
-	sun_theta.x = acos(l_dir.y);
-	sun_theta.y = cos( sun_theta.x ) * cos( sun_theta.x );
+	const float cos_theta =  cos(sun_theta[0]);
+	sun_theta[1] = cos_theta * cos_theta;
 
+	Vector3 zenithColor;
 
-#define CBQ(X)		((X) * (X) * (X))
-#define SQR(X)		((X) * (X))
+	zenithColor.x = ( 0.00165f * CBQ(sun_theta[0]) - 0.00374f * SQR(sun_theta[0]) + 0.00208f * sun_theta[0] + 0.0f)     * SQR(mTurbidity) +	
+				    (-0.02902f * CBQ(sun_theta[0]) + 0.06377f * SQR(sun_theta[0]) - 0.03202f * sun_theta[0] + 0.00394f) * mTurbidity +
+					( 0.11693f * CBQ(sun_theta[0]) - 0.21196f * SQR(sun_theta[0]) + 0.06052f * sun_theta[0] + 0.25885f);
 
-	const double PI = (double)3.1415926535897932;
+	zenithColor.y = (0.00275f  * CBQ(sun_theta[0]) - 0.00610f * SQR(sun_theta[0]) + 0.00316f * sun_theta[0] + 0.0f)     * SQR(mTurbidity) +
+	                (-0.04214f * CBQ(sun_theta[0]) + 0.08970f * SQR(sun_theta[0]) - 0.04153f * sun_theta[0] + 0.00515f) * mTurbidity +
+		            ( 0.15346f * CBQ(sun_theta[0]) - 0.26756f * SQR(sun_theta[0]) + 0.06669f * sun_theta[0] + 0.26688f);
+	
+	zenithColor.z  = (float)((4.0453f * mTurbidity - 4.9710f) *	tan((4.0f / 9.0f - mTurbidity / 120.0f) * 
+							 (M_PI - 2.0f * sun_theta[0])) - 0.2155f * mTurbidity + 2.4192f);
 
-	FVector3 zenithColor;
-
-	zenithColor.x  = ( 0.00165f * CBQ(sun_theta.x) - 0.00374f  * SQR(sun_theta.x) +
-		0.00208f *       sun_theta.x  +     0.0f) * SQR(mTurbidity) +
-		(-0.02902f * CBQ(sun_theta.x) + 0.06377f  * SQR(sun_theta.x) -
-		0.03202f *       sun_theta.x  + 0.00394f) *        mTurbidity +
-		( 0.11693f * CBQ(sun_theta.x) - 0.21196f  * SQR(sun_theta.x) +
-		0.06052f *       sun_theta.x + 0.25885f);
-
-	zenithColor.y  = ( 0.00275f * CBQ(sun_theta.x) - 0.00610f  * SQR(sun_theta.x) +
-		0.00316f *       sun_theta.x +     0.0f) * SQR(mTurbidity) +
-		(-0.04214f * CBQ(sun_theta.x) + 0.08970f  * SQR(sun_theta.x) -
-		0.04153f *       sun_theta.x  + 0.00515f) *        mTurbidity  +
-		( 0.15346f * CBQ(sun_theta.x) - 0.26756f  * SQR(sun_theta.x) +
-		0.06669f *       sun_theta.x  + 0.26688f);
-
-	zenithColor.z  = (float)((4.0453f * mTurbidity - 4.9710f) *
-		tan((4.0f / 9.0f - mTurbidity / 120.0f) * (PI - 2.0f * sun_theta.x)) -
-		0.2155f * mTurbidity + 2.4192f);
 	// convert kcd/m² to cd/m²
 	zenithColor.z *= 1000;
@@ -74,23 +75,23 @@
 	double ABCDE_x[5], ABCDE_y[5], ABCDE_Y[5];
 
-	ABCDE_x[0] = -0.01925 * mTurbidity   - 0.25922;
-	ABCDE_x[1] = -0.06651 * mTurbidity   + 0.00081;
-	ABCDE_x[2] = -0.00041 * mTurbidity   + 0.21247;
-	ABCDE_x[3] = -0.06409 * mTurbidity   - 0.89887;
-	ABCDE_x[4] = -0.00325 * mTurbidity   + 0.04517;
+	ABCDE_x[0] = -0.01925 * mTurbidity - 0.25922;
+	ABCDE_x[1] = -0.06651 * mTurbidity + 0.00081;
+	ABCDE_x[2] = -0.00041 * mTurbidity + 0.21247;
+	ABCDE_x[3] = -0.06409 * mTurbidity - 0.89887;
+	ABCDE_x[4] = -0.00325 * mTurbidity + 0.04517;
 
-	ABCDE_y[0] = -0.01669 * mTurbidity  - 0.26078;
-	ABCDE_y[1] = -0.09495 * mTurbidity   + 0.00921;
-	ABCDE_y[2] = -0.00792 * mTurbidity   + 0.21023;
-	ABCDE_y[3] = -0.04405 * mTurbidity   - 1.65369;
-	ABCDE_y[4] = -0.01092 * mTurbidity   + 0.05291;
+	ABCDE_y[0] = -0.01669 * mTurbidity - 0.26078;
+	ABCDE_y[1] = -0.09495 * mTurbidity + 0.00921;
+	ABCDE_y[2] = -0.00792 * mTurbidity + 0.21023;
+	ABCDE_y[3] = -0.04405 * mTurbidity - 1.65369;
+	ABCDE_y[4] = -0.01092 * mTurbidity + 0.05291;
 
-	ABCDE_Y[0] =  0.17872 * mTurbidity   - 1.46303;
-	ABCDE_Y[1] = -0.35540 * mTurbidity   + 0.42749;
-	ABCDE_Y[2] = -0.02266 * mTurbidity   + 5.32505;
-	ABCDE_Y[3] =  0.12064 * mTurbidity   - 2.57705;
-	ABCDE_Y[4] = -0.06696 * mTurbidity   + 0.37027;
+	ABCDE_Y[0] =  0.17872 * mTurbidity - 1.46303;
+	ABCDE_Y[1] = -0.35540 * mTurbidity + 0.42749;
+	ABCDE_Y[2] = -0.02266 * mTurbidity + 5.32505;
+	ABCDE_Y[3] =  0.12064 * mTurbidity - 2.57705;
+	ABCDE_Y[4] = -0.06696 * mTurbidity + 0.37027;
 
-
+/*
 	F().getRenderDevice().setDefaultDepthStencilMode(FRenderDevice::DEPTHSTENCIL_TEST_NO_OVERWRITE);
 
@@ -126,9 +127,11 @@
 
 	F().getRenderDevice().setDefaultDepthStencilMode(FRenderDevice::DEPTHSTENCIL_TEST_AND_OVERWRITE);
+	*/
 }
 
 
-void SkyPreetham::renderSunDisk()
+void SkyPreetham::RenderSunDisk()
 {
+	/*
 	F().getRenderDevice().setDefaultBlendingMode(FRenderDevice::BLENDING_ADDITIVE);
 
@@ -154,9 +157,11 @@
 
 	F().getRenderDevice().setDefaultBlendingMode(FRenderDevice::BLENDING_NONE);
+	*/
 }
 
 
-void SkyPreetham::createSunQuad()
+void SkyPreetham::CreateSunQuad()
 {
+	/*
 	mSunQuad = new FVertexBuffer();
 	mSunQuad->setupPrimitiveType(FVertexBuffer::PRIMITIVES_TRIANGLES);
@@ -180,3 +185,4 @@
 	mSunQuad->setIndex(4, 1);
 	mSunQuad->setIndex(5, 3);
+	*/
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.cpp	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.cpp	(revision 2955)
@@ -71,21 +71,21 @@
 	float ABCDE_x[5], ABCDE_y[5], ABCDE_Y[5];
 
-	ABCDE_x[0] = -0.01925f * turbidity   - 0.25922f;
-	ABCDE_x[1] = -0.06651f * turbidity   + 0.00081f;
-	ABCDE_x[2] = -0.00041f * turbidity   + 0.21247f;
-	ABCDE_x[3] = -0.06409f * turbidity   - 0.89887f;
-	ABCDE_x[4] = -0.00325f * turbidity   + 0.04517f;
+	ABCDE_x[0] = -0.01925f * turbidity - 0.25922f;
+	ABCDE_x[1] = -0.06651f * turbidity + 0.00081f;
+	ABCDE_x[2] = -0.00041f * turbidity + 0.21247f;
+	ABCDE_x[3] = -0.06409f * turbidity - 0.89887f;
+	ABCDE_x[4] = -0.00325f * turbidity + 0.04517f;
 
-	ABCDE_y[0] = -0.01669f * turbidity  - 0.26078f;
-	ABCDE_y[1] = -0.09495f * turbidity   + 0.00921f;
-	ABCDE_y[2] = -0.00792f * turbidity   + 0.21023f;
-	ABCDE_y[3] = -0.04405f * turbidity   - 1.65369f;
-	ABCDE_y[4] = -0.01092f * turbidity   + 0.05291f;
+	ABCDE_y[0] = -0.01669f * turbidity - 0.26078f;
+	ABCDE_y[1] = -0.09495f * turbidity + 0.00921f;
+	ABCDE_y[2] = -0.00792f * turbidity + 0.21023f;
+	ABCDE_y[3] = -0.04405f * turbidity - 1.65369f;
+	ABCDE_y[4] = -0.01092f * turbidity + 0.05291f;
 
-	ABCDE_Y[0] =  0.17872f * turbidity   - 1.46303f;
-	ABCDE_Y[1] = -0.35540f * turbidity   + 0.42749f;
-	ABCDE_Y[2] = -0.02266f * turbidity   + 5.32505f;
-	ABCDE_Y[3] =  0.12064f * turbidity   - 2.57705f;
-	ABCDE_Y[4] = -0.06696f * turbidity   + 0.37027f;
+	ABCDE_Y[0] =  0.17872f * turbidity - 1.46303f;
+	ABCDE_Y[1] = -0.35540f * turbidity + 0.42749f;
+	ABCDE_Y[2] = -0.02266f * turbidity + 5.32505f;
+	ABCDE_Y[3] =  0.12064f * turbidity - 2.57705f;
+	ABCDE_Y[4] = -0.06696f * turbidity + 0.37027f;
 
 	Vector3 num;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2948)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2955)
@@ -24,11 +24,10 @@
 	};
 
-	enum RenderType
+	/// the used render type for this render pass
+	enum RenderPassType
 	{
 		FIXED,
 		DEPTH_PASS,
-		DEFERRED,
-		DEPTH_PASS_DEFERRED,
-		NUM_RENDER_TYPES
+		DEFERRED
 	};
 
@@ -38,5 +37,4 @@
 	
 	~RenderState() { Reset(); };
-
 	/** This must be called each time before and after an occlusion test.
 		Mode is one of render mode or query mode. Returns true if a state
@@ -62,10 +60,14 @@
 	*/
 	void SetUseAlphaToCoverage(bool useAlphaToCoverage);
-
-	void SetRenderType(RenderType type) { mRenderType = type; }
-	RenderType GetRenderType() const { return mRenderType; }
-
-
-	///////////////////
+	/** Sets the type of rendering used (foreward, depth pass, deferred)
+	*/
+	void SetRenderPassType(RenderPassType t);
+	/** See Set
+	*/
+	RenderPassType GetRenderPassType() const;
+	/** If true, the current value of cull face enabled / disable will
+		not be changed by the render state.
+	*/
+	void LockCullFaceEnabled(bool lockCull);
 
 
@@ -90,7 +92,9 @@
 	int mCurrentVboId;
 
-	RenderType mRenderType;
+	RenderPassType mRenderType;
 
 	bool mUseAlphaToCoverage;
+
+	bool mLockCullFaceEnabled;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2844)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2955)
@@ -74,5 +74,5 @@
 	}
 
-	if (state->GetRenderType() == RenderState::DEFERRED)
+	if (state->GetRenderPassType() == RenderState::DEFERRED)
 	{
 		if (mTexture)
@@ -87,5 +87,5 @@
 		}
 	}
-	else if (state->GetRenderType() == RenderState::FIXED)
+	else if (state->GetRenderPassType() == RenderState::FIXED)
 	{
 		glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 2952)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 2955)
@@ -25,5 +25,5 @@
 	if (!mMatrix) return;
 	
-	if (state->GetRenderType() == RenderState::DEFERRED)
+	if (state->GetRenderPassType() == RenderState::DEFERRED)
 	{
 		cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix->x);
@@ -39,5 +39,5 @@
 	if (!mMatrix) return;
 
-	if (state->GetRenderType() == RenderState::DEFERRED)
+	if (state->GetRenderPassType() == RenderState::DEFERRED)
 	{
 		static Matrix4x4 identity = IdentityMatrix();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h	(revision 2955)
@@ -2,5 +2,10 @@
 #define _SKYPREETHAM_H__
 
-class SkyPreetham: public Entity
+
+namespace CHCDemoEngine{
+class Vector3;
+}
+
+class SkyPreetham
 {
 public:
@@ -9,17 +14,19 @@
 	virtual ~SkyPreetham();
 
+	void Compute(const CHCDemoEngine::Vector3 &sunDir);
+
 protected:
 
-	void renderSunDisk();
-	void createSunQuad();
+	void RenderSunDisk();
+	void CreateSunQuad();
 
 
 	/// Members.
-	FEffect*		mEffect;
+/*	FEffect*		mEffect;
 
 	FEffect*		mSunEffect;
 	FTexture2D*		mSunTexture;
 	FVertexBuffer*	mSunQuad;
-
+*/
 	float mTurbidity;
 };
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2955)
@@ -166,5 +166,16 @@
 PerfTimer frameTimer, algTimer;
 
-int renderType = RenderState::FIXED;
+/// the used render type for this render pass
+enum RenderMethod
+{
+	RENDER_FIXED,
+	RENDER_DEPTH_PASS,
+	RENDER_DEFERRED,
+	RENDER_DEPTH_PASS_DEFERRED,
+	RENDER_NUM_RENDER_TYPES
+};
+
+/// one of four possible render methods
+int renderMethod = RENDER_FIXED;
 
 PerformanceGraph *perfGraph = NULL;
@@ -459,5 +470,5 @@
 	visualization = new Visualization(bvh, camera, NULL, &state);
 	
-	state.SetRenderType(RenderState::FIXED);
+	state.SetRenderPassType(RenderState::FIXED);
 	sceneQuery = new SceneQuery(bvh->GetBox(), traverser);
 
@@ -756,5 +767,5 @@
 	tr->SetUseMultiQueries(useMultiQueries);
 	tr->SetUseTightBounds(useTightBounds);
-	tr->SetUseDepthPass((renderType == RenderState::DEPTH_PASS) || (renderType == RenderState::DEPTH_PASS_DEFERRED));
+	tr->SetUseDepthPass((renderMethod == RENDER_DEPTH_PASS) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED));
 	tr->SetRenderQueue(renderQueue);
 
@@ -840,5 +851,5 @@
 	matProjectionView = matViewing * matProjection;
 	
-	if ((renderType == RenderState::DEFERRED) || (renderType == RenderState::DEPTH_PASS_DEFERRED))
+	if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED))
 	{
 		cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)IdentityMatrix().x);
@@ -878,5 +889,5 @@
 	glDisable(GL_MULTISAMPLE_ARB);
 
-	state.SetRenderType(RenderState::DEFERRED);
+	state.SetRenderPassType(RenderState::DEFERRED);
 
 	cgGLEnableProfile(RenderState::sCgVertexProfile);
@@ -933,8 +944,8 @@
 
 	// hack
-	int oldRenderType = renderType;
+	int oldRenderMethod = renderMethod;
 
 	if (renderLightView)
-		renderType = RenderState::FIXED;
+		renderMethod = RenderState::FIXED;
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -942,11 +953,11 @@
 
 	// render with the specified method (forward rendering, forward + depth, deferred)
-	switch (renderType)
-	{
-	case RenderState::FIXED:
+	switch (renderMethod)
+	{
+	case RENDER_FIXED:
 	
 		glEnable(GL_MULTISAMPLE_ARB);
 		
-		state.SetRenderType(RenderState::FIXED);
+		state.SetRenderPassType(RenderState::FIXED);
 		glEnable(GL_LIGHTING);
 
@@ -960,11 +971,10 @@
 		break;
 
-	case RenderState::DEPTH_PASS_DEFERRED:
+	case RENDER_DEPTH_PASS_DEFERRED:
 
 		glDisable(GL_MULTISAMPLE_ARB);
 		state.SetUseAlphaToCoverage(false);
 
-		state.Reset();
-		state.SetRenderType(RenderState::DEPTH_PASS);
+		state.SetRenderPassType(RenderState::DEPTH_PASS);
 
 		if (!fbo) InitFBO(); fbo->Bind();
@@ -985,5 +995,5 @@
 		break;
 
-	case RenderState::DEPTH_PASS:
+	case RENDER_DEPTH_PASS:
 
 		glEnable(GL_MULTISAMPLE_ARB);
@@ -992,5 +1002,5 @@
 		cgGLDisableProfile(RenderState::sCgVertexProfile);
 
-		state.SetRenderType(RenderState::DEPTH_PASS);
+		state.SetRenderPassType(RenderState::DEPTH_PASS);
 
 		// the scene is rendered withouth any shading	
@@ -1060,6 +1070,6 @@
 	
 	// reset depth pass and render visible objects
-	if ((renderType == RenderState::DEPTH_PASS) ||
-		(renderType == RenderState::DEPTH_PASS_DEFERRED))
+	if ((renderMethod == RENDER_DEPTH_PASS) ||
+		(renderMethod == RENDER_DEPTH_PASS_DEFERRED))
 	{
 		RenderVisibleObjects();
@@ -1078,5 +1088,6 @@
 
 
-	if ((renderType == RenderState::DEFERRED) || (renderType == RenderState::DEPTH_PASS_DEFERRED))
+	if ((renderMethod == RENDER_DEFERRED) ||
+		(renderMethod == RENDER_DEPTH_PASS_DEFERRED))
 	{
 		//glPopAttrib();
@@ -1111,5 +1122,5 @@
 
 
-	state.SetRenderType(RenderState::FIXED);
+	state.SetRenderPassType(RenderState::FIXED);
 	state.Reset();
 
@@ -1118,5 +1129,5 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 	
-	renderType = oldRenderType;
+	renderMethod = oldRenderMethod;
 
 
@@ -1375,6 +1386,10 @@
 	case GLUT_KEY_F7:
 
-		renderType = (renderType + 1) % RenderState::NUM_RENDER_TYPES;
-		traverser->SetUseDepthPass((renderType == RenderState::DEPTH_PASS) || (renderType == RenderState::DEPTH_PASS_DEFERRED));
+		renderMethod = (renderMethod + 1) % 4;
+
+		traverser->SetUseDepthPass(
+			(renderMethod == RENDER_DEPTH_PASS) || 
+			(renderMethod == RENDER_DEPTH_PASS_DEFERRED)
+			);
 		
 		break;
@@ -1850,10 +1865,10 @@
 			int i = 0;
 
-			static char *renderTypeStr[] = {"forward", "depth pass + forward", "deferred shading", "depth pass + deferred"};
+			static char *renderMethodStr[] = {"forward", "depth pass + forward", "deferred shading", "depth pass + deferred"};
 	
 			sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d", 
 							useMultiQueries, useTightBounds, useRenderQueue);
 
-			sprintf(msg[i ++], "render technique: %s, SSAO: %d", renderTypeStr[renderType], useAdvancedShading);
+			sprintf(msg[i ++], "render technique: %s, SSAO: %d", renderMethodStr[renderMethod], useAdvancedShading);
 
 			sprintf(msg[i ++], "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf);
@@ -1940,5 +1955,5 @@
 void RenderVisibleObjects()
 {
-	if (renderType == RenderState::DEPTH_PASS_DEFERRED)
+	if (renderMethod == RENDER_DEPTH_PASS_DEFERRED)
 	{
 		if (showShadowMap && !renderLightView)
@@ -1956,5 +1971,4 @@
 		glDrawBuffers(3, mrt);
 		glClear(GL_COLOR_BUFFER_BIT);
-		//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 	}
 	else
@@ -1963,5 +1977,5 @@
 		glEnable(GL_LIGHTING);
 
-		state.SetRenderType(RenderState::FIXED);
+		state.SetRenderPassType(RenderState::FIXED);
 	}
 
@@ -2015,20 +2029,24 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 
-	state.SetRenderType(RenderState::DEPTH_PASS);
+	state.SetRenderPassType(RenderState::DEPTH_PASS);
+	state.LockCullFaceEnabled(true);
+	state.SetUseAlphaToCoverage(false);
 
 	// change CHC++ set of state variables (must be done for each change of camera because
 	// otherwise the temporal coherency is broken
 	BvhNode::SetCurrentState(1);
-	state.SetUseAlphaToCoverage(false);
 
 	// hack: temporarily change camera far plane
 	camera->SetFar(newfar);
-
+	glDisable(GL_CULL_FACE);
+	
 	// the scene is rendered withouth any shading	
 	shadowMap->ComputeShadowMap(shadowTraverser, matProjectionView);
 
+	glEnable(GL_CULL_FACE);
 	camera->SetFar(farDist);
 
 	state.SetUseAlphaToCoverage(true);
+	state.LockCullFaceEnabled(false);
 
 	glEnableClientState(GL_NORMAL_ARRAY);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.h	(revision 2954)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.h	(revision 2955)
@@ -2,10 +2,8 @@
 #define __SUNCOLOR_H__
 
-//#include "Vector3.h"
-
 namespace CHCDemoEngine{
-
 class Vector3;
 }
+
 /** Class describing a plane in 3D space.
 */
