Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 2333)
@@ -130,5 +130,7 @@
 		@brief Size of the shadow maps.
 	*/
-	unsigned int shadowMapSize;
+	unsigned int shadowMapSizePoint;
+	unsigned int shadowMapSizeSpot;
+	unsigned int shadowMapSizeDirectional;
 	/**
 		@brief Size of area lights for soft shadows.
@@ -138,5 +140,7 @@
 		@brief Sets if light space perspective shadow mapping should be used.
 	*/
-	bool useLISPSM;
+	bool useLISPSMPoint;
+	bool useLISPSMSpot;
+	bool useLISPSMDirectional;
 	/**
 		@brief Sets if the shadow maps should be blurred.
@@ -144,9 +148,13 @@
 		Used in variance shadow mapping.
 	*/
-	bool blurSM;
+	bool blurSMPoint;
+	bool blurSMSpot;
+	bool blurSMDirectional;
 	/**
 		@brief Sets if shadow maps should be focused.
 	*/
-	bool focusingSM;
+	bool focusingSMPoint;
+	bool focusingSMSpot;
+	bool focusingSMDirectional;
 	/**
 		@brief The material name that should be used during rendering the shadow maps.
@@ -166,5 +174,7 @@
 		 - directional lights : GTP/Basic/Depth or GTP/Basic/DepthCCW
 	*/
-	String shadowMapMaterialName;
+	String shadowMapMaterialNamePoint;
+	String shadowMapMaterialNameSpot;
+	String shadowMapMaterialNameDirectional;
 	/**
 		@brief Size of the phase texture.
@@ -241,5 +251,9 @@
 	std::vector<UpdateListener*> updateListeners;
 
+	bool joinRuns;
+
 public:
+
+	void joinSharedRuns(bool join){joinRuns = join;}
 	/**
 		@brief Registers an UpdateListener instance. @see UpdateListener
@@ -296,5 +310,22 @@
 		@see shadowMapSize
 	*/
-	void setShadowMapSize(unsigned int size){shadowMapSize = size;}
+	void setShadowMapSize(unsigned int size)
+	{
+		shadowMapSizeDirectional = size;
+		shadowMapSizePoint = size;
+		shadowMapSizeSpot = size;
+	}
+	void setShadowMapSize(Light::LightTypes type, unsigned int size)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+				shadowMapSizeDirectional = size;break;
+			case Light::LT_POINT:
+				shadowMapSizePoint = size;break;
+			case Light::LT_SPOTLIGHT:
+				shadowMapSizeSpot = size;break;
+		}
+	}
 	/**
 		@brief Returns the one and only OgreIlluminationManager instance.
@@ -454,29 +485,130 @@
 		@see useLISPSM
 	*/
-	bool getUseLISPSM(){return useLISPSM;}
+	bool getUseLISPSM(Light::LightTypes type)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+			return useLISPSMDirectional;
+			case Light::LT_POINT:
+			return useLISPSMPoint;
+			case Light::LT_SPOTLIGHT:
+			return useLISPSMSpot;
+		}
+	}
 	/**
 		@see focusingSM
 	*/
-	bool getFocusingShadowMap(){return focusingSM;}
+	bool getFocusingShadowMap(Light::LightTypes type)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+			return focusingSMDirectional;
+			case Light::LT_POINT:
+			return focusingSMPoint;
+			case Light::LT_SPOTLIGHT:
+			return focusingSMSpot;
+		}
+	}
 	/**
 		@see blurSM
 	*/
-	bool getBlurShadowMap(){return blurSM;}
+	bool getBlurShadowMap(Light::LightTypes type)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+			return blurSMDirectional;
+			case Light::LT_POINT:
+			return blurSMPoint;
+			case Light::LT_SPOTLIGHT:
+			return blurSMSpot;
+		}
+	}
 	/**
 		@see useLISPSM
 	*/
-	void setUseLISPSM(bool use){useLISPSM = use;}
+	void setUseLISPSM(bool use)
+	{
+		useLISPSMDirectional = use;
+		useLISPSMPoint = use;
+		useLISPSMSpot = use;
+	}
+	void setUseLISPSM(Light::LightTypes type, bool use)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+				useLISPSMDirectional = use;break;
+			case Light::LT_POINT:
+				useLISPSMPoint = use;break;
+			case Light::LT_SPOTLIGHT:
+				useLISPSMSpot = use;break;
+		}
+	}
 	/**
 		@see focusingSM
 	*/
