Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2333)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2355)
@@ -115,5 +115,5 @@
 		@param rq pointer to the filled Renderqueue instance to set material for
 	*/
-	void setMaterialForRenderables(String& materialName, RenderQueue* rq, bool solidsonly = false);
+	void setMaterialForRenderables(String& materialName, RenderQueue* rq, bool solidsonly = false, String triggerName = "");
 	/**
 		@brief Sets the given material for each Renderable visible from a given camera.
@@ -130,5 +130,5 @@
 		@param shadowcastersonly flag to search for only shadow casters
 	*/
-	void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false, bool solidsonly = false);
+	void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false, bool solidsonly = false, String triggerName = "");
 	/**
 		@brief Restores previously stored materials.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreTechniqueGroup.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreTechniqueGroup.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreTechniqueGroup.h	(revision 2355)
@@ -29,6 +29,13 @@
 		parentSharedRuns->updateBounds();		
 	}
+	String getMaterialNameForTrigger(String trigger)
+	{
+		if(triggeredMaterials.find(trigger) == triggeredMaterials.end())
+			return "";
+		else return triggeredMaterials[trigger];
+	}
 
 protected:
+	std::map<String, String> triggeredMaterials;
 	/**
 		@brief Collection of OgreRenderTechniques
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCubeMapRenderingRun.h	(revision 2355)
@@ -54,4 +54,5 @@
 								 String selfMaterial,
 								 String environmentMaterial,
+								 String envTriggerName,
 								 bool getMinMax,
 								 RenderingRunType cubemapRunType);
@@ -104,4 +105,6 @@
 	Vector4 max;
 
+	String envTriggerName;
+
 	/**
 		@brief 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDistanceCubeMapRenderTechnique.h	(revision 2355)
@@ -65,4 +65,5 @@
 							String minVariableName,
 							String maxVariableName,
+							String triggerName,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreColorCubeMapRenderTechnique.h	(revision 2355)
@@ -65,4 +65,5 @@
 									String minVariableName,
 									String maxVariableName,
+									String triggerName,
 									Pass* pass,
 									OgreRenderable* parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.h	(revision 2355)
@@ -65,4 +65,5 @@
 							String minVariableName,
 							String maxVariableName,
+							String triggerName,														
 							Pass* pass,
 							OgreRenderable* parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 2355)
@@ -65,4 +65,5 @@
 							String minVariableName,
 						    String maxVariableName,
+							String triggerName,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -109,4 +110,6 @@
 	String maxVariableName;
 
+	String triggerName;
+
 	//inherited
 	RenderingRun* createCubeMapRun();
@@ -152,3 +155,4 @@
 	String minVariableName;
 	String maxVariableName;
+	String triggerName;
 };
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2333)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2355)
@@ -13,8 +13,9 @@
 private:
 	String materialName;
+	String triggerName;
 	std::map<Renderable*, String>* visibleObjects;
 public:
     
-	MaterialSetVisitor(String& materialName, std::map<Renderable*, String>* visibleObjects)
+	MaterialSetVisitor(String& materialName, std::map<Renderable*, String>* visibleObjects, String trigger = "")
 	{
 		this->materialName = materialName;
@@ -29,5 +30,14 @@
 		{
 			(*visibleObjects)[rend] = rend->getMaterial().getPointer()->getName();
-			rend->setMaterialName(materialName);
+			String materialToSet = materialName;
+			if(triggerName != "")//we have a trigger here
+			{
+				String triggeredMaterial = 
+					((OgreTechniqueGroup*)rend->getRenderTechniqueGroup())
+						->getMaterialNameForTrigger(triggerName);
+				if(triggeredMaterial != "")//a trigger is associated
+					materialToSet = triggeredMaterial;
+			}				
+			rend->setMaterialName(materialToSet);
 		}
 	}
@@ -40,5 +50,14 @@
 		{
 			(*visibleObjects)[rend] = rend->getMaterial().getPointer()->getName();
-			rend->setMaterialName(materialName);
+			String materialToSet = materialName;
+			if(triggerName != "")//we have a trigger here
+			{
+				String triggeredMaterial = 
+					((OgreTechniqueGroup*)rend->getRenderTechniqueGroup())
+						->getMaterialNameForTrigger(triggerName);
+				if(triggeredMaterial != "")//a trigger is associated
+					materialToSet = triggeredMaterial;
+			}				
+			rend->setMaterialName(materialToSet);
 		}
 	}
@@ -127,5 +146,5 @@
 }
 
-void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq,  bool solidsonly)
+void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq,  bool solidsonly, String triggerName)
 {
 	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
@@ -144,5 +163,5 @@
 			const QueuedRenderableCollection& solids = pPriorityGrp->getSolidsBasic();
 			const QueuedRenderableCollection& transparents = pPriorityGrp->getTransparents();
-			MaterialSetVisitor visitor(materialName, &visibleObjects);	
+			MaterialSetVisitor visitor(materialName, &visibleObjects, triggerName);	
 			solids.acceptVisitor(&visitor, QueuedRenderableCollection::OM_PASS_GROUP);
 			if(!solidsonly)
@@ -166,5 +185,5 @@
 }
 
-void OgreRenderingRun::setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly, bool solidsonly)
+void OgreRenderingRun::setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly, bool solidsonly, String triggerName)
 {
 	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
@@ -183,5 +202,5 @@
 	sm->_findVisibleObjects(cam, shadowcastersonly);
 	
-	setMaterialForRenderables(materialName, sm->getRenderQueue(), solidsonly);
+	setMaterialForRenderables(materialName, sm->getRenderQueue(), solidsonly, triggerName);
 }
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 2355)
@@ -43,5 +43,5 @@
 {
 	
-	setMaterialForVisibles(String("GTP/Basic/CameraDepth"), playerCamera, false, true);
+	setMaterialForVisibles(String("GTP/Basic/CameraDepth"), playerCamera, false, true, "ILLUM_TRIGGER_CAMERADEPTH");
 	
 	RenderTarget* rt = depthTexture->getBuffer().getPointer()->getRenderTarget();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCubeMapRenderingRun.cpp	(revision 2355)
@@ -18,4 +18,5 @@
 														   String selfMaterial,
 														   String environmentMaterial,
+														   String envTriggerName,
 														   bool getMinMax,
 														   RenderingRunType cubemapRunType)
@@ -25,4 +26,5 @@
 
 {
+	this->envTriggerName = envTriggerName;
 	this->getMinMax = getMinMax;
 	this->cubemapRunType = cubemapRunType;
@@ -83,5 +85,5 @@
 			if(useEnvMaterial)
 			{
-				setMaterialForVisibles(environmentMaterial, cam);
+				setMaterialForVisibles(environmentMaterial, cam, false, false, envTriggerName);
 				//sm->_queueSkiesForRendering(cam);				
 			}
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp	(revision 1930)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreColorCubeMapRenderTechnique.cpp	(revision 2355)
@@ -21,8 +21,9 @@
 														String minVariableName,
 														String maxVariableName,
+														String triggerName,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
 														OgreTechniqueGroup* parentTechniqueGroup)
-														:OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, pass, parentRenderable, parentTechniqueGroup),
+														:OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, triggerName, 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),
@@ -128,4 +129,5 @@
 												    minVariableName,
 												    maxVariableName,
+													triggerName,
 													pass,
 													parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp	(revision 1886)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreConvolvedCubeMapRenderTechnique.cpp	(revision 2355)
@@ -22,9 +22,10 @@
 														String minVariableName,
 														String maxVariableName,
+														String triggerName,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
 														OgreTechniqueGroup* parentTechniqueGroup)
 							:
-							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, pass, parentRenderable, parentTechniqueGroup),
+							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, triggerName, 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),
@@ -135,4 +136,5 @@
 												minVariableName,
 												maxVariableName,
+												triggerName,
 												pass,
 												parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp	(revision 1930)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCubeMapRenderTechnique.cpp	(revision 2355)
@@ -21,4 +21,5 @@
 														String minVariableName,
 														String maxVariableName,
+														String triggerName,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
@@ -92,4 +93,5 @@
 												selfMaterial,
 												environmentMaterial,
+												triggerName,
 												getMinMax,
 												cubemapLayer);
@@ -221,4 +223,10 @@
 		OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
 		f->attachToTexUnit =  StringConverter::parseBool(params);
+	}
+
+	void parseTriggerName(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
+		f->triggerName =  params;
 	}
 
@@ -248,4 +256,5 @@
 	this->attributeParsers.insert(AttribParserList::value_type("min_var_name", (ILLUM_ATTRIBUTE_PARSER) parseMinVarName));
 	this->attributeParsers.insert(AttribParserList::value_type("max_var_name", (ILLUM_ATTRIBUTE_PARSER) parseMaxVarName));
+	this->attributeParsers.insert(AttribParserList::value_type("trigger_name", (ILLUM_ATTRIBUTE_PARSER) parseTriggerName));
 
 }
@@ -271,4 +280,5 @@
 	minVariableName = "";
 	maxVariableName = "";
+	triggerName = "";
 
 }
@@ -302,4 +312,5 @@
 												minVariableName,
 												maxVariableName,
+												triggerName,
 												pass,
 												parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 2355)
@@ -132,5 +132,6 @@
 										true,
 										"",
-										"GameTools/DistanceShader",
+										"GTP/Basic/Distance",
+										"ILLUM_TRIGGER_DISTANCE",
 										false,										
 										ILLUMRUN_DISTANCE_CUBEMAP);
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2333)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2355)
@@ -58,14 +58,4 @@
 		Pass* newpass = techn->createPass();
 		passes.push_back(newpass);
-
-		newpass->setVertexProgram(shadowVertexProgram);
-		newpass->setFragmentProgram(shadowFragmentProgram);
-		
-		GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer();
-		Vparams->setNamedAutoConstant(WorldViewProjParamName,
-									GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);	
-		Vparams->setNamedAutoConstant(WorldParamName,
-									GpuProgramParameters::ACT_WORLD_MATRIX);
-		GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer();
 		
 		TextureUnitState* st = newpass->createTextureUnitState();		
@@ -122,8 +112,17 @@
 					depthRun->getDepthMapTextureName());
 			
-				//TODO: set matrices
+				//TODO: ask programs from illummanager
+				passes.at(i)->setVertexProgram(shadowVertexProgram);
+				passes.at(i)->setFragmentProgram(shadowFragmentProgram);
+		
 				GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters();
 				GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters();
 
+		
+				vpParams->setNamedAutoConstant(WorldViewProjParamName,
+									GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);	
+				vpParams->setNamedAutoConstant(WorldParamName,
+									GpuProgramParameters::ACT_WORLD_MATRIX);
+		
 				if(setLightViewProjMatrix)
 					vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix());
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp	(revision 2265)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp	(revision 2355)
@@ -21,9 +21,10 @@
 														String minVariableName,
 														String maxVariableName,
+														String triggerName,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
 														OgreTechniqueGroup* parentTechniqueGroup)
 							:
-							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, pass, parentRenderable, parentTechniqueGroup),
+							OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, triggerName, 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),
@@ -107,4 +108,5 @@
 	environmentMaterial = "GTP/Basic/Distance";
 	selfMaterial = "GTP/Basic/Distance";
+	triggerName = "ILLUM_TRIGGER_DISTANCE";
 	OgreCubeMapRenderTechniqueFactory::parseParams(params);	
 	parseParams(params);
@@ -129,4 +131,5 @@
 												minVariableName,
 												maxVariableName,
+												triggerName,
 												pass,
 												parentRenderable,
