Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 1722)
@@ -186,5 +186,7 @@
 	void runChanged(RenderingRunType runType, RenderingRun* run);
 	virtual void addTechniqueGroup(TechniqueGroup* group){childTechniqueGroups.push_back(group);}
-	
+	void setMaterial(String materialName);
+	void restoreMaterial();
+
 protected:
 	/**
@@ -206,4 +208,5 @@
 	*/
 	std::map<OgreRenderable*, bool> renderables; 
+	std::map<OgreRenderable*, String> renderableMaterials;
 	/**
 		@brief the bounding sphere of all the objects connected to this node.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1644)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1722)
@@ -32,6 +32,5 @@
 	OgreRenderingRun* asOgreRenderingRun(){return this;}
 
-	virtual bool canJoin(OgreRenderingRun* run){return true;}
-
+	
 protected:
 
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 1722)
@@ -0,0 +1,83 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderingRun.h"
+#include "CubeMapRenderingRun.h"
+#include "OgreSharedRuns.h"
+
+
+/**
+	@brief ColorCubeMapRenderingRun used in an OGRE environment.
+*/
+class OgreCubeMapRenderingRun : public OgreRenderingRun,
+								public CubeMapRenderingRun
+{	
+public:
+
+	/**
+		@brief Constructor.
+
+		@param sharedRuns			a pointer to the OgreSharedRuns this run belongs to
+		@param name					the name of the cubemap texture to be created
+		@param startFrame			adds an offset to the current frame number to help evenly distribute updates between frames
+		@param updateInterval		update frequency
+		@param resolution			cubemap resolution
+		@param useDistCalc			flag to skip cube face update if object is far away
+		@param useFaceAngleCalc		flag to skip cube face update if face is neglible
+		@param distTolerance		distance tolerance used in face skip
+		@param angleTolerance		angle tolerance used in face skip		
+		@param updateAllFace		defines if all cubemap faces should be updated in a frame or only one face per frame
+	*/	
+	OgreCubeMapRenderingRun(OgreSharedRuns* sharedRuns,
+								 String name,
+								 unsigned long startFrame,
+								 unsigned long updateInterval,
+								 unsigned int resolution,
+								 bool useDistCalc,
+								 bool useFaceAngleCalc,
+								 float distTolerance,
+								 float angleTolerance,
+								 bool updateAllFace,
+								 bool renderSelf,
+								 bool renderEnvironment,
+								 String selfMaterial,
+								 String environmentMaterial);
+	/**
+		@brief returns the name of the resulting color cubemap texture
+	*/
+	String getCubeMapTextureName(){return name;}
+	
+protected:
+
+	/**
+		@brief a pointer to the OgreSharedRuns this run belongs to
+	*/
+	OgreSharedRuns* sharedRuns;
+	/**
+		@brief the name of the cubemap texture that was created by this run
+	*/
+	String name;
+	/**
+		@brief a pointer to the cubemap texture that was created by this run
+	*/
+	Texture* cubemapTexture;
+	String selfMaterial;
+	bool useSelfMaterial;
+	String environmentMaterial;
+	bool useEnvMaterial;
+
+	
+	
+	//inherited
+	inline void createCubeMap();
+	//inherited
+	inline void updateCubeFace(int facenum);
+	//inherited
+    bool faceNeedsUpdate(int facenum); 	
+};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h	(revision 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h	(revision 1722)
@@ -48,7 +48,7 @@
 	void refreshLight();
 
-	bool canJoin(OgreRenderingRun* run)
+	bool canJoin(RenderingRun* run)
 	{
-		OgrePhotonMapRenderingRun* r = (OgrePhotonMapRenderingRun*) run;
+		OgrePhotonMapRenderingRun* r = (OgrePhotonMapRenderingRun*) run->asOgreRenderingRun();
 		if(r->materialName == materialName)
 			return true;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h	(revision 1688)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h	(revision 1722)
@@ -60,7 +60,7 @@
 	float getAttenuation(){return attenuation;}
 	
-	bool canJoin(OgreRenderingRun* run)
+	bool canJoin(RenderingRun* run)
 	{
-		OgreCausticCubeMapRenderingRun* r = (OgreCausticCubeMapRenderingRun*) run;
+		OgreCausticCubeMapRenderingRun* r = (OgreCausticCubeMapRenderingRun*) run->asOgreRenderingRun();
 		if(r->materialName == materialName)
 			return true;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1330)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1722)
@@ -46,5 +46,5 @@
 	String getImpostorTextureName(){return name;}
 	
-	bool canJoin(OgreRenderingRun* run)
+	bool canJoin(RenderingRun* run)
 	{
 		
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreColorCubeMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreColorCubeMapRenderingRun.h	(revision 790)
+++ 	(revision )
@@ -1,74 +1,0 @@
-#pragma once
-
-//disable inheritance warning caused by multiple inheritance
-#if _WIN32
-#if _MSC_VER
-#pragma warning(disable: 4250)
-#endif
-#endif
-
-#include "OgreRenderingRun.h"
-#include "ColorCubeMapRenderingRun.h"
-#include "OgreSharedRuns.h"
-
-
-/**
-	@brief ColorCubeMapRenderingRun used in an OGRE environment.
-*/
-class OgreColorCubeMapRenderingRun : public OgreRenderingRun,
-									public ColorCubeMapRenderingRun
-{	
-public:
-
-	/**
-		@brief Constructor.
-
-		@param sharedRuns			a pointer to the OgreSharedRuns this run belongs to
-		@param name					the name of the cubemap texture to be created
-		@param startFrame			adds an offset to the current frame number to help evenly distribute updates between frames
-		@param updateInterval		update frequency
-		@param resolution			cubemap resolution
-		@param useDistCalc			flag to skip cube face update if object is far away
-		@param useFaceAngleCalc		flag to skip cube face update if face is neglible
-		@param distTolerance		distance tolerance used in face skip
-		@param angleTolerance		angle tolerance used in face skip		
-		@param updateAllFace		defines if all cubemap faces should be updated in a frame or only one face per frame
-	*/	
-	OgreColorCubeMapRenderingRun(OgreSharedRuns* sharedRuns,
-								 String name,
-								 unsigned long startFrame,
-								 unsigned long updateInterval,
-								 unsigned int resolution,
-								 bool useDistCalc = false,
-								 bool useFaceAngleCalc = false,
-								 float distTolerance = 15,
-								 float angleTolerance = 10,
-								 bool updateAllFace = false);
-	/**
-		@brief returns the name of the resulting color cubemap texture
-	*/
-	String getColorCubeMapTextureName(){return name;}
-	
-protected:
-
-	/**
-		@brief a pointer to the OgreSharedRuns this run belongs to
-	*/
-	OgreSharedRuns* sharedRuns;
-	/**
-		@brief the name of the cubemap texture that was created by this run
-	*/
-	String name;
-	/**
-		@brief a pointer to the cubemap texture that was created by this run
-	*/
-	Texture* colorCubemapTexture;
-	
-	
-	//inherited
-	inline void createColorCubeMap();
-	//inherited
-	inline void updateCubeFace(int facenum);
-	//inherited
-    bool faceNeedsUpdate(int facenum); 	
-};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDistanceCubeMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDistanceCubeMapRenderingRun.h	(revision 790)
+++ 	(revision )
@@ -1,73 +1,0 @@
-#pragma once
-
-//disable inheritance warning caused by multiple inheritance
-#if _WIN32
-#if _MSC_VER
-#pragma warning(disable: 4250)
-#endif
-#endif
-
-#include "OgreRenderingRun.h"
-#include "DistanceCubeMapRenderingRun.h"
-#include "OgreSharedRuns.h"
-
-
-/**
-	@brief ColorCubeMapRenderingRun used in an OGRE environment.
-*/
-class OgreDistanceCubeMapRenderingRun : public OgreRenderingRun,
-									public DistanceCubeMapRenderingRun
-{	
-public:
-
-	/**
-		@brief Constructor.
-
-		@param sharedRuns			a pointer to the OgreSharedRuns this run belongs to
-		@param name					the name of the cubemap texture to be created
-		@param startFrame			adds an offset to the current frame number to help evenly distribute updates between frames
-		@param updateInterval		update frequency
-		@param resolution			cubemap resolution
-		@param useDistCalc			flag to skip cube face update if object is far away
-		@param useFaceAngleCalc		flag to skip cube face update if face is neglible
-		@param distTolerance		distance tolerance used in face skip
-		@param angleTolerance		angle tolerance used in face skip		
-		@param updateAllFace		defines if all cubemap faces should be updated in a frame or only one face per frame
-	*/	
-	OgreDistanceCubeMapRenderingRun(OgreSharedRuns* sharedRuns,
-								String name,
-								  unsigned long startFrame,
-								unsigned long updateInterval,
-								unsigned int resolution,
-								 bool useDistCalc = false,
-								 bool useFaceAngleCalc = false,
-								 float distTolerance = 15,
-								 float angleTolerance = 10,
-								 bool updateAllFace = false);
-	/**
-		@brief returns the name of the resulting distance cubemap texture
-	*/
-	String getDistanceCubeMapTextureName(){return name;}
-	
-protected:	
-	/**
-		@brief a pointer to the OgreSharedRuns this run belongs to
-	*/
-	OgreSharedRuns* sharedRuns;
-	/**
-		@brief the name of the cubemap texture that was created by this run
-	*/
-	String name;
-	/**
-		@brief a pointer to the cubemap texture that was created by this run
-	*/
-	Texture* distanceCubemapTexture;
-	
-	
-	//inherited
-	inline void createDistanceCubeMap();
-	//inherited
-	inline void updateCubeFace(int facenum);
-	//inherited
-    bool faceNeedsUpdate(int facenum); 	
-};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 1711)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 1722)
@@ -48,4 +48,7 @@
 							bool updateAllFace,
 							bool renderSelf,