-	void setFocusingSM(bool use){focusingSM = use;}
+	void setFocusingSM(bool use)
+	{
+		focusingSMDirectional = use;
+		focusingSMPoint = use;
+		focusingSMSpot = use;
+	}
+	void setFocusingSM(Light::LightTypes type, bool use)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+				focusingSMDirectional = use;break;
+			case Light::LT_POINT:
+				focusingSMPoint = use;break;
+			case Light::LT_SPOTLIGHT:
+				focusingSMSpot = use;break;
+		}
+	}
 	/**
 		@see blurSM
 	*/
-	void setBlurShadowMap(bool use){blurSM = use;}
+	void setBlurShadowMap(bool use)
+	{
+		blurSMDirectional = use;
+		blurSMPoint = use;
+		blurSMSpot = use;
+	}
+	void setBlurShadowMap(Light::LightTypes type, bool use)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+				blurSMDirectional = use;break;
+			case Light::LT_POINT:
+				blurSMPoint = use;break;
+			case Light::LT_SPOTLIGHT:
+				blurSMSpot = use;break;
+		}
+	}
 	/**
 		@see shadowMapMaterialName
 	*/
-	void setShadowMapMaterialName(String name){shadowMapMaterialName = name;}
+	void setShadowMapMaterialName(String name)
+	{
+		shadowMapMaterialNameDirectional = name;
+		shadowMapMaterialNamePoint = name;
+		shadowMapMaterialNameSpot = name;
+	}
+	void setShadowMapMaterialName(Light::LightTypes type, String name)
+	{
+		switch(type)
+		{
+			case Light::LT_DIRECTIONAL:
+				shadowMapMaterialNameDirectional = name;break;
+			case Light::LT_POINT:
+				shadowMapMaterialNamePoint = name;break;
+			case Light::LT_SPOTLIGHT:
+				shadowMapMaterialNameSpot = name;break;
+		}
+	}
 	/**
 		@brief Registers a PathMapClusters structure for a given subentity.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 2333)
@@ -22,6 +22,5 @@
 						:RenderingRun(startFrame, updateInterval)
 	{
-		pixelSprites = 0;
-		fullscreenGrid = 0;
+		
 	}
 	
@@ -69,5 +68,5 @@
 		@see renderPixelSprites
 	*/
-	BillboardSet* pixelSprites;
+	static BillboardSet* pixelSprites;
 	/**
 		@brief Entity used in fullscreen grid rendering
@@ -75,5 +74,5 @@
 		@see renderPixelGrid
 	*/
-	Entity* fullscreenGrid;
+	static Entity* fullscreenGrid;
 	/**
 		@brief unique name of the SpriteSet used in pixel sprite rendering
@@ -81,5 +80,5 @@
 		@see renderPixelSprites
 	*/
-	String spriteSetName;
+	static String spriteSetName;
 	/**
 		@brief Returns a direction for a cubemap face id.
@@ -147,5 +146,5 @@
 		@param target the RenderTarget the quad should be rendered on
 	*/
-	void renderFullscreenQuad(String materialName, RenderTarget* target);
+	static void renderFullscreenQuad(String materialName, RenderTarget* target);
 	/**
 		@brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material.
@@ -161,5 +160,5 @@
 		@param height the desired resolution height of the sprites
 	*/
-	void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height);
+	static void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height);
 	/**
 		@brief Renders a grid onto the screen.
@@ -169,4 +168,4 @@
 		@param height the desired vertical resolution of the grid
 	*/
-	void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);	
+	static void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);	
 };
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h	(revision 2333)
@@ -35,9 +35,10 @@
 		@brief returns the name of the weight texture
 	*/
-	String getPMWeightTetureName(){return weightTexture->getName();}
+	static String getPMWeightTextureName(){return weightTexture->getName();}
 	//not used
 	float* getWeights(){return weights;}
 
 	void freeAllResources();
+	static void sumWeights(unsigned long frameNum);
 	
 protected:
@@ -57,5 +58,5 @@
 		@brief a pointer to the weight texture that was created by this run
 	*/
