Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1644)
@@ -46,4 +46,5 @@
 	*/
 	std::map<Renderable*, String> visibleObjects;
+	String terrainMaterial;
 	/**
 		@brief fulls screen quad plane used in full screen quad rendering
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1644)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				ImproveFloatingPointConsistency="TRUE"
-				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include;..\include\RenderingRuns;..\include\RenderTechniques;..\..\IllumModule\include;..\..\IllumModule\include\RenderingRuns;..\..\IllumModule\include\RenderTechniques"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include;..\include\RenderingRuns;..\include\RenderTechniques;..\..\IllumModule\include;..\..\IllumModule\include\RenderingRuns;..\..\IllumModule\include\RenderTechniques;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include\&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
@@ -37,5 +37,5 @@
 				Name="VCLibrarianTool"
 				AdditionalDependencies="IllumModule.lib OgreMain_d.lib"
-				AdditionalLibraryDirectories="..\..\IllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;"/>
+				AdditionalLibraryDirectories="..\..\IllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;"/>
 			<Tool
 				Name="VCMIDLTool"/>
@@ -75,5 +75,5 @@
 				OptimizeForProcessor="2"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include;..\include\RenderingRuns;..\include\RenderTechniques;..\..\IllumModule\include;..\..\IllumModule\include\RenderingRuns;..\..\IllumModule\include\RenderTechniques"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include;..\include\RenderingRuns;..\include\RenderTechniques;..\..\IllumModule\include;..\..\IllumModule\include\RenderingRuns;..\..\IllumModule\include\RenderTechniques;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include\&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE"
 				StringPooling="TRUE"
@@ -92,5 +92,5 @@
 				Name="VCLibrarianTool"
 				AdditionalDependencies="IllumModule.lib OgreMain.lib"
-				AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;"/>
+				AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;"/>
 			<Tool
 				Name="VCMIDLTool"/>
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1592)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1644)
@@ -1,4 +1,5 @@
 #include "OgreRenderingrun.h"
 #include "OgreIlluminationManager.h"
+#include "OgreTerrainSceneManager.h"
 
 MovablePlane* OgreRenderingRun::fullScreenQuad = NULL;
@@ -121,4 +122,11 @@
 void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq,  bool solidsonly)
 {
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	if(sm->getTypeName()==TerrainSceneManagerFactory::FACTORY_TYPE_NAME)
+	{
+		terrainMaterial = ((TerrainSceneManager*)sm)->getTerrainMaterial()->getName();
+		((TerrainSceneManager*)sm)->setCustomMaterial(materialName);
+	}
+
 	RenderQueue::QueueGroupIterator queueIt = rq->_getQueueGroupIterator();
    
@@ -153,5 +161,4 @@
 	}
 
-	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
 	sm->setFindVisibleObjects(false);	
 }
@@ -178,4 +185,9 @@
 void OgreRenderingRun::restoreMaterials()
 {
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	if(sm->getTypeName()==TerrainSceneManagerFactory::FACTORY_TYPE_NAME)
+		((TerrainSceneManager*)sm)->setCustomMaterial(terrainMaterial);
+	
+
 	std::map<Renderable*, String>::iterator it = visibleObjects.begin();
 	std::map<Renderable*, String>::iterator itend = visibleObjects.end();
@@ -189,5 +201,4 @@
 	visibleObjects.clear();
 
-	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
 	sm->setFindVisibleObjects(true);
 }
