Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2379)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2397)
@@ -77,4 +77,5 @@
 	*/
 	void createTechnique(IllumTechniqueParams* params, Pass* pass, OgreRenderable* rend, OgreSharedRuns* sRuns);
+	bool needMaterialCopyForTechnique(IllumTechniqueParams* params);
 	/**
 		@brief A helper function to find the renderable object attached to a particle system (ONLY BILLBOARDSETS ARE SUPPORTED).
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h	(revision 2397)
@@ -46,5 +46,5 @@
 		//inherited
 		virtual OgreRenderTechnique* asOgreRenderTechnique(){return this;}
- 				
+				
 	protected:
 		/**
@@ -112,4 +112,6 @@
 										OgreRenderable* parentRenderable,
 										OgreTechniqueGroup* parentTechniqueGroup) = 0;
+
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return false;}
 	/**
 		@brief parses parameters from the material file.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h	(revision 2397)
@@ -34,4 +34,5 @@
 	*/
 	OgreSBBRenderTechnique(	unsigned char depthTexID,
+							bool bindTexture,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -58,5 +59,5 @@
 	*/
 	unsigned char depthTexID;
-
+	bool bindTexture;
 	bool lastVisibility;
 	
@@ -79,5 +80,5 @@
 
 	unsigned char depthTexID;
-
+	bool bindTexture;
 };
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 2397)
@@ -123,4 +123,5 @@
 										OgreTechniqueGroup* parentTechniqueGroup);
 
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
 
 	unsigned long impostorUpdateInterval;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h	(revision 2397)
@@ -96,4 +96,5 @@
 										OgreTechniqueGroup* parentTechniqueGroup);
 
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
 
 	String materialName;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h	(revision 2366)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h	(revision 2397)
@@ -91,4 +91,6 @@
 										OgreTechniqueGroup* parentTechniqueGroup);
 
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
+
 	SceneBlendFactor passBlendingSRC;
 	SceneBlendFactor passBlendingDEST;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 2355)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCubeMapRenderTechnique.h	(revision 2397)
@@ -135,5 +135,6 @@
 
 	void resetParams();
-	
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
+
 	unsigned long startFrame;
 	unsigned long cubeMapUpdateInterval;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h	(revision 2366)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h	(revision 2397)
@@ -69,4 +69,5 @@
 							bool createNewPasses,
 							int startTextureUnitID,
+							bool nearestLightsFromCamera,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -144,4 +145,5 @@
 	bool createNewPasses;
 	int startTextureUnitID;
+	bool nearestLightsFromCamera;
 };
 
@@ -160,4 +162,5 @@
 										OgreTechniqueGroup* parentTechniqueGroup);
 
+	virtual bool needMaterialCopy(IllumTechniqueParams* params);
 
 	int maxlights;
@@ -176,4 +179,5 @@
 	bool createNewPasses;
 	int startTextureUnitID;
+	bool nearestLightsFromCamera;
 };
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticReceiverRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticReceiverRenderTechnique.h	(revision 2366)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticReceiverRenderTechnique.h	(revision 2397)
@@ -117,4 +117,5 @@
 										OgreTechniqueGroup* parentTechniqueGroup);
 
+	virtual bool needMaterialCopy(IllumTechniqueParams* params){return true;}
 
 	int maxcasters;
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2372)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2397)
@@ -19,5 +19,6 @@
 												SceneBlendFactor passBlendingDEST,
 												bool createNewPasses,
-												int startTextureUnitID,							
+												int startTextureUnitID,
+												bool nearestLightsFromCamera,
 												Pass* pass,
 												OgreRenderable* parentRenderable,
@@ -42,4 +43,6 @@
 	this->createNewPasses = createNewPasses;
 	this->startTextureUnitID = startTextureUnitID;
+
+	this->nearestLightsFromCamera = nearestLightsFromCamera;
 							
 	if(createNewPasses)
@@ -86,6 +89,9 @@
 {
 	LightList lights;
+	Vector3 center = OgreIlluminationManager::getSingleton().getMainCamera()->getWorldPosition();
+	if(!nearestLightsFromCamera)
+		center = ((OgreSharedRuns*) sharedRuns)->getRootPosition();
 	Root::getSingleton()._getCurrentSceneManager()->_populateLightList(
-						((OgreSharedRuns*) sharedRuns)->getRootPosition(),
+							center,
 							100000.0,
 							lights);
@@ -336,4 +342,9 @@
 		f->startTextureUnitID =  StringConverter::parseInt(params);
 	}
+	void parseNearestFromCamera(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreDepthShadowReceiverRenderTechniqueFactory* f = (OgreDepthShadowReceiverRenderTechniqueFactory*) factory;
+		f->nearestLightsFromCamera = StringConverter::parseBool(params);
+	}
 }
 
@@ -358,4 +369,5 @@
 	this->attributeParsers.insert(AttribParserList::value_type("new_passes", (ILLUM_ATTRIBUTE_PARSER) parseCreateNewPasses));
 	this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID));	