-	Texture* weightTexture;
+	static Texture* weightTexture;
 	/**
 		@brief A pointer to a texture that stores weights for all the entry point.
@@ -63,5 +64,5 @@
 		This texture will be used to determine the weights of the clusters.
 	*/
-	Texture* allWeightsTexture;
+	static Texture* allWeightsTexture;
 	/**
 		@brief A pointer to the light source.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj	(revision 2285)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj	(revision 2333)
@@ -91,6 +91,6 @@
 			<Tool
 				Name="VCLibrarianTool"
-				AdditionalDependencies="IllumModule.lib OgreMain.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib"
-				AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;..\..\..\..\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;"/>
+				AdditionalDependencies="IllumModule.lib OgreMain.lib"
+				AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;"/>
 			<Tool
 				Name="VCMIDLTool"/>
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2265)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 2333)
@@ -5,4 +5,7 @@
 Entity* OgreRenderingRun::fullScreenQuadEntity = NULL;
 SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL;
+BillboardSet* OgreRenderingRun::pixelSprites = NULL;
+Entity* OgreRenderingRun::fullscreenGrid = NULL;
+String OgreRenderingRun::spriteSetName = "";
 
 class MaterialSetVisitor : public QueuedRenderableVisitor
@@ -231,5 +234,5 @@
 	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
 	
-	if(this->fullscreenGrid == NULL)
+	if(fullscreenGrid == NULL)
 	{
 		MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp	(revision 2333)
@@ -238,5 +238,5 @@
 		else
 		{			
-			Vector3 pos = light->getParentSceneNode()->getPosition();
+			Vector3 pos = light->getDerivedPosition();
 			Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos;
 			dir.normalise();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp	(revision 2333)
@@ -4,4 +4,7 @@
 #include "OgreDepthShadowMapRenderingRun.h"
 
+Texture* OgrePMWeightComputeRenderingRun::weightTexture = 0;
+Texture* OgrePMWeightComputeRenderingRun::allWeightsTexture = 0;
+
 OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName)
 														   : OgreRenderingRun(1, 1)
@@ -19,46 +22,50 @@
 void OgrePMWeightComputeRenderingRun::createWeightMap()
 {
-	
-	unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size();
-	int width = entryPointCnt / 4096;
-	int height = 4096;
-	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 
-																		"default",
-																		TEX_TYPE_2D,
-																		width,
-																		height,
-																		0,
-																		0,
-																		PF_FLOAT32_R,
-																		TU_RENDERTARGET);
-	 allWeightsTexture = texPtr.getPointer();
-	 //add viewport to rendertarget
-	 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer();
-	 RenderTarget* rt = hpb->getRenderTarget();
-	 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 
-	 Viewport* v = rt->addViewport(wc);
-	 v->setOverlaysEnabled(false);
-	 rt->setAutoUpdated(false);
-
-	unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
-	width = clustercount;
-	height = 1;
-	texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
-																"default",
-																TEX_TYPE_2D,
-																width,
-																height,
-																0,
-																0,
-																PF_FLOAT32_R,
-																TU_RENDERTARGET);
-	 weightTexture = texPtr.getPointer();
-	 //add viewport to rendertarget
-	 hpb = (weightTexture->getBuffer()).getPointer();
-	 rt = hpb->getRenderTarget();
-	 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 
-	 v = rt->addViewport(wc);
-	 v->setOverlaysEnabled(false);
-	 rt->setAutoUpdated(false);
+	if(allWeightsTexture == 0)
+	{
+		unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size();
+		int width = entryPointCnt / 4096;
+		int height = 4096;
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 
+																			"default",
+																			TEX_TYPE_2D,
+																			width,
+																			height,
+																			0,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);
+		allWeightsTexture = texPtr.getPointer();
+		//add viewport to rendertarget
+		HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget();
+		Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 
+		Viewport* v = rt->addViewport(wc);
+		v->setBackgroundColour(ColourValue::Black);
+		v->setClearEveryFrame(false);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);
+
+		unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
+		width = clustercount;
+		height = 1;
+		texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
+																	"default",
+																	TEX_TYPE_2D,
+																	width,
+																	height,
+																	0,
+																	0,
+																	PF_FLOAT16_RGBA,
+																	TU_RENDERTARGET);
+		weightTexture = texPtr.getPointer();
+		//add viewport to rendertarget
+		hpb = (weightTexture->getBuffer()).getPointer();
+		rt = hpb->getRenderTarget();
+		wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 
+		v = rt->addViewport(wc);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);		
+	}
 }
 
@@ -83,7 +90,7 @@
 		GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
 			
-			Vector3 lightPos = light->getPosition();
-			Vector3 lightDir = light->getDirection();
-		//	Radian lightAngle = light->getSpotlightOuterAngle();
+			Vector3 lightPos = light->getDerivedPosition();
+			Vector3 lightDir = light->getDerivedDirection();
+			Radian lightAngle = light->getSpotlightOuterAngle();
 			
 			Fparams->setNamedConstant("nRadionColumns", col);
@@ -91,6 +98,13 @@
 			Fparams->setNamedConstant("lightDir", lightDir);
 			Fparams->setNamedConstant("lightPower", light->getPowerScale());
+			Fparams->setNamedConstant("lightColor", light->getDiffuseColour());
 			Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix());
 			Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane());
+			Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(),
+																	light->getAttenuationConstant(),
+																	light->getAttenuationLinear(),
+																	light->getAttenuationQuadric()));
+			Fparams->setNamedConstant("lightAngleCos", Math::Cos(lightAngle.valueRadians()/2.0));			
+			Fparams->setNamedConstant("spotLightFalloff", light->getSpotlightFalloff());			
 			
 			mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(
@@ -100,50 +114,66 @@
 				
 			RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget();
-			renderFullscreenQuad(mat->getName(), rt);
+			if(frameNum != rt->getLastFrameNumber())
+				rt->getViewport(0)->setClearEveryFrame(true);
+			else
+				rt->getViewport(0)->setClearEveryFrame(false);
+			
+				renderFullscreenQuad(mat->getName(), rt);
+			
 
 		//	rt->writeContentsToFile("allweights.bmp");
 		//	rt->writeContentsToFile("allweights.dds");
-			
-		/*	float* allweights = new float[entryPointCnt / 4096 * 4096];
-			PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights);
-			allWeightsTexture->getBuffer()->blitToMemory(lockBox);
-
-			///////////////////DEBUG
-			static BillboardSet* entryPointBBSet = 0;
-			if(entryPointBBSet == 0)
-			{
-				SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
-				entryPointBBSet = sm->createBillboardSet("PATHMAP_ENTRYPOINTS", entryPointCnt);
-				entryPointBBSet->setBillboardType(BBT_POINT);
-				entryPointBBSet->setBillboardsInWorldSpace(true);
-				entryPointBBSet->setPointRenderingEnabled(true);
-				for(unsigned int i = 0; i < entryPointCnt; i++)
-				{
-					PathMapEntryPoint EP = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i);
-					Vector3 billboardPosition = EP.position;
-					
-					float uCoord = allweights[i];
-					float  vCoord = 0;
-					//float uCoord = ((float) (i % col) + 0.5f) / (float) col;
-					//float vCoord = ((float)(i / col) + 0.5f) / 4096.0f;
-					entryPointBBSet->createBillboard(billboardPosition, ColourValue(uCoord, vCoord, 0, 0));
-				}
-				entryPointBBSet->setMaterialName("GTP/PM/EPBillboards");
-				MaterialPtr mater = MaterialManager::getSingleton().getByName("GTP/PM/EPBillboards");
-				mater->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(allWeightsTexture->getName());
-				sm->getRootSceneNode()->createChildSceneNode()->attachObject(entryPointBBSet);
-			}
-
-			delete[] allweights;*/
-
-/////////////////
+
 	}
