Index: /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl	(revision 2213)
+++ /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl	(revision 2217)
@@ -2,9 +2,8 @@
 uniform float4 prmAtlasTilesHalfPixel;
 uniform sampler2D filteredAtlasSampler : register(s0);
-uniform sampler1D clusterWeightIndexSampler : register(s1);
+uniform sampler2D clusterWeightIndexSampler : register(s1);
 uniform sampler2D clusterWeightSampler : register(s2);
 uniform float allClusterCount; 
-uniform float clusterCount; //clustercount / 4
-//uniform float weights[32];
+uniform float clusterCount;
 
 struct vsInputWalk
@@ -38,5 +37,5 @@
 	
 	float3 col = 0;
-	for(int iCluster=0; iCluster<16; iCluster++)
+	for(int iCluster = 0; iCluster < 32; iCluster++)
 	{
 		float2 prmTexPos = float2(
@@ -44,37 +43,12 @@
 			1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel;
 
-		//float4 weight = 0.065;
-		//weight = float4(weights[iCluster/4], weights[iCluster/4 + 1],weights[iCluster/4 + 2], weights[iCluster/4 + 3]);
-		//float4 weight = weights[iCluster/4];
-		float4 weightIndex = tex1D(clusterWeightIndexSampler, ((float)iCluster/4) / clusterCount).r / allClusterCount;
-		float weight1 = tex2D(clusterWeightSampler, float2(weightIndex.r, 0.5)).r;
-		float weight2 = tex2D(clusterWeightSampler, float2(weightIndex.g, 0.5)).r;
-		float weight3 = tex2D(clusterWeightSampler, float2(weightIndex.b, 0.5)).r;
-		float weight4 = tex2D(clusterWeightSampler, float2(weightIndex.a, 0.5)).r;
-		float4 weight = float4(weight1, weight2, weight3, weight4);
-		
-		float3 val = tex2D(filteredAtlasSampler, prmTexPos);
-		col += val.xyz * weight.x;
-		iCluster++;
-		
-		prmTexPos.x += 1.0 / prmAtlasTiles.x;
-		val = tex2D(filteredAtlasSampler, prmTexPos);
-		col += val.xyz * weight.y;
-		iCluster++;
-		
-		prmTexPos.x += 1.0 / prmAtlasTiles.x;
-		val = tex2D(filteredAtlasSampler, prmTexPos);
-		col += val.xyz * weight.z;
-		iCluster++;
-		
-		prmTexPos.x += 1.0 / prmAtlasTiles.x;
-		val = tex2D(filteredAtlasSampler, prmTexPos);
-		col += val.xyz * weight.w;
+		float weightIndex = tex2D(clusterWeightIndexSampler, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r;
+		float weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).r;
+		//weight = 0.0002 + 0.000000000001 * weight;
+		float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz;
+		col += val.xyz * weight;		
 	}
 	
-	//return col.xxxx *0.00001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y));
-//return float4(1,0,0,1)+col.xxxx*0.0000000001;
-//return prmAtlasTilesHalfPixel.x*allClusterCount*clusterCount*0.000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)).r;
-	return float4(col * 200, 1);
+	return float4(col * 300, 1);
 }
 
Index: /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PRMDemo.material
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PRMDemo.material	(revision 2207)
+++ /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PRMDemo.material	(revision 2217)
@@ -11,5 +11,5 @@
    entry_point psWalk
    target ps_3_0
-   flow_control avoid
+   flow_control prefer
 }
 
@@ -22,6 +22,19 @@
 	IllumTechniques
 	{
-	   	RenderTechnique PathMap
+	   	RenderTechnique DepthShadowReciever
 	  	{
+	    	max_light_count 2
+			vertex_program_name GTP/Basic/LightCPos_VS
+			fragment_program_name GTP/Basic/SM/Dist_VSM_PS
+			set_light_view true
+			set_light_farplane true
+			light_viewproj_param_name LightViewProj
+			light_view_param_name LightView
+			light_farplane_param_name lightFarPlane
+			world_view_proj_param_name WorldViewProj
+			world_param_name World
+	  	}
+		RenderTechnique PathMap
+	 	{
 	    
 	  	}
@@ -30,7 +43,6 @@
    	{
      colour_op replace
-    }
-   }
-   
+    }    
+   }   
  }
 }
@@ -119,5 +131,5 @@
    source PathMapWeightCompute.hlsl
    entry_point psComputeWeights
-   target ps_2_0   
+   target ps_3_0   
 }
 
@@ -141,4 +153,8 @@
 				filtering off
 			}
+			texture_unit shadow_map //stores distances
+   			{
+     			
+    		}
 		}
 		
@@ -173,13 +189,13 @@
 			texture_unit //entrypoint texture
 			{
-				filtering off
+				filtering none
 			}
 			texture_unit //entrypoint weight texture
 			{
-				filtering off
+				filtering none
 			}
 			texture_unit //cluster length
 			{
-				filtering off
+				filtering none
 			}
 		}
Index: /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl	(revision 2213)
+++ /GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl	(revision 2217)
@@ -1,12 +1,12 @@
 #define SAMPLECUTDIST2 0.01
-#define WEIGHTCUTOFF 0.01
+#define WEIGHTCUTOFF   0.01
+#define DIST_BIAS      0.005
 
 uniform int nRadionColumns;
-uniform sampler2D radionSampler       : register(s0);
-uniform sampler2D entryPointCountSampler : register(s1);
-uniform sampler2D allWeightsSampler   : register(s2);
 uniform float3 lightPos;
 uniform float3 lightDir;
 uniform float clusterCount;
