Index: /trunk/VUT/GtpVisibility/include/QueryManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/QueryManager.h	(revision 71)
+++ /trunk/VUT/GtpVisibility/include/QueryManager.h	(revision 113)
@@ -25,5 +25,5 @@
 	onm different hierarchy types, while reusing the implementation of the query methods.
      */
-    QueryManager( HierarchyInterface *hierarchyInterface );
+    QueryManager(HierarchyInterface *hierarchyInterface);
     
     /** 
@@ -64,5 +64,5 @@
     
   /** 
-      Ray shooting intreface: finds an intersection with objects in the scene.
+      Ray shooting interface: finds an intersection with objects in the scene.
 
       @param ray The given input ray (assuming the ray direction is normalized)
@@ -84,5 +84,5 @@
       @remark the scene traverser depends on the type of hierarchyInterface the scene consists of.
 	*/
-	void SetSceneTraverser(HierarchyInterface *hierarchyInterface );
+	void SetSceneTraverser(HierarchyInterface *hierarchyInterface);
 
 protected:
Index: /trunk/VUT/GtpVisibility/include/PreprocessingManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/PreprocessingManager.h	(revision 71)
+++ /trunk/VUT/GtpVisibility/include/PreprocessingManager.h	(revision 113)
@@ -90,5 +90,5 @@
 	@remark the scene traverser is dependent on the type of hierarchyInterface the scene consists of.
     */
-    virtual void SetSceneTraverser( HierarchyInterface *hierarchyInterface ) {
+    virtual void SetSceneTraverser(HierarchyInterface *hierarchyInterface) {
       mSceneTraverser = hierarchyInterface;
     }
Index: /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 112)
+++ /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 113)
@@ -21,4 +21,9 @@
 		{//if (mHierarchyInterface->mIsShadowPass)
 			mNumFrustumCulledNodes ++;
+
+			if(mVisualizeCulledNodes)
+			{
+				mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+			}
 		}
 		else
Index: /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 112)
+++ /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 113)
@@ -53,5 +53,5 @@
 				if(mVisualizeCulledNodes)
 				{
-					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+					mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
 				}
 			}
Index: /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 112)
+++ /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 113)
@@ -23,4 +23,8 @@
 		{//if (mHierarchyInterface->mIsShadowPass)
 			mNumFrustumCulledNodes ++;
+			if(mVisualizeCulledNodes)
+			{
+				mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+			}
 		}
 		else
@@ -48,4 +52,8 @@
 			{	//if (mHierarchyInterface->mIsShadowPass)
 				mNumQueryCulledNodes ++;
+				if(mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+				}
 			}
 		}
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 112)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 113)
@@ -92,7 +92,6 @@
 {
 	// Set ambient light
-	//mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
 	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
-
+	
 	//-- create light
 	mSunLight = mSceneMgr->createLight("SunLight");
@@ -104,5 +103,5 @@
 	mSunLight->setCastShadows(true);
 
-	Vector3 dir(0.5, 0.5, 0.5);
+	Vector3 dir(0.5, 1, 0.5);
 	dir.normalise();
 	mSunLight->setDirection(dir);
@@ -237,5 +236,5 @@
 mVizCamera(vizCamera),
 mShowVisualization(false),
-mRenderNodesForViz(false),
+mNodeVizMode(NODEVIZ_NONE),
 mVizCameraHeight(Real(2500.0)),
 mCamNode(camNode),
@@ -292,6 +291,5 @@
 	mSceneMgr->setOption("CullCamera", &mCullCamera);
 	mSceneMgr->setOption("ShowVisualization", &mShowVisualization);
-	mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
-
+	
 	pOver->show();
 } 
@@ -403,6 +401,6 @@
 		// important for visualization => draw octree bounding boxes
 		mSceneMgr->setOption("ShowOctree", &mShowVisualization);
-		// also render geometry?
-		mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
+		// also render nodew content?
+		//mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
 
 		// -- setup visualization camera
@@ -454,11 +452,11 @@
 	KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling());
 	KEY_PRESSED(KC_1, 0.3, toggleShowViz());
