Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl	(revision 2138)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl	(revision 2181)
@@ -53,7 +53,6 @@
 {
 	float4 hPosition	: POSITION;
-	float4 Position		: TEXCOORD0;
-	float4 lPosition	: TEXCOORD1;
-	float4 lVPosition	: TEXCOORD2;
+	float4 lPosition	: TEXCOORD0;
+	float4 lVPosition	: TEXCOORD1;
 };
 
@@ -67,10 +66,9 @@
   float4 wPos = mul(world, position);
   OUT.lPosition = mul(lightViewProj, wPos);  
-  OUT.lVPosition = 0;  
-  OUT.Position = position;  
-  return OUT;
-}
-
-
+  OUT.lVPosition = 0;
+  return OUT;
+}
+
+/*
 float4 depthShadowPS(VS_OUT_SHADOW IN,
 					uniform float4x4 lightViewProj,
@@ -110,5 +108,5 @@
 	return light;	
 }
-
+*/
 
 
@@ -125,5 +123,4 @@
   OUT.lPosition = mul(lightViewProj, wPos);
   OUT.lVPosition = mul(lightView, wPos);  
-  OUT.Position = position;  
   return OUT;
 }
@@ -213,5 +210,5 @@
 }
 */
-/*
+
 float4 depthShadowPS(VS_OUT_SHADOW IN,
 					uniform float4x4 lightViewProj,
@@ -249,3 +246,2 @@
 	return light;	
 }
-*/
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_PS.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_PS.hlsl	(revision 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_PS.hlsl	(revision 2181)
@@ -28,5 +28,5 @@
 {
  float4 pos = IN.VPosition / IN.VPosition.w;
- return float4(pos.z, pos.z * pos.z, 0, pos.z);	
+ return float4(pos.z, pos.z * pos.z, 1, 1);	
 }
 
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 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl	(revision 2181)
@@ -14,5 +14,5 @@
 #define DEPTH_BIAS      0.001
 #define DEPTH_BIAS_VSM  0.001
-#define DEPTH_EPSILON   0.001
+#define DEPTH_EPSILON   0.00005
 #define DIST_BIAS       0.1
 #define DIST_BIAS_VSM   0.001
@@ -24,14 +24,15 @@
                       uniform sampler2D shadowMap) : COLOR
 {
-  float4 light = shadowColor;	
-  if( IN.LightVPos.z > 0.0)
+  float4 light = shadowColor;	  
+	
+  if(IN.LightVPos.z > 0.0)
   {
-    float4 pos = (IN.LightVPos / IN.LightVPos.w);
-  	pos.xy = (pos.xy + 1.0) / 2.0;
-    pos.y = 1.0 - pos.y;
-    float storedDepth = tex2D(shadowMap, pos.xy).r;
-	pos.z -= DIST_BIAS;
-	light = max(pos.z <= storedDepth.r, shadowColor);    	    
-  }
+	float4 pos = (IN.LightVPos / IN.LightVPos.w);
+		
+	pos.xy = (pos.xy + 1.0) / 2.0;
+	pos.y = 1.0 - pos.y;
+	float4 storedDepth = tex2D(shadowMap, pos.xy);
+	light = max(storedDepth.r + DEPTH_BIAS >= pos.z, shadowColor);			
+  }		
   return light;	
 }
@@ -45,6 +46,5 @@
   
   if( pos.z > 0.0)
