Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp	(revision 2214)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp	(revision 2218)
@@ -2,4 +2,5 @@
 #include "OgreIlluminationManager.h"
 #include "OgrePMEntryPointMapRenderingRun.h"
+#include "OgreDepthShadowMapRenderingRun.h"
 
 OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName)
@@ -74,6 +75,10 @@
 	if(light->getType() == Light::LT_SPOTLIGHT)
 	{
+		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");
-
 		GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
 			
@@ -82,19 +87,22 @@
 		//	Radian lightAngle = light->getSpotlightOuterAngle();
 			
-			//Fparams->setNamedConstant("lightTransform", lightMatrix);
 			Fparams->setNamedConstant("nRadionColumns", col);
 			Fparams->setNamedConstant("lightPos", lightPos);
 			Fparams->setNamedConstant("lightDir", lightDir);
+			Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix());
+			Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane());
 			
 			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();
 			renderFullscreenQuad(mat->getName(), rt);
 
-			rt->writeContentsToFile("allweights.bmp");
+		//	rt->writeContentsToFile("allweights.bmp");
 		//	rt->writeContentsToFile("allweights.dds");
 			
-			float* allweights = new float[entryPointCnt / 4096 * 4096];
+		/*	float* allweights = new float[entryPointCnt / 4096 * 4096];
 			PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights);
 			allWeightsTexture->getBuffer()->blitToMemory(lockBox);
@@ -126,5 +134,5 @@
 			}
 
-			delete[] allweights;
+			delete[] allweights;*/
 
 /////////////////
@@ -153,10 +161,10 @@
 	//rt->writeContentsToFile("weights.bmp");	
 	//rt->writeContentsToFile("weights.dds");
-
+/*
 	float* weights = new float[clustercount];
 	PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights);
-	allWeightsTexture->getBuffer()->blitToMemory(lockBox);
+	weightTexture->getBuffer()->blitToMemory(lockBox);
 
-	delete[] weights;
+	delete[] weights;*/
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2200)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp	(revision 2218)
@@ -50,5 +50,6 @@
 	Vector4 pathMapParameters(prmnt[0],prmnt[1],halfPixel[0],halfPixel[1]);
 	Fparams->setNamedConstant("prmAtlasTilesHalfPixel",pathMapParameters);
-    unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
+    
+	unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
 	Fparams->setNamedConstant("allClusterCount", (float) clustercount);
 	PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName());
@@ -74,6 +75,6 @@
 	st->setTextureBorderColour(ColourValue::Blue);
 	
-	//newpass->setSceneBlending(SBT_MODULATE);
-	newpass->setSceneBlending(SBF_ONE, SBF_ZERO);
+	newpass->setSceneBlending(SBT_MODULATE);
+	//newpass->setSceneBlending(SBF_ONE, SBF_ZERO);
 	newpass->setDepthBias(1);
 	
@@ -90,18 +91,18 @@
 {
 	PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName());
-	int width = clusters->count / 4;
+	int width = clusters->count;
 	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(this->parentOgreRenderable->getName() + "_PMWeightIndexTexture", 
 																		"default",
-																		TEX_TYPE_1D,
+																		TEX_TYPE_2D,
 																		width,
 																		1,
 																		0,
 																		0,
-																		PF_FLOAT32_RGBA,
+																		PF_FLOAT32_R,
 																		TU_DYNAMIC_WRITE_ONLY);
 	weightIndexTexture = texPtr.getPointer();
 
-	float *weightIndices = new float[clusters->count];
-	PixelBox lockBox(width, 1, 1, PF_FLOAT32_RGBA, weightIndices);
+	float *weightIndices = new float[width];
+	PixelBox lockBox(width, 1, 1, PF_FLOAT32_R, weightIndices);
 	for(int j = 0; j< clusters->count; j++)
 			weightIndices[j] = clusters->clusters[j];
@@ -116,6 +117,9 @@
 	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++)
 	{
@@ -126,6 +130,22 @@
 			OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun();
 
-		TextureUnitState* st =pathMapPass->getTextureUnitState(2);
-		st->setTextureName(PMWeightRun->getPMWeightTetureName());				
+		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());	*/			
 	}
 }