-	else
+	else if(light->getType() == Light::LT_POINT)
 	{
-		///not implemented
+		OgreIlluminationManager::getSingleton().createPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP);
+		OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP, frameNum);
+		OgreDepthShadowMapRenderingRun* SMrun = (OgreDepthShadowMapRenderingRun*) OgreIlluminationManager::getSingleton()
+			.getPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun(); 
+		
+		MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights_Point");
+		GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
+			
+			Vector3 lightPos = light->getDerivedPosition();
+			
+			Fparams->setNamedConstant("nRadionColumns", col);
+			Fparams->setNamedConstant("lightPos", lightPos);
+			Fparams->setNamedConstant("lightPower", light->getPowerScale());
+			Fparams->setNamedConstant("lightColor", light->getDiffuseColour());
+			Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane());
+			Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(),
+																	light->getAttenuationConstant(),
+																	light->getAttenuationLinear(),
+																	light->getAttenuationQuadric()));
+
+			mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(
+						PMEPrun->getEntryPointTextureName());
+			mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName(
+						SMrun->getDepthMapTextureName());
+				
+			RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget();
+			if(frameNum != rt->getLastFrameNumber())
+				rt->getViewport(0)->setClearEveryFrame(true);
+			else
+				rt->getViewport(0)->setClearEveryFrame(false);
+			
+				renderFullscreenQuad(mat->getName(), rt);
+			
 	}
 