-	KEY_PRESSED(KC_2, 0.3, toggleRenderNodesForViz());
+	KEY_PRESSED(KC_2, 0.3, nextNodeVizMode());
 	
 	KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10));
 	KEY_PRESSED(KC_ADD, 0, changeThreshold(10));
 	
-	KEY_PRESSED(KC_3, 0, zoomVizCamera(50));
-	KEY_PRESSED(KC_4, 0, zoomVizCamera(-50));
+	KEY_PRESSED(KC_4, 0, zoomVizCamera(50));
+	KEY_PRESSED(KC_5, 0, zoomVizCamera(-50));
 
 	KEY_PRESSED(KC_F1, 0.3, nextAppState());
@@ -758,9 +756,15 @@
 }
 //-----------------------------------------------------------------------
-void MouseQueryListener::toggleRenderNodesForViz()
-{
-	mRenderNodesForViz = !mRenderNodesForViz;
-
-	mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
+void MouseQueryListener::nextNodeVizMode()
+{
+	mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM;
+
+	bool renderNodesForViz = 
+		(mNodeVizMode == NODEVIZ_RENDER_NODES) || 
+		(mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT);
+	bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT;
+
+	mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz);
+	mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz);
 }
 //-----------------------------------------------------------------------
@@ -848,4 +852,14 @@
 	const bool nShowViz = !showViz;
 
+	// ambient light must be full for visualization
+    if (showViz)
+	{
+		mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));
+	}
+	else
+	{
+		mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
+	}
+
     mSceneMgr->setOption("ShowVisualization", &showViz);
 	mSceneMgr->setOption("SkyBoxEnabled", &nShowViz);
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 112)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 113)
@@ -87,4 +87,8 @@
 	enum  {WALKTHROUGH, REPLAY, STATE_NUM};
 
+	// visualization modes for scene nodes
+	enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, 
+		  NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
+
 	void nextAlgorithm();
 	void changeThreshold(int incr);
@@ -95,5 +99,5 @@
 	void toggleUseVisibilityCulling();
 	void toggleShowViz();
-	void toggleRenderNodesForViz();
+	void nextNodeVizMode();
 	void toggleRecord();
 
@@ -148,5 +152,5 @@
 	bool mUseVisibilityCulling;
 	bool mShowVisualization;
-	bool mRenderNodesForViz;
+	int mNodeVizMode;
 	bool mCullCamera;
 
Index: /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
===================================================================
--- /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 112)
+++ /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 113)
@@ -60,6 +60,7 @@
 	bool mUseVisibilityCulling;
 	bool mShowVisualization;
-	bool mRenderNodesForViz;
 	bool mVisualizeCulledNodes;
+
+	int mRenderNodesForViz;
 };
 
Index: /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
===================================================================
--- /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 112)
+++ /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 113)
@@ -50,5 +50,5 @@
 	*/
 	GtpVisibility::VisibilityManager *getVisibilityManager();
-	
+
 protected:
 	
@@ -63,4 +63,5 @@
 	bool mShowVisualization;
 	bool mRenderNodesForViz;
+	bool mRenderNodesContentForViz;
 	bool mVisualizeCulledNodes;
 };
Index: /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 112)
+++ /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 113)
@@ -20,4 +20,5 @@
 mShowVisualization(false),
 mRenderNodesForViz(false),