+	this->attributeParsers.insert(AttribParserList::value_type("nearest_from_camera", (ILLUM_ATTRIBUTE_PARSER) parseNearestFromCamera));	
 }
 
@@ -382,4 +394,5 @@
 	createNewPasses = true;
 	startTextureUnitID = 0;
+	nearestLightsFromCamera = true;
 	
 	parseParams(params);
@@ -401,4 +414,5 @@
 												createNewPasses,
 												startTextureUnitID,
+												nearestLightsFromCamera,
 												pass,
 												parentRenderable,
@@ -408,2 +422,12 @@
 }
 
+bool OgreDepthShadowReceiverRenderTechniqueFactory::needMaterialCopy(IllumTechniqueParams* params)
+{
+	nearestLightsFromCamera = true;
+	parseParams(params);
+	if(nearestLightsFromCamera)
+		return false;
+	else
+		 return true;
+}
+
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 2379)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 2397)
@@ -6,4 +6,5 @@
 
 OgreSBBRenderTechnique::OgreSBBRenderTechnique( unsigned char depthTexID,
+											   bool bindTexture,
 												Pass* pass,
 												OgreRenderable* parentRenderable,
@@ -14,4 +15,5 @@
 {
 	this->depthTexID = depthTexID;
+	this->bindTexture = bindTexture;
 	
 	OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);	
@@ -25,4 +27,5 @@
 	OgreIlluminationManager::getSingleton().addUpdateListener(this);
 	
+	if(bindTexture)
 	pass->getTextureUnitState(depthTexID)->setTextureName(run->getDepthTextureName());
 	
@@ -70,4 +73,9 @@
 		f->depthTexID =  StringConverter::parseUnsignedInt(params);
 	}
+	void parseBindTexture(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreSBBRenderTechniqueFactory* f = (OgreSBBRenderTechniqueFactory*) factory;
+		f->bindTexture =  StringConverter::parseBool(params);
+	}
 }
 
@@ -80,4 +88,5 @@
 	//register parsers
 	this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseDepthTexID));
+	this->attributeParsers.insert(AttribParserList::value_type("bind_texture", (ILLUM_ATTRIBUTE_PARSER) parseBindTexture));
 }
 
@@ -90,9 +99,11 @@
 	//reset parameters
 	depthTexID = 1;
-	
+	bindTexture = true;
+
 	parseParams(params);
 
 	OgreSBBRenderTechnique* result = new OgreSBBRenderTechnique(
 												depthTexID,
+												bindTexture,
 												pass,
 												parentRenderable,
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 2397)
@@ -34,5 +34,5 @@
 	this->useVParam = useVParam;
 	this->useFParam = useFParam;
-	
+		
 	//create the Particle system
 	childPSysName = parentOgreRenderable->getName() + "_small_PSYS";
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2366)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2397)
@@ -23,5 +23,4 @@
 
 	this->clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentRenderable->getName());
-	
 	Pass* passToSet = pass;
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2379)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2397)
@@ -312,4 +312,5 @@
 		OgreTechniqueGroup* group = 0;
 
+		bool materialCopied = false;
 		for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++)
 		{
@@ -323,4 +324,14 @@
 				if( techniques.size() > 0)
 				{
+					bool needMaterialCopy = false;
+
+					std::vector<IllumTechniqueParams*>::iterator it = techniques.begin();
+					std::vector<IllumTechniqueParams*>::iterator itend = techniques.end();
+					while(it!=itend)
+					{
+						needMaterialCopy = needMaterialCopy || needMaterialCopyForTechnique(*it);
+						it++;
+					}
+
 					if(rend == 0)
 					{
@@ -339,9 +350,16 @@
 						sharedruns->updateBounds();
 					}
-					String newMaterialName = mat->getName() + "_clone_" + rend->getName();
-					Material* newMat = mat->clone(newMaterialName).getPointer();
-					rend->setMaterialName(newMaterialName);
-					mat = sube->getMaterial().getPointer();
-					break;
+
+					if(needMaterialCopy)
+					{
+						String newMaterialName = mat->getName() + "_clone_" + rend->getName();
+						Material* newMat = mat->clone(newMaterialName).getPointer();
+						rend->setMaterialName(newMaterialName);
+						mat = sube->getMaterial().getPointer();
+						materialCopied = true;
+					}
+					
+					if(materialCopied)
+						break;
 				}
 			}
@@ -495,4 +513,21 @@
 	}
 }
+
+bool OgreIlluminationManager::needMaterialCopyForTechnique(IllumTechniqueParams* params)
+{
+	std::list<RenderTechniqueFactory*>::iterator it = techniqueFactories.begin();
+	std::list<RenderTechniqueFactory*>::iterator itend = techniqueFactories.end();
+			
+	while(it != itend)
+	{
+		RenderTechniqueFactory* factory = *it;
+		
+		if(factory->isType(params->getTypeName()))
+			return factory->needMaterialCopy(params);
+
+		it++;
+	}
+}
+
 void OgreIlluminationManager::preAllUpdates()
 {