+}
+
+void OgrePMWeightComputeRenderingRun::sumWeights(unsigned long frameNum)
+{
+	RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();
+	if(frameNum == rt->getLastFrameNumber())return;
+	
+	unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size();
+	int col = entryPointCnt / 4096; 
 	unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
-
+	OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*)
+	OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun();
+	
 	MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights");
 	GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
@@ -157,15 +187,5 @@
 						allWeightsTexture->getName());
 	
-	RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();
 	renderFullscreenQuad(mat->getName(), rt);
-
-	//rt->writeContentsToFile("weights.bmp");	
-	//rt->writeContentsToFile("weights.dds");
-/*
-	float* weights = new float[clustercount];
-	PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights);
-	weightTexture->getBuffer()->blitToMemory(lockBox);
-
-	delete[] weights;*/
 }
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp	(revision 2333)
@@ -100,5 +100,5 @@
 		if(light->getType() == Light::LT_DIRECTIONAL)
 		{
-			Vector3 dir = light->getDirection();
+			Vector3 dir = light->getDerivedDirection();
 			photonMapCamera->setDirection( dir );
 			Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
@@ -113,5 +113,5 @@
 		else
 		{			
-			Vector3 pos = light->getParentSceneNode()->getPosition();
+			Vector3 pos = light->getDerivedPosition();
 			Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos;
 			Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2333)
@@ -26,4 +26,12 @@
 void OgreDepthShadowMapRenderingRun::createDepthMap()
 {
+	if(light->getType() == Light::LT_POINT)
+	{
+		depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White);
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
+		blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White);
+	}
+	else
+	{
 	
 		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
@@ -46,5 +54,5 @@
 		rt->setAutoUpdated(false);
 		
-		if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 		{
 			texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, 
@@ -64,4 +72,5 @@
 			rt->setAutoUpdated(false);
 		}
+	}
 }
 
@@ -72,5 +81,10 @@
 	if(light->getType() == Light::LT_POINT)
 	{
-		updateDepthMap();
+		//static int currentFace = 0;
+		//updateDepthCubeFace(currentFace);
+		//currentFace = (currentFace+1)%6;
+
+		for(int i = 0; i < 6 ; i++)
+			updateDepthCubeFace(i);
 	}
 	else
@@ -82,4 +96,28 @@
 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum)
 {
+	Vector3 lightpos = light->getDerivedPosition();			
+	
+	RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();	
+	Camera*  cam = 	rt->getViewport(0)->getCamera();
+	cam->setPosition(lightpos);	
+	cam->setFarClipDistance(lightFarPlane);
+
+	setMaterialForVisibles(materialName, cam, false);
+	rt->update();
+	restoreMaterials();
+
+	//rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds");
+
+	if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
+	{
+		rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();
+		Material*  mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer();
+		mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName());
+		mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum);
+		renderFullscreenQuad("GameTools/BlurCubeFace", rt);		
+		
+		//rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds");
+	}
+	
 }
 
@@ -93,5 +131,5 @@
 	restoreMaterials();
 	
-	if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+	if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 	{
 		rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget();
@@ -108,5 +146,5 @@
 const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName()
 {
-		if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 			return blurredname;
 
@@ -119,6 +157,6 @@
 	if(light!= 0)
 	{
-		bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM();
-		bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap();
+		bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType());
+		bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType());
 		if(light->getType() == Light::LT_DIRECTIONAL)
 		{
@@ -129,6 +167,6 @@
 			frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix());
 
-			Vector3 lightpos = light->getParentSceneNode()->getWorldPosition();
-			Vector3 lightdir = light->getDirection();
+			Vector3 lightpos = light->getDerivedPosition();
+			Vector3 lightdir = light->getDerivedDirection();
 			lightdir.normalise();		
 			
@@ -234,6 +272,6 @@
 			frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix());
 