+							bool renderEnvironment,
+							String selfMaterial,
+							String environmentMaterial,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -64,6 +67,4 @@
 	//inherited
 	void distanceCubeMapRunChanged(RenderingRun* run);
-	//inherited
-	RenderingRun* createDistanceCubeMapRun();
 	//inherited
 	void distanceCubeMapRunUpdated(RenderingRun* run);
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 1711)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 1722)
@@ -48,4 +48,7 @@
 									bool updateAllFace,
 									bool renderSelf,
+									bool renderEnvironment,
+									String selfMaterial,
+									String environmentMaterial,
 									Pass* pass,
 									OgreRenderable* parentRenderable,
@@ -63,9 +66,5 @@
 	
 	//inherited
-	void colorCubeMapRunChanged(RenderingRun* run);
-	//inherited
-	RenderingRun* createColorCubeMapRun();
-
-	
+	void colorCubeMapRunChanged(RenderingRun* run);	
 };
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h	(revision 1711)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h	(revision 1722)
@@ -50,4 +50,7 @@
 							bool updateAllFace,
 							bool renderSelf,
+							bool renderEnvironment,
+							String selfMaterial,
+							String environmentMaterial,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -68,6 +71,4 @@
 	//inherited
 	void colorCubeMapRunChanged(RenderingRun* run);