-  {	
-    {
+  {	    
 	float depth = pos.z;
 	pos.xy = (pos.xy + 1.0) / 2.0;
@@ -58,10 +58,8 @@
 	float v2 = min(max(M2 - M1 * M1, 0.0) +  DEPTH_EPSILON, 1.0);
 	float m_d = M1 - depth;
-    	float pmax = v2 / (v2 + m_d * m_d);
+    float pmax = v2 / (v2 + m_d * m_d);
 						
-    	// Adjust the light color based on the shadow attenuation
-    	light = max(lit_factor, pmax);
-    	
-     }
+    // Adjust the light color based on the shadow attenuation
+    light = max(lit_factor, pmax);    
   }
   else
@@ -73,9 +71,8 @@
 
 float4 shadowMapDist(LightCPos_OUT IN,
-					//uniform float lightFarPlane,
+					uniform float lightFarPlane,
 					 uniform sampler2D shadowMap) : COLOR
 {
-  float4 light = shadowColor;
-  
+  float4 light = shadowColor;  
   if( IN.LightVPos.z > 0.0)
   {	
@@ -85,5 +82,5 @@
     //if(d <= 1.0)
     //{
-		float dist = length(IN.LightCPos.xyz) ;
+		float dist = length(IN.LightCPos.xyz) / lightFarPlane;
 		pos.xy = (pos.xy + 1.0) / 2.0;
 		pos.y = 1.0 - pos.y;
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program	(revision 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program	(revision 2181)
@@ -49,5 +49,5 @@
    source GTPBasic_VS.hlsl
    entry_point VPos
-   target vs_1_1
+   target vs_2_0
 }
 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_VS.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_VS.hlsl	(revision 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_VS.hlsl	(revision 2181)
@@ -145,5 +145,5 @@
 };
 
-VPos_OUT VPos(float4 position : POSITION0,
+VPos_OUT VPos(float4 position : POSITION,
               uniform float4x4 WorldViewProj)
 {
@@ -159,5 +159,5 @@
 };
 
-MPos_OUT MPos(float4 position : POSITION0,
+MPos_OUT MPos(float4 position : POSITION,
               uniform float4x4 WorldViewProj)
 {
@@ -168,5 +168,5 @@
 }
 
-MPos_OUT MPos_NoTransform(float4 position : POSITION0)
+MPos_OUT MPos_NoTransform(float4 position : POSITION)
 {
  MPos_OUT OUT;
@@ -182,5 +182,5 @@
 };
 
-CPos_OUT CPos(float4 position : POSITION0,
+CPos_OUT CPos(float4 position : POSITION,
               uniform float4x4 WorldViewProj,
               uniform float4x4 WorldView)
@@ -222,5 +222,5 @@
 };
 
-LightVPos_OUT LightVPos(float4 position : POSITION0,
+LightVPos_OUT LightVPos(float4 position : POSITION,
               uniform float4x4 WorldViewProj,
               uniform float4x4 LightViewProj,
@@ -242,5 +242,5 @@
 };
 
-LightCPos_OUT LightCPos(float4 position : POSITION0,
+LightCPos_OUT LightCPos(float4 position : POSITION,
               uniform float4x4 WorldViewProj,
               uniform float4x4 World,
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material	(revision 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material	(revision 2181)
@@ -40,7 +40,7 @@
 material GTP/Basic/Depth
 {
- technique
+ technique maintechnique
  {
-  pass
+  pass mainpass
   {
    cull_hardware clockwise
@@ -49,5 +49,5 @@
      param_named_auto WorldViewProj worldviewproj_matrix     
    } 
-   vertex_program_ref GTP/Basic/VDepth_PS
+   fragment_program_ref GTP/Basic/VDepth_PS
    {	
    }   
@@ -58,7 +58,7 @@
 material GTP/Basic/DepthCCW : GTP/Basic/Depth
 {
- technique 0
+ technique maintechnique
  {
-  pass 0
+  pass mainpass
   {
    cull_hardware anticlockwise   
@@ -79,5 +79,5 @@
      param_named_auto WorldView     worldview_matrix     
    } 
-   vertex_program_ref GTP/Basic/CDepth_PS
+   fragment_program_ref GTP/Basic/CDepth_PS
    {	
    }   
@@ -88,7 +88,7 @@
 material GTP/Basic/Distance
 {
- technique
+ technique maintechnique
  {
-  pass
+  pass mainpass
   {
    cull_hardware clockwise
@@ -107,7 +107,7 @@
 material GTP/Basic/DistanceCCW : GTP/Basic/Distance
 {
- technique 0
+ technique maintechnique
  {
-  pass 0
+  pass mainpass
   {
    cull_hardware anticlockwise   
@@ -118,7 +118,7 @@
 material GTP/Basic/Distance_Normalized
 {
- technique
+ technique maintechnique
  {
-  pass
+  pass mainpass
   {
    cull_hardware clockwise
@@ -138,7 +138,7 @@
 material GTP/Basic/Distance_NormalizedCCW : GTP/Basic/Distance_Normalized
 {
- technique 0
+ technique maintechnique
  {
-  pass 0
+  pass mainpass
   {
    cull_hardware anticlockwise   
@@ -160,7 +160,10 @@
 			max_light_count 1
 			vertex_program_name GTP/Basic/LightVPos_VS
-			fragment_program_name GTP/Basic/SM/Depth_PS
+			fragment_program_name GTP/Basic/SM/Depth_VSM_PS
 			set_light_view false
 			set_light_farplane false
+			world_view_proj_param_name WorldViewProj
+			world_param_name World
+			light_viewproj_param_name LightViewProj			
 		}	
      }
Index: GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h	(revision 2179)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h	(revision 2181)
@@ -104,9 +104,9 @@
 		OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
 		OgreIlluminationManager::getSingleton().setShadowMapSize(512);
-		OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GameTools/ShadowMapDistance");
+		OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GTP/Basic/DepthCCW");
 		OgreIlluminationManager::getSingleton().setFocusingSM(true);
-	   OgreIlluminationManager::getSingleton().setShadowMapSize(512);
-	   OgreIlluminationManager::getSingleton().setBlurShadowMap(false);
-	   OgreIlluminationManager::getSingleton().setUseLISPSM(false);
+	   OgreIlluminationManager::getSingleton().setShadowMapSize(700);
+	   OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
+	   OgreIlluminationManager::getSingleton().setUseLISPSM(true);
 				
 		Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
@@ -126,8 +126,8 @@
 		SceneSerializer s(mSceneMgr);
 		DataStreamPtr inputStream; 				
-		inputStream = ResourceGroupManager::getSingleton().openResource("level.txt");	//towers2.level	
+		inputStream = ResourceGroupManager::getSingleton().openResource("towers2.level");	//towers2.level	
 		s.parseScript(inputStream, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 			
-		createPlane("p","GTP/Basic/ShadowReciever/Depth",Vector3(0,0,0),Vector2(1000,1000));
+		createPlane("p","GTP/Basic/ShadowReciever/Depth",Vector3(0,-0.3,0),Vector2(150,150));
 
 		Light* mainLight = mSceneMgr->createLight("MainLight");
Index: GTP/trunk/App/Demos/Illum/Ogre/bin/Release/ogre.cfg
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/bin/Release/ogre.cfg	(revision 2167)
+++ GTP/trunk/App/Demos/Illum/Ogre/bin/Release/ogre.cfg	(revision 2181)
@@ -6,5 +6,5 @@
 Floating-point mode=Fastest
 Full Screen=No
-Rendering Device=NVIDIA GeForce 7950 GX2
+Rendering Device=NVIDIA GeForce 6800 GT
 VSync=No
 Video Mode=800 x 600 @ 32-bit colour
Index: GTP/trunk/App/Demos/Illum/Ogre/bin/Debug/ogre.cfg
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/bin/Debug/ogre.cfg	(revision 2167)
+++ GTP/trunk/App/Demos/Illum/Ogre/bin/Debug/ogre.cfg	(revision 2181)
@@ -6,5 +6,5 @@
 Floating-point mode=Fastest
 Full Screen=No
-Rendering Device=NVIDIA GeForce 7950 GX2
+Rendering Device=NVIDIA GeForce 6800 GT
 VSync=No
 Video Mode=800 x 600 @ 32-bit colour