-			Vector3 lightpos = light->getParentSceneNode()->getWorldPosition ();
-			Vector3 lightdir = light->getDirection();
+			Vector3 lightpos = light->getDerivedPosition();
+			Vector3 lightdir = light->getDerivedDirection();
 			lightdir.normalise();		
 			Radian lightangle = light->getSpotlightOuterAngle();
@@ -359,22 +397,6 @@
 		else//point light
 		{
-	/*		Vector3 pos = light->getParentNode()->getWorldPosition();
-			Vector3 dir = -pos;
-			depthMapCamera->setDirection( dir );
-			depthMapCamera->setPosition(pos);
-			depthMapCamera->setProjectionType(PT_PERSPECTIVE);
-			depthMapCamera->setFOVy(Radian(Degree(140)));
-			depthMapCamera->setNearClipDistance(1);
-			// depthMapCamera->setFarClipDistance(200);
-	
-			//OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight");
-		*/	
-			/*Vector3 pos = light->getParentNode()->getWorldPosition();
-			Vector3 dir = -pos;
-			depthMapCamera->setDirection( dir );
-			depthMapCamera->setPosition(pos);
-			depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);
-			depthMapCamera->*/
-			
+			lightFarPlane = light->getAttenuationRange();
+			//no other adjustment needed			
 		}
 	}
@@ -383,10 +405,18 @@
 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix()
 {
-	return depthMapCamera->getViewMatrix();
+	Camera* cam = depthMapCamera;
+	if(light->getType() == Light::LT_POINT)
+	 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();	
+	
+	return cam->getViewMatrix();
 }
 
 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix()
 {
-	return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix();
+	Camera* cam = depthMapCamera;
+	if(light->getType() == Light::LT_POINT)
+	 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();	
+	
+	return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix();
 }
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2299)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp	(revision 2333)
@@ -125,6 +125,5 @@
 				GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters();
 				GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters();
-			
-				//fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 
+
 				if(setLightViewProjMatrix)
 					vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix());
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2299)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2333)
@@ -63,5 +63,5 @@
 	TextureUnitState* st = newpass->createTextureUnitState();		
 	st->setTextureFiltering(TFO_BILINEAR);
-	st->setTextureAddressingMode(TextureUnitState::TAM_BORDER);
+	st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
 	st->setTextureBorderColour(ColourValue::Green);
 	st->setTextureName(clusters->pathMapTextureFilename);
@@ -71,5 +71,5 @@
 	st = newpass->createTextureUnitState();		
 	st->setTextureFiltering(TFO_NONE);
-	st->setTextureAddressingMode(TextureUnitState::TAM_BORDER);
+	st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
 	st->setTextureBorderColour(ColourValue::Red);
 	st->setTextureName(weightIndexTexture->getName());
@@ -77,5 +77,5 @@
 	st = newpass->createTextureUnitState();		
 	st->setTextureFiltering(TFO_NONE);
-	st->setTextureAddressingMode(TextureUnitState::TAM_BORDER);
+	st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
 	st->setTextureBorderColour(ColourValue::Blue);
 
@@ -122,39 +122,18 @@
 	LightList lights;
 	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
-	sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO
-//TODO set weights
-	/*
-	unsigned int entryPointCount = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size();
-	PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName());
-	int weightTextureWidth = clusters->count / 4;
-	*/
-	for(int i = 0 ; i < 1; i++)
-	{
-		String lightName = lights.at(0)->getName();
+	sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getPosition(), 1000, lights);
+
+	for(int i = 0 ; i < 5 && i < lights.size(); i++)
+	{
+		String lightName = lights.at(i)->getName();
 		OgreIlluminationManager::getSingleton().createPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP);
