Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2333)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2379)
@@ -4,18 +4,4 @@
 #include "OgreTechniqueGroup.h"
 #include "OgreRenderable.h"
-#include "OgreColorCubeMapRenderTechnique.h"
-#include "OgreDistanceCubeMapRenderTechnique.h"
-#include "OgreConvolvedCubeMapRenderTechnique.h"
-#include "OgreCausticCasterRenderTechnique.h"
-#include "OgreCausticReceiverRenderTechnique.h"
-#include "OgreSceneCameraDepthRenderingRun.h"
-#include "OgreSBBRenderTechnique.h"
-#include "OgreDepthShadowMapRenderingRun.h"
-#include "OgreDepthShadowReceiverRenderTechnique.h"
-#include "OgreFireRenderTechnique.h"
-#include "OgreHierarchicalParticleSystemTechnique.h"
-#include "OgreIllumVolumeRenderTechnique.h"
-#include "OgrePhaseTextureRenderingRun.h"
-#include "OgrePathMapRenderTechnique.h"
 
 
@@ -680,5 +666,5 @@
 		@brief Sets the fire rendertarget - frame buffer resolution ratio
 	*/
-	void setFireRenderTargetSize(int size){FireRenderTarget::targetsize = size;}
+	inline void setFireRenderTargetSize(int size);
 
 	void freeAllResources();
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2375)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2379)
@@ -9,5 +9,5 @@
 	@brief Base class of a RenderingRun in an OGRE environment.	
 */
-class OgreRenderingRun : virtual public RenderingRun
+class OgreRenderingRun : virtual public RenderingRun, public RenderQueue::RenderableListener
 {	
 	friend class OgreIlluminationManager;
@@ -33,4 +33,6 @@
 	*/
 	OgreRenderingRun* asOgreRenderingRun(){return this;}
+	//inherited
+	bool  renderableQueued (Renderable *rend, uint8 groupID, ushort priority, Technique **ppTech){return true;}
 
 protected:
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreSceneCameraDepthRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreSceneCameraDepthRenderingRun.h	(revision 2320)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreSceneCameraDepthRenderingRun.h	(revision 2379)
@@ -40,4 +40,7 @@
 
 	void freeAllResources();
+
+	bool  renderableQueued (Renderable *rend, uint8 groupID, ushort priority, Technique **ppTech);
+
 	
 protected:
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 2320)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 2379)
@@ -66,4 +66,6 @@
 	void freeAllResources();
 