+uniform float4x4 lightViewProj;
+uniform float lightFarPlane;
 
 struct vsInputComputeWeights
@@ -28,9 +28,13 @@
     output.pos = input.pos;
     output.tex = (input.pos + 1.0) / 2.0;
+    //output.tex = input.tex;
     output.tex.y = 1.0 - output.tex.y;
+   
     return output;
 }
 
-float4 psComputeWeights(vsOutputComputeWeights input) : COLOR0
+float4 psComputeWeights(vsOutputComputeWeights input,
+						uniform sampler2D radionSampler : register(s0),
+						uniform sampler2D shadowMap : register(s1)) : COLOR0
 {
 	float dataColumnWidth = 1.0 / (float)nRadionColumns;
@@ -49,25 +53,25 @@
 	float cosb = max(dot(dir, diff), 0);	
 	
-	/*
-	float4 occProjPos = mul(float4(pos, 1), occWorldToProjMatrix);	
-	occProjPos /= occProjPos.w;
-	float2 occTexPos = mul( occProjPos.xyw, occProjToTexMatrix);
-	float visibility = tex2Dproj(depthMapSampler, float4(occTexPos, occProjPos.z - 0.1, 1) );
+	
+	float4 lightVPos = mul(lightViewProj, float4(pos,1));
+	float dist = sqrt(dist2) / lightFarPlane;
+	lightVPos /= lightVPos.w;
+	lightVPos.xy = (lightVPos.xy + 1.0) / 2.0;
+	lightVPos.y = 1.0 - lightVPos.y;
+	float storedDist = tex2D(shadowMap, lightVPos.xy).r;
+	dist -= DIST_BIAS;
+	float visibility = (dist <= storedDist);  	
 
-	float3 lightToPos = pos - lightPos;
-	float actualDepth = length(lightToPos);
-*/
-	float visibility = 1;
+	//float visibility = 1;
+	//visibility = visibility * 0.00001 + 1.0;
 	
-	float4 ret = pow(cosa, 9) * cosb / dist2;
-
-	//float ize = 0;
-	//if(pos.y > 0) ize = 1;
-	//return float4(lightDir + ret.x * 0.00000000001, 1);
-	//return ret;
+	float4 ret = visibility * pow(cosa, 9) * cosb / dist2;
 	return ret;
 }
 
-float4 psSumWeights(vsOutputComputeWeights input) : COLOR0
+float4 psSumWeights(vsOutputComputeWeights input,
+					uniform sampler2D radionSampler       : register(s0),
+					uniform sampler2D entryPointCountSampler : register(s1),
+					uniform sampler2D allWeightsSampler   : register(s2)) : COLOR0
 {
 	float halfPixel = 0.5 / clusterCount;
@@ -80,22 +84,22 @@
 	for(int i = 0; i < entryPointCount; i++)
 	{
-		float hp = float2(0.5 / (float) nRadionColumns, 0.5 / 4096.0);
-		float2 coord1 = float2((float)(currentEntryPoint % nRadionColumns)  / (float) nRadionColumns,
-								currentEntryPoint / (float) nRadionColumns / 4096.0) + hp;
-		float2 coord2 = coord1 + float2(hp.x / 2.0, 0);
-		float radrad = tex2Dlod(radionSampler, float4(coord2, 0, 0)).a;
-		//weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r * radrad;
-		weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r;
+		
+		float dataColumnWidth = 1.0 / (float)nRadionColumns;
+		int werx = currentEntryPoint % nRadionColumns;
+		int wery = currentEntryPoint / nRadionColumns;
+		float2 coord1 = float2((werx + 0.5) * dataColumnWidth, (wery  + 0.5) / 4096.0);
+		float2 coord2 = coord1 + float2(0.25 * dataColumnWidth, 0);
+		float w = tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r;
+		float radrad = tex2Dlod(radionSampler, float4(coord1, 0, 0)).a;		
+		weight += w * radrad;		
 		clusterRad += radrad;
 		currentEntryPoint++;
 	}	
 	
-	/*if(clusterRad >= 0)
+	if(clusterRad >= 0)
 		weight /= clusterRad;
 	else
-		weight = 0;*/
-			
-    weight /= (float) entryPointCount;
-		
+		weight = 0;
+   
 	return weight;
 }
Index: /GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl	(revision 2186)
+++ /GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl	(revision 2217)
@@ -15,9 +15,9 @@
 #define DEPTH_BIAS_VSM  0.001
 #define DEPTH_EPSILON   0.00005
-#define DIST_BIAS       0.1
-#define DIST_BIAS_VSM   0.001
+#define DIST_BIAS       0.005
+#define DIST_BIAS_VSM   0.005
 #define DIST_EPSILON    0.001
 
-#define shadowColor float4(0.2,0.2,0.2,1)
+#define shadowColor float4(0.5,0.5,0.5,1)
 
 float4 shadowMapDepth(LightVPos_OUT IN,
@@ -78,8 +78,8 @@
   {	
     float4 pos = (IN.LightVPos / IN.LightVPos.w);
-  	//float d = length(pos.xy);
-    //light = saturate((1.0 - d)/0.05);		
-    //if(d <= 1.0)
-    //{
+  	float d = length(pos.xy);
+    light = saturate((1.0 - d)/0.05);		
+    if(d <= 1.0)
+    {
 		float dist = length(IN.LightCPos.xyz) / lightFarPlane;
 		pos.xy = (pos.xy + 1.0) / 2.0;
@@ -88,5 +88,5 @@
 		dist -= DIST_BIAS;
 		light = max(dist <= storedDist.r, shadowColor);    	
-    //}
+    }
   }
   	