-		OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum);
-		OgrePMWeightComputeRenderingRun* PMWeightRun = (OgrePMWeightComputeRenderingRun*)
-			OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun();
-
-		TextureUnitState* st = pathMapPass->getTextureUnitState(2);
-		st->setTextureName(PMWeightRun->getPMWeightTetureName());
-
-		/*
-		TexturePtr tex = TextureManager::getSingleton().getByName(PMWeightRun->getPMWeightTetureName());
-		float *allClusterWeights = new float[entryPointCount];
-		PixelBox lockBox(entryPointCount, 1, 1, PF_FLOAT32_R, allClusterWeights);
-		tex->getBuffer()->blitToMemory(lockBox);
-
-		float *weightIndices = new float[clusters->count];
-		for(int j = 0; j< clusters->count; j++)
-			weightIndices[j] = allClusterWeights[clusters->clusters[j]];
-		
-		PixelBox lockBox2(weightTextureWidth, 1, 1, PF_FLOAT32_RGBA, weightIndices);
-		weightIndexTexture->getBuffer()->blitFromMemory(lockBox2);
-
-		TextureUnitState* st = pathMapPass->getTextureUnitState(1);
-		st->setTextureName(weightIndexTexture->getName());	*/			
+		OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum);		
 	}
-}
+	OgrePMWeightComputeRenderingRun::sumWeights(frameNum);
+	TextureUnitState* st = pathMapPass->getTextureUnitState(2);
+	st->setTextureName(OgrePMWeightComputeRenderingRun::getPMWeightTextureName());
+}
+
+
 
 namespace PathMapParsers
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2320)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 2333)
@@ -79,13 +79,15 @@
 {
 	visitor = new VisibleFinderVisitor(&visibleObjects);
+	joinRuns = true;
 	maxRad = 400;
 	focusingMapSize = 32;
-	shadowMapSize = 512;
 	phaseTextureSize = 256;
-	useLISPSM = false;
-//	useVSM = false;
-	blurSM = false;
-	focusingSM = true;
-	shadowMapMaterialName = "GTP/Basic/Distance_NormalizedCCW";
+	shadowMapSizeDirectional = shadowMapSizePoint = shadowMapSizeSpot = 512;
+	useLISPSMDirectional = useLISPSMPoint = useLISPSMSpot = false;
+	blurSMDirectional = blurSMPoint = blurSMSpot = false;
+	focusingSMDirectional = focusingSMPoint = focusingSMSpot = true;
+	shadowMapMaterialNameDirectional = "GTP/Basic/Depth or GTP/Basic/DepthCCW";
+	shadowMapMaterialNamePoint = "GTP/Basic/Distance_NormalizedCCW";
+	shadowMapMaterialNameSpot = "GTP/Basic/Distance_NormalizedCCW";
 	areaLightRadius = 0.1;
 
@@ -515,9 +517,10 @@
 		fillVisibleList(rq);	
 
-		int l = visibleObjects.size(); //debug
-		
-		joinSharedRuns();
-
-		int ll = sharedRunRoots.size(); //debug
+		if(joinRuns)
+		{
+			int l = visibleObjects.size(); //debug		
+			joinSharedRuns();
+			int ll = sharedRunRoots.size(); //debug
+		}
 
 		//update precomputings				
@@ -717,11 +720,30 @@
 		{
 			SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
+			Light* light = sm->getLight(lightName);
+			unsigned int res;
+			String MaterialName;
+			switch(light->getType())
+			{
+			case Light::LT_DIRECTIONAL:
+				res = shadowMapSizeDirectional;
+				MaterialName = shadowMapMaterialNameDirectional;
+				break;
+			case Light::LT_POINT:
+				res = shadowMapSizePoint;
+				MaterialName = shadowMapMaterialNamePoint;
+				break;
+			case Light::LT_SPOTLIGHT:
+				res = shadowMapSizeSpot;
+				MaterialName = shadowMapMaterialNameSpot;
+				break;
+			}
+
 			OgreDepthShadowMapRenderingRun* run  = new OgreDepthShadowMapRenderingRun(
 				runs,
 				lightName + "DEPTH_SHADOW_MAP",
-				sm->getLight(lightName),
-				shadowMapSize,
-				shadowMapSize,
-				shadowMapMaterialName //TODO
+				light,
+				res,
+				res,
+				MaterialName
 				);
 			runs->addRun(ILLUMRUN_DEPTH_SHADOWMAP, run);