+	bool  renderableQueued (Renderable *rend, uint8 groupID, ushort priority, Technique **ppTech);
+
 protected:	
 	/**
@@ -100,4 +102,5 @@
 	Texture* blurredDepthMapTexture;
 	Real lightFarPlane;
+	String triggerName;
 	
 	//inherited
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2375)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2379)
@@ -43,8 +43,8 @@
 				if(triggerName != "")//we have a trigger here
 				{
-					OgreTechniqueGroup* tg = (OgreTechniqueGroup*)rend->getRenderTechniqueGroup();
-					if(tg)
+					OgreTechniqueGroup* TG = (OgreTechniqueGroup*)rend->getRenderTechniqueGroup();
+					if(TG)
 					{
-						String triggeredMaterial = tg->getMaterialNameForTrigger(triggerName);
+						String triggeredMaterial = TG->getMaterialNameForTrigger(triggerName);
 						if(triggeredMaterial != "")//a trigger is associated
 							materialToSet = triggeredMaterial;
@@ -69,9 +69,11 @@
 				if(triggerName != "")//we have a trigger here
 				{
-					String triggeredMaterial = 
-						((OgreTechniqueGroup*)rend->getRenderTechniqueGroup())
-							->getMaterialNameForTrigger(triggerName);
-					if(triggeredMaterial != "")//a trigger is associated
-						materialToSet = triggeredMaterial;
+					OgreTechniqueGroup* TG = (OgreTechniqueGroup*)rend->getRenderTechniqueGroup();
+					if(TG)
+					{
+						String triggeredMaterial = TG->getMaterialNameForTrigger(triggerName);
+						if(triggeredMaterial != "")//a trigger is associated
+							materialToSet = triggeredMaterial;
+					}
 				}				
 				rend->setMaterialName(materialToSet);
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2375)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2379)
@@ -75,33 +75,33 @@
 }
 
+bool  OgreDepthShadowMapRenderingRun::renderableQueued (Renderable *rend, uint8 groupID, ushort priority, Technique **ppTech)
+{
+	OgreTechniqueGroup* TG = (OgreTechniqueGroup*) rend->getRenderTechniqueGroup();
+	if(TG)
+	{
+		String materialToSet = materialName;
+		String triggeredMaterial = TG->getMaterialNameForTrigger(triggerName);
+		if(triggeredMaterial != "")//a trigger is associated
+			materialToSet = triggeredMaterial;
+		Technique* techn = ((Material*)MaterialManager::getSingleton().getByName(	materialToSet ).getPointer())->getTechnique(0);
+		*ppTech = techn;	
+	}
+	return true;
+}
+
 void OgreDepthShadowMapRenderingRun::updateFrame(unsigned long frameNum)
 {
 	refreshLight(frameNum);
 
+	RenderQueue* rq = Root::getSingleton()._getCurrentSceneManager()->getRenderQueue();		
+	rq->setRenderableListener(this);
+
 	if(light->getType() == Light::LT_POINT)
-	{
-		//static int currentFace = 0;
-		//updateDepthCubeFace(currentFace);
-		//currentFace = (currentFace+1)%6;
+	{		
 		
-
-		//Timer* t = Root::getSingleton().getTimer();
-		//unsigned long  start =  t->getMicroseconds();		
-		//setMaterialForRenderables(materialName, true);				
-		//unsigned long  end =  t->getMicroseconds();
-		//double elapsed = (double) (end - start) / 1000.0;
-		//LogManager::getSingleton().logMessage(String("MaterialSetTime: ") + name + " : " + StringConverter::toString(Real(elapsed)) + " ms");
-		//visibleObjects.clear();
-
 		for(int i = 0; i < 6 ; i++)
-			updateDepthCubeFace(i);
-
-		//start =  t->getMicroseconds();
-		
-		restoreMaterials();
-
-		//end =  t->getMicroseconds();
-		//elapsed = (double) (end - start) / 1000000.0;
-		//LogManager::getSingleton().logMessage(String("MaterialRestoreTime: ") + name + " : " +  StringConverter::toString(Real(elapsed)) + " ms");	
+			updateDepthCubeFace(i);		
+
+		//restoreMaterials();
 	}
 	else
@@ -109,4 +109,6 @@
 		updateDepthMap();
 	}	
+
+	rq->setRenderableListener(0);
 }
 
@@ -114,5 +116,4 @@
 {	
 	Vector3 lightpos = light->getDerivedPosition();			
-	String triggerName = "ILLUM_TRIGGER_SM_POINT";	
 		
 	RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();	
@@ -122,5 +123,5 @@
 	
 	
-	setMaterialForVisibles(materialName, cam, true, false, triggerName);
+	//setMaterialForVisibles(materialName, cam, true, false, triggerName);
 	
 	rt->update();
@@ -144,20 +145,13 @@
 void OgreDepthShadowMapRenderingRun::updateDepthMap()
 {
-	String triggerName;
-	switch(light->getType())
-	{
-	case Light::LT_DIRECTIONAL:
-		triggerName = "ILLUM_TRIGGER_SM_DIRECTIONAL";
-		break;
-	case Light::LT_SPOTLIGHT:
-		triggerName = "ILLUM_TRIGGER_SM_SPOT";
-		break;	
-	}
-	setMaterialForVisibles(materialName, depthMapCamera, true, false, triggerName);	
+	
 	RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget();	
 	Viewport* vp = rt->getViewport(0);
 	
+	//setMaterialForVisibles(materialName, depthMapCamera, true, false, triggerName);	
+	
 	rt->update();
-	restoreMaterials();
+	
+	//restoreMaterials();
 	
 	if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
@@ -184,5 +178,4 @@
 void OgreDepthShadowMapRenderingRun::refreshLight(unsigned long frameNum)
 {
-	
 	if(light!= 0)
 	{
@@ -191,4 +184,5 @@
 		if(light->getType() == Light::LT_DIRECTIONAL)
 		{
+			triggerName = "ILLUM_TRIGGER_SM_DIRECTIONAL";
 			Camera* viewcam = OgreIlluminationManager::getSingleton().getMainCamera();			
 			
@@ -296,4 +290,5 @@
 		else if(light->getType() == Light::LT_SPOTLIGHT)
 		{
+			triggerName = "ILLUM_TRIGGER_SM_SPOT";
 			Camera* viewcam = OgreIlluminationManager::getSingleton().getMainCamera();			
 			
@@ -428,4 +423,5 @@
 		{
 			lightFarPlane = light->getAttenuationRange();
+			triggerName = "ILLUM_TRIGGER_SM_POINT";		
 			//no other adjustment needed			
 		}
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 2355)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 2379)
@@ -1,3 +1,4 @@
 #include "OgreSceneCameraDepthRenderingRun.h"
+#include "OgreTechniqueGroup.h"
 
 
@@ -40,9 +41,29 @@
 }
 
+bool  OgreSceneCameraDepthRenderingRun::renderableQueued (Renderable *rend, uint8 groupID, ushort priority, Technique **ppTech)
+{
+	if((*ppTech)->isTransparent())
+		return false;
+
+	OgreTechniqueGroup* TG = (OgreTechniqueGroup*) rend->getRenderTechniqueGroup();
+	if(TG)
+	{
+		String materialToSet = String("GTP/Basic/CameraDepth");
+		String triggeredMaterial = TG->getMaterialNameForTrigger("ILLUM_TRIGGER_CAMERADEPTH");
+		if(triggeredMaterial != "")//a trigger is associated
+			materialToSet = triggeredMaterial;
+		Technique* techn = ((Material*)MaterialManager::getSingleton().getByName(	materialToSet ).getPointer())->getTechnique(0);
+		*ppTech = techn;	
+	}
+	return true;
+}
+
 void OgreSceneCameraDepthRenderingRun::updateFrame(unsigned long frameNum)
 {
 	
-	setMaterialForVisibles(String("GTP/Basic/CameraDepth"), playerCamera, false, true, "ILLUM_TRIGGER_CAMERADEPTH");
-	
+	//setMaterialForVisibles(String("GTP/Basic/CameraDepth"), playerCamera, false, true, "ILLUM_TRIGGER_CAMERADEPTH");
+	RenderQueue* rq = Root::getSingleton()._getCurrentSceneManager()->getRenderQueue();		
+	rq->setRenderableListener(this);
+
 	RenderTarget* rt = depthTexture->getBuffer().getPointer()->getRenderTarget();
 
@@ -60,7 +81,8 @@
 	//rt->writeContentsToFile("cameraDepth.bmp");
 	
-	restoreMaterials();
+	//restoreMaterials();
 
 	sharedRuns->getRoot()->restoreVisibility();
+	rq->setRenderableListener(0);
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp	(revision 2320)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp	(revision 2379)
@@ -2,4 +2,5 @@
 #include "OgreTechniqueGroup.h"
 #include "OgreIlluminationManager.h"
+#include "OgreSceneCameraDepthRenderingRun.h"
 
 int FireRenderTarget::targetsize = 2;
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 2379)
@@ -2,4 +2,5 @@
 #include "OgreTechniqueGroup.h"
 #include "OgreIlluminationManager.h"
+#include "OgreSceneCameraDepthRenderingRun.h"
 
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp	(revision 2320)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp	(revision 2379)
@@ -1,4 +1,5 @@
 #include "..\include\OgreSharedRuns.h"
 #include "OgreIlluminationManager.h"
+#include "OgreRenderingRun.h"
 
 void OgreSharedRuns::freeAllResources()
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2366)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2379)
@@ -6,4 +6,19 @@
 #include "OgrePMWeightComputeRenderingRun.h"
 #include "OgreTriggersRenderTechnique.h"
+#include "OgreColorCubeMapRenderTechnique.h"
+#include "OgreDistanceCubeMapRenderTechnique.h"
+#include "OgreConvolvedCubeMapRenderTechnique.h"
+#include "OgreCausticCasterRenderTechnique.h"
+#include "OgreCausticReceiverRenderTechnique.h"
+#include "OgreSceneCameraDepthRenderingRun.h"
+#include "OgreSBBRenderTechnique.h"
+#include "OgreDepthShadowMapRenderingRun.h"
+#include "OgreDepthShadowReceiverRenderTechnique.h"
+#include "OgreFireRenderTechnique.h"
+#include "OgreHierarchicalParticleSystemTechnique.h"
+#include "OgreIllumVolumeRenderTechnique.h"
+#include "OgrePhaseTextureRenderingRun.h"
+#include "OgrePathMapRenderTechnique.h"
+
 
 OgreIlluminationManager* OgreIlluminationManager::instance = NULL;
@@ -787,2 +802,7 @@
 }
 
+void OgreIlluminationManager::setFireRenderTargetSize(int size)
+{
+	FireRenderTarget::targetsize = size;
+}
+