-	//inherited
-	RenderingRun* createColorCubeMapRun();
 	//inherited
 	RenderingRun* createReducedCubeMapRun();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 1711)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 1722)
@@ -48,7 +48,11 @@
 							bool updateAllFace,
 							bool renderSelf,
+							bool renderEnvironment,
+							String selfMaterial,
+							String environmentMaterial,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
-							OgreTechniqueGroup* parentTechniqueGroup
+							OgreTechniqueGroup* parentTechniqueGroup,
+							bool createCubeRun = false
 							);
 	/**
@@ -56,4 +60,5 @@
 	*/
 	~OgreCubeMapRenderTechnique();
+	
 		
 protected:
@@ -62,5 +67,11 @@
 		@brief the id of the texture unit state the resulting cubemap should be bound to
 	*/
-	unsigned char texID;	
+	unsigned char texID;
+	String selfMaterial;
+	String environmentMaterial;
+	String texturePostFix;
+
+	RenderingRun* createCubeMapRun();
+	void cubeMapRunChanged(RenderingRun* run);	
 };
 
@@ -70,4 +81,11 @@
 	
 	OgreCubeMapRenderTechniqueFactory();
+
+	OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup);
+
+	void resetParams();
 	
 	unsigned long startFrame;
@@ -81,6 +99,6 @@
 	bool updateAllFace;
 	bool renderSelf;
-
-	void resetParams();
-
+	bool renderEnvironment;
+	String selfMaterial;
+	String environmentMaterial;
 };