+mRenderNodesContentForViz(false),
 mVisualizeCulledNodes(false)
 {
@@ -39,5 +40,7 @@
 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
 {
+	// only shadow casters will be rendered in shadow texture pass
 	mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
+
 	// does nothing if hierarchical culling is used =>
 	// we interleave identification and rendering of objects 
@@ -64,22 +67,23 @@
             // ignore
         }
-				
-		for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
+		
+		if (mRenderNodesForViz || mRenderNodesContentForViz)
 		{
-			MaterialPtr mp = (*it)->getMaterial();
-			
-			mp.get()->setLightingEnabled(false);
-			mp.get()->setAmbient(ColourValue(1,0,0));
-			mp.get()->setDiffuse(ColourValue(1,1,1));
-			mp.get()->setSpecular(ColourValue(1,1,1));
-			
-			mp.get()->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
-			//*mp = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting");
-			//(*it)->setMaterialName("BaseWhiteNoLighting");
-			getRenderQueue()->addRenderable(*it);
-
-			if (mRenderNodesForViz)
+			// change node material so it is better suited for visualization
+			MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
+			nodeMat->setAmbient(1, 1, 0);
+			nodeMat->setLightingEnabled(true);
+			nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
+
+			for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
 			{
-				(*it)->_addToRenderQueue(cam, getRenderQueue(), false);
+				if (mRenderNodesForViz)
+				{
+					getRenderQueue()->addRenderable(*it);
+				}
+				if (mRenderNodesContentForViz) 
+				{
+					(*it)->_addToRenderQueue(cam, getRenderQueue(), false);
+				}
 			}
 		}
@@ -109,4 +113,6 @@
 	if (!mUseVisibilityCulling || mShowVisualization)
 	{	
+		//mDestRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM);
+		//mDestRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);
 		TerrainSceneManager::_renderVisibleObjects();
 	
@@ -179,4 +185,9 @@
 	{
 		mRenderNodesForViz = (*static_cast<const bool *>(val));
+		return true;
+	}
+	if (key == "RenderNodesContentForViz")
+	{
+		mRenderNodesContentForViz = (*static_cast<const bool *>(val));
 		return true;
 	}
Index: /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 112)
+++ /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 113)
@@ -3,5 +3,5 @@
 #include <OgreOctree.h>
 #include <OgreLogManager.h>
-
+#include <OgreStringConverter.h>
 #include <windows.h>
 
@@ -156,6 +156,6 @@
 		box->setMaterial("QueryCulledNodesMaterial");
 	}
+
 	static_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box);
-	//LogManager::getSingleton().logMessage("pushing box");
 }
 } // namespace Ogre
Index: /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 112)
+++ /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 113)
@@ -142,5 +142,5 @@
 	if (key == "RenderNodesForViz")
 	{
-		mRenderNodesForViz = (*static_cast<const bool *>(val));
+		mRenderNodesForViz = (*static_cast<const int *>(val));
 		return true;
 	}
Index: /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 112)
+++ /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 113)
@@ -12,6 +12,4 @@
 mCamera(NULL), mCullCamera(NULL), mOnlyShadowCasters(false)
 {
-	CreateCulledNodeMaterials();
-	
 }
 //-----------------------------------------------------------------------
@@ -20,27 +18,30 @@
 	// material for frustum culled nodes
 	MaterialPtr mat = MaterialManager::getSingleton().getByName("FrustumCulledNodesMaterial");
-	MaterialPtr baseWhite = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting");
+	
 	if (mat.isNull())
 	{
 		mat = MaterialManager::getSingleton().create("FrustumCulledNodesMaterial", 
 			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-
-		//baseWhite.get()->copyDetailsTo(mat);
-		//mat->setColourWriteEnabled(true);
-		mat->setLightingEnabled(false);
-		//mat->setAmbient(ColourValue(1,0,0));
+		mat->createTechnique()->createPass();
+		
+		mat->getTechnique(0)->getPass(0)->setAmbient(1,0,0);
+		mat->getTechnique(0)->getPass(0)->setLightingEnabled(true);
+		//mat->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
+		
+		mat->load();
 	}
 
 	// material for query culled nodes
-	MaterialPtr mat2 = MaterialManager::getSingleton().getByName("QueryCulledNodesMaterial");
-
-	if (mat2.isNull())
-	{
-		mat2 = MaterialManager::getSingleton().create("QueryCulledNodesMaterial", 
+	mat = MaterialManager::getSingleton().getByName("QueryCulledNodesMaterial");
+
+	if (mat.isNull())
+	{
+		mat = MaterialManager::getSingleton().create("QueryCulledNodesMaterial", 
 			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-		//baseWhite.get()->copyDetailsTo(mat2);
-	//	mat2->setColourWriteEnabled(true);
-		mat2->setLightingEnabled(false);
-		//mat2->setAmbient(ColourValue(0,0,1));		
+		mat->createTechnique()->createPass();
+		
+		mat->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
+		mat->getTechnique(0)->getPass(0)->setLightingEnabled(true);
+		mat->load();
 	}
 }
@@ -126,4 +127,6 @@
 		SetCullCamera(cam);
 	}
+
+	CreateCulledNodeMaterials();
 }
 //-----------------------------------------------------------------------
