Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h	(revision 1725)
@@ -48,5 +48,6 @@
 								 bool renderEnvironment,
 								 String selfMaterial,
-								 String environmentMaterial);
+								 String environmentMaterial,
+								 RenderingRunType cubemapRunType);
 	/**
 		@brief returns the name of the resulting color cubemap texture
@@ -72,5 +73,5 @@
 	String environmentMaterial;
 	bool useEnvMaterial;
-
+	RenderingRunType cubemapRunType;
 	
 	
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 1725)
@@ -51,4 +51,5 @@
 							String selfMaterial,
 							String environmentMaterial,
+							int layer,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -77,5 +78,4 @@
 {
 public:
-	
 	OgreDistanceCubeMapRenderTechniqueFactory();
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 1725)
@@ -51,4 +51,5 @@
 									String selfMaterial,
 									String environmentMaterial,
+									int layer,
 									Pass* pass,
 									OgreRenderable* parentRenderable,
@@ -64,5 +65,4 @@
 	
 protected:		
-	
 	//inherited
 	void colorCubeMapRunChanged(RenderingRun* run);	
@@ -72,5 +72,4 @@
 {
 public:
-	
 	OgreColorCubeMapRenderTechniqueFactory();
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 1725)
@@ -51,4 +51,5 @@
 							String selfMaterial,
 							String environmentMaterial,
+							int layer,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -102,3 +103,4 @@
 	String selfMaterial;
 	String environmentMaterial;
+	int layer;
 };
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1670)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1725)
@@ -110,5 +110,6 @@
 		v->setOverlaysEnabled(false);
 		rt->setAutoUpdated(false);
-
+		v->setBackgroundColour(clearColor);
+		
 		Root::getSingleton().getRenderSystem()->_setViewport(v);
 		Root::getSingleton().getRenderSystem()->clearFrameBuffer( FBT_COLOUR, clearColor);
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp	(revision 1725)
@@ -17,5 +17,6 @@
 														   bool renderEnvironment,
 														   String selfMaterial,
-														   String environmentMaterial)
+														   String environmentMaterial,														   
+														   RenderingRunType cubemapRunType)
 														   :CubeMapRenderingRun(startFrame, updateInterval, resolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment)
 							, OgreRenderingRun(startFrame, updateInterval)
@@ -23,4 +24,5 @@
 
 {
+	this->cubemapRunType = cubemapRunType;
 	this->sharedRuns = sharedRuns;
 	this->name = name;
@@ -44,4 +46,6 @@
 void OgreCubeMapRenderingRun::createCubeMap()
 {
+	ColourValue clearColor = ColourValue::Black;
+	clearColor.a = 0.0;
 	cubemapTexture = createCubeRenderTexture(name, 
 												sharedRuns->getRootPosition(),
@@ -49,10 +53,11 @@
 												PF_FLOAT16_RGBA,
 												//PF_R8G8B8A8,
-												0);	
+												0,
+												clearColor);	
 }
 
 void OgreCubeMapRenderingRun::updateCubeFace(int facenum)
 {
-	OgreSharedRuns* root = (OgreSharedRuns*) sharedRuns->getRoot(ILLUMRUN_COLOR_CUBEMAP);
+	OgreSharedRuns* root = (OgreSharedRuns*) sharedRuns->getRoot(cubemapRunType);
 	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
 	RenderQueue* rq = sm->getRenderQueue();
@@ -60,5 +65,5 @@
 	RenderTarget* rt = cubemapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();
 	Camera*  cam = 	rt->getViewport(0)->getCamera();
-	Vector3 center = sharedRuns->getRootPosition(ILLUMRUN_COLOR_CUBEMAP);
+	Vector3 center = sharedRuns->getRootPosition(cubemapRunType);
 	cam->setPosition(center);
 
@@ -94,5 +99,5 @@
 		if(renderSelf)
 		{
-			sharedRuns->getRoot(ILLUMRUN_COLOR_CUBEMAP)->restoreVisibility();
+			root->restoreVisibility();
 			if(useSelfMaterial)
 				root->setMaterial(selfMaterial);
@@ -105,5 +110,5 @@
 	rt->update();
 
-	//rt->writeContentsToFile("cubbe" + StringConverter::toString(facenum) + ".dds");
+	//rt->writeContentsToFile( "cubeLayer" + StringConverter::toString(cubemapRunType)+ "face" +  StringConverter::toString(facenum) + ".dds");
 	
 	if(!renderAllwithOwnColor)
@@ -132,6 +137,6 @@
 		if(useDistCalc)
 		{
-			Vector3 cubemapPosition = sharedRuns->getRootPosition(ILLUMRUN_COLOR_CUBEMAP);
-			float objradius = sharedRuns->getRootBoundingSphere(ILLUMRUN_COLOR_CUBEMAP).getRadius();
+			Vector3 cubemapPosition = sharedRuns->getRootPosition(cubemapRunType);
+			float objradius = sharedRuns->getRootBoundingSphere(cubemapRunType).getRadius();
 			float fov = mainCamera->getFOVy().valueRadians() / 2.0;
 			float dist = (cubemapPosition - mainCamera->getPosition()).length();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp	(revision 1725)
@@ -16,18 +16,42 @@
 														String selfMaterial,
 														String environmentMaterial,
+														int layer,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
 														OgreTechniqueGroup* parentTechniqueGroup)
-															:OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, pass, parentRenderable, parentTechniqueGroup),
-															ColorCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
-															CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
+															:OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, pass, parentRenderable, parentTechniqueGroup),
+															ColorCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
+															CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
 															RenderTechnique(parentRenderable, parentTechniqueGroup) 
 {	
-	texturePostFix = "_COLORCUBEMAP";
+	switch(layer)
+	{
+		case 0:
+			texturePostFix = "_COLORCUBEMAP";
+			break;
+		case 1:
+			texturePostFix = "_COLORCUBEMAP_L1";
+			break;
+		case 2:
+			texturePostFix = "_COLORCUBEMAP_L2";
+			break;
+		case 3:
+			texturePostFix = "_COLORCUBEMAP_L3";
+			break;
+		case 4:
+			texturePostFix = "_COLORCUBEMAP_L4";
+			break;
+		case 5:
+			texturePostFix = "_COLORCUBEMAP_L5";
+			break;
+		case 6:
+			texturePostFix = "_COLORCUBEMAP_L6";
+			break;
+	}
 
-	if(sharedRuns->getRun(ILLUMRUN_COLOR_CUBEMAP) == 0)
-		sharedRuns->addRun(ILLUMRUN_COLOR_CUBEMAP, createCubeMapRun());
+	if(sharedRuns->getRun(cubemapLayer) == 0)
+		sharedRuns->addRun(cubemapLayer, createCubeMapRun());
 	
-	colorCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_COLOR_CUBEMAP));
+	colorCubeMapRunChanged(sharedRuns->getRun(cubemapLayer));
 }
 
@@ -57,11 +81,8 @@
 }
 
-
-
-
 ///Technique factory
 OgreColorCubeMapRenderTechniqueFactory::OgreColorCubeMapRenderTechniqueFactory()
 {
-	typeName = "ColorCubeMap";	
+	typeName = "ColorCubeMap";
 }
 
@@ -91,4 +112,5 @@
 													selfMaterial,
 													environmentMaterial,
+													layer,
 													pass,
 													parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp	(revision 1725)
@@ -22,6 +22,6 @@
 														OgreTechniqueGroup* parentTechniqueGroup)
 							:
-							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, pass, parentRenderable, parentTechniqueGroup),
-							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
+							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, pass, parentRenderable, parentTechniqueGroup),
+							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
 							ConvolvedCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, reducedCubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
 							RenderTechnique(parentRenderable, parentTechniqueGroup) 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp	(revision 1725)
@@ -16,4 +16,5 @@
 														String selfMaterial,
 														String environmentMaterial,
+														int layer,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
@@ -21,5 +22,5 @@
 														bool createCubeRun)
 							:OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
-							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
+							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
 							RenderTechnique(parentRenderable, parentTechniqueGroup) 
 {	
@@ -67,5 +68,6 @@
 												renderEnvironment,
 												selfMaterial,
-												environmentMaterial);
+												environmentMaterial,
+												cubemapLayer);
 }
 
@@ -167,9 +169,16 @@
 		f->environmentMaterial =  params;
 	}
+	void parseLayer(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
+		f->layer =  StringConverter::parseInt(params);
+	}
+
 }
 ///Technique factory
 OgreCubeMapRenderTechniqueFactory::OgreCubeMapRenderTechniqueFactory()
 {
-	
+	typeName = "CubeMap";
+
 	using namespace CubemapParsers;
 
@@ -186,4 +195,5 @@
 	this->attributeParsers.insert(AttribParserList::value_type("self_material", (ILLUM_ATTRIBUTE_PARSER) parseSelfMaterial));
 	this->attributeParsers.insert(AttribParserList::value_type("env_material", (ILLUM_ATTRIBUTE_PARSER) parseEnvMaterial));
+	this->attributeParsers.insert(AttribParserList::value_type("layer", (ILLUM_ATTRIBUTE_PARSER) parseLayer));
 
 }
@@ -204,4 +214,5 @@
 	selfMaterial = "";
 	environmentMaterial = "";
+	layer = 0;
 }
 
@@ -229,4 +240,5 @@
 												selfMaterial,
 												environmentMaterial,
+												layer,
 												pass,
 												parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 1725)
@@ -132,5 +132,6 @@
 										true,
 										"",
-										"GameTools/DistanceShader");
+										"GameTools/DistanceShader",
+										ILLUMRUN_DISTANCE_CUBEMAP);
 
 }
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp	(revision 1722)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp	(revision 1725)
@@ -16,19 +16,42 @@
 														String selfMaterial,
 														String environmentMaterial,
+														int layer,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
 														OgreTechniqueGroup* parentTechniqueGroup)
 							:
-							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, pass, parentRenderable, parentTechniqueGroup),
-							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
-							DistanceCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
+							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, pass, parentRenderable, parentTechniqueGroup),
+							CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
+							DistanceCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
 							RenderTechnique(parentRenderable, parentTechniqueGroup) 
 {	
-	texturePostFix = "_DISTANCECUBEMAP";
+	switch(layer)
+	{
+		case 0:
+			texturePostFix = "_DISTANCECUBEMAP";
+			break;
+		case 1:
+			texturePostFix = "_DISTANCECUBEMAP_L1";
+			break;
+		case 2:
+			texturePostFix = "_DISTANCECUBEMAP_L2";
+			break;
+		case 3:
+			texturePostFix = "_DISTANCECUBEMAP_L3";
+			break;
+		case 4:
+			texturePostFix = "_DISTANCECUBEMAP_L4";
+			break;
+		case 5:
+			texturePostFix = "_DISTANCECUBEMAP_L5";
+			break;
+		case 6:
+			texturePostFix = "_DISTANCECUBEMAP_L6";
+			break;
+	}
+	if(sharedRuns->getRun(cubemapLayer) == 0)
+		sharedRuns->addRun(cubemapLayer, createCubeMapRun());
 
-	if(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP) == 0)
-		sharedRuns->addRun(ILLUMRUN_DISTANCE_CUBEMAP, createCubeMapRun());
-
-	distanceCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP));
+	distanceCubeMapRunChanged(sharedRuns->getRun(cubemapLayer));
 }
 
@@ -55,5 +78,5 @@
 {
 	GpuProgramParametersSharedPtr fpParams = pass->getFragmentProgramParameters();
-	Vector3 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(ILLUMRUN_DISTANCE_CUBEMAP);
+	Vector3 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(cubemapLayer);
 	fpParams->setNamedConstant("lastCenter",center); 
 }
@@ -94,4 +117,5 @@
 												selfMaterial,
 												environmentMaterial,
+												layer,
 												pass,
 												parentRenderable,
