Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material	(revision 1638)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material	(revision 1671)
@@ -157,7 +157,5 @@
 		texture_unit
 		{
-			cubic_texture cubemap.jpg combinedUVW
-			tex_address_mode clamp
-			colour_op replace
+			
 		}
 
@@ -165,7 +163,5 @@
 		texture_unit
 		 {
-		   cubic_texture cubemap.jpg combinedUVW
-		   tex_address_mode clamp
-		   colour_op replace
+		  
 		 }
 	 }
@@ -173,4 +169,78 @@
 }
 
+vertex_program DiffuseBumpVS hlsl
+{
+	source GameTools_Diffuse.hlsl
+	entry_point DiffuseBumpVS
+	target vs_3_0
+} 
+
+fragment_program DiffuseBumpPS hlsl
+{
+	source GameTools_Diffuse.hlsl
+	entry_point DiffuseBumpPS
+	target ps_3_0
+} 
+
+
+
+material GameTools/DiffuseBump
+{ 
+   technique 
+   { 
+      pass 
+      { 
+		
+		IllumTechniques
+		{
+			RenderTechnique DistanceCubeMap
+			{
+				update_interval		1
+				update_all_face		true
+				distance_calc		false
+				face_angle_calc		false
+				resolution			128						
+			}
+			RenderTechnique ReducedColorCubeMap
+			{
+				update_interval		1
+				reduced_resolution 4
+				resolution 128
+				distance_calc false
+				face_angle_calc false
+				update_all_face		true
+			}
+		}
+      
+
+		vertex_program_ref DiffuseBumpVS
+		{       
+			param_named_auto worldViewProj worldviewproj_matrix 
+    		param_named_auto world world_matrix
+        
+		} 
+		fragment_program_ref DiffuseBumpPS
+		{ 
+			param_named_auto worldI inverse_world_matrix  
+    		param_named lastCenter float3 0 0 0
+		} 
+		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{			
+		}
+
+		//Cube map of distances
+		texture_unit
+		 {
+		     
+		 }
+		 texture_unit
+		 {
+			texture atheneNormalMapNew.dds
+		 }
+	 }
+   }
+}
 
 fragment_program DiffuseP2PPS hlsl
@@ -181,5 +251,5 @@
 } 
 
-material GameTools/Diffuse/use1
+material GameTools/DiffuseP2P
 { 
    technique 
@@ -193,4 +263,5 @@
 			{
 				update_interval		1
+				resolution 128
 				distance_calc false	
 				face_angle_calc false
@@ -211,11 +282,10 @@
 		vertex_program_ref Diffuse2VS
 		{       
-		 param_named_auto worldViewProj worldviewproj_matrix 
-    		param_named_auto world world_matrix  
-        
+			param_named_auto worldViewProj worldviewproj_matrix 
+    		param_named_auto worldI inverse_world_matrix  
+    		param_named_auto world world_matrix        
 		} 
 		fragment_program_ref DiffuseP2PPS
 		{ 
-			param_named REDUCED_CUBEMAP_SIZE int 4
 			param_named lastCenter float3 0 0 0				
 		} 
@@ -224,7 +294,5 @@
 		texture_unit
 		{
-			cubic_texture cubemap.jpg combinedUVW
-			tex_address_mode clamp
-			colour_op replace
+			
 		}
 
@@ -232,7 +300,5 @@
 		texture_unit
 		 {
-		   cubic_texture cubemap.jpg combinedUVW
-		   tex_address_mode clamp
-		   colour_op replace
+		  
 		 }
 	 }
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/difflab.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/difflab.material	(revision 1638)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/difflab.material	(revision 1671)
@@ -115,4 +115,8 @@
 				{
 					max_light_count 3
+					vertex_program_name GameTools/ShadowMap/ShadowDistVS
+					fragment_program_name GameTools/ShadowMap/ShadowDistPS
+					set_light_view true
+					set_light_farplane true
 				}
 			}
@@ -136,4 +140,8 @@
 				{
 					max_light_count 3
+					vertex_program_name GameTools/ShadowMap/ShadowDistVS
+					fragment_program_name GameTools/ShadowMap/ShadowDistPS
+					set_light_view true
+					set_light_farplane true
 				}
 			}
@@ -179,4 +187,8 @@
 				{
 					max_light_count 3
+					vertex_program_name GameTools/ShadowMap/ShadowDistVS
+					fragment_program_name GameTools/ShadowMap/ShadowDistPS
+					set_light_view true
+					set_light_farplane true
 				}
 			}
@@ -249,4 +261,8 @@
 				{
 					max_light_count 3
+					vertex_program_name GameTools/ShadowMap/ShadowDistVS
+					fragment_program_name GameTools/ShadowMap/ShadowDistPS
+					set_light_view true
+					set_light_farplane true
 				}
 			}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material	(revision 1629)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material	(revision 1671)
@@ -221,4 +221,30 @@
         { 
 			
+        }
+        
+       }
+    }
+}
+
+material GameTools/ShadowMapDistance
+{ 
+
+   technique 
+   { 
+      scene_blend none
+
+      pass 
+      { 
+		cull_hardware anticlockwise
+		//cull_hardware none
+		
+		vertex_program_ref GameTools/ShadowMap/DistVS
+        {       
+          param_named_auto worldViewProj worldviewproj_matrix
+          param_named_auto worldView worldview_matrix          
+	    } 
+		fragment_program_ref  GameTools/ShadowMap/DistPS
+        { 
+			param_named_auto farPlane far_clip_distance
         }
         
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/hangar.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/hangar.material	(revision 1085)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/hangar.material	(revision 1671)
@@ -9,4 +9,9 @@
 				RenderTechnique DepthShadowReciever
 				{
+					max_light_count 3
+					vertex_program_name GameTools/ShadowMap/ShadowDistVS
+					fragment_program_name 					GameTools/ShadowMap/ShadowDistPS
+					set_light_view true
+					set_light_farplane true
 					
 				}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program	(revision 1131)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program	(revision 1671)
@@ -252,4 +252,19 @@
 	target ps_3_0
 
+}
+
+vertex_program GameTools/ShadowMap/DistVS hlsl
+{
+	source GameTools_DepthShadow.hlsl
+	entry_point DepthDistVS
+	target vs_3_0
+} 
+
+fragment_program GameTools/ShadowMap/DistPS hlsl
+{
+	source GameTools_DepthShadow.hlsl
+	entry_point DepthDistPS
+	target ps_3_0
+
 } 
 
@@ -269,4 +284,19 @@
 } 
 
+vertex_program GameTools/ShadowMap/ShadowDistVS hlsl
+{
+	source GameTools_DepthShadow.hlsl
+	entry_point distShadowVS
+	target vs_1_1
+} 
+
+fragment_program GameTools/ShadowMap/ShadowDistPS hlsl
+{
+	source GameTools_DepthShadow.hlsl
+	entry_point distShadowPS
+	target ps_2_0
+
+} 
+
 vertex_program GameTools/UV_VS hlsl
 {
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 1638)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl	(revision 1671)
@@ -27,4 +27,25 @@
 }
 
+VS_OUT DepthDistVS(float4 position : POSITION,	
+				uniform float4x4 worldViewProj,
+				uniform float4x4 worldView)
+{
+  
+  VS_OUT OUT;
+ 
+  OUT.hPosition = mul(worldViewProj, position);
+  OUT.Position = mul(worldView, position);
+  
+  return OUT;
+}
+
+float4 DepthDistPS(VS_OUT IN,
+					uniform float farPlane ):COLOR
+{
+	float dist = length(IN.Position.xyz) / farPlane;
+	return float4(dist, dist * dist, 1, 1);	
+	//return farPlane;
+}
+
 ///////////////Shadow
 
@@ -34,4 +55,5 @@
 	float4 Position		: TEXCOORD0;
 	float4 lPosition	: TEXCOORD1;
+	float4 lVPosition	: TEXCOORD2;
 };
 
@@ -45,9 +67,10 @@
   float4 wPos = mul(world, position);
   OUT.lPosition = mul(lightViewProj, wPos);  
+  OUT.lVPosition = 0;  
   OUT.Position = position;  
   return OUT;
 }
 
-/*
+
 float4 depthShadowPS(VS_OUT_SHADOW IN,
 					uniform float4x4 lightViewProj,
@@ -72,12 +95,11 @@
 			float4 storedDepth = tex2D(depthShadowMap, pos.xy);
 	
-			if(storedDepth.r + bias < pos.z)
-			{
-				float M1 = storedDepth.r;
-				float M2 = storedDepth.g;
-				float v2 = M2 - M1 * M1;
-				float pmax = v2 / (v2 + pow(M1 - pos.z, 2));
-				light = saturate(shadow + (1 - shadow) * pmax);
-			}
+			 
+			float M1 = storedDepth.r;
+			float M2 = storedDepth.g;
+			float v2 = M2 - M1 * M1;
+			float pmax = v2 / (v2 + pow(M1 - pos.z, 2));
+			light = saturate(shadow + (1 - shadow) * pmax);
+			
 		}
 		
@@ -88,7 +110,71 @@
 	return light;	
 }
-*/
-
-
+
+
+
+VS_OUT_SHADOW distShadowVS(float4 position : POSITION,	
+							uniform float4x4 worldViewProj,
+							uniform float4x4 world,
+							uniform float4x4 lightView,
+							uniform float4x4 lightViewProj)
+{
+  VS_OUT_SHADOW OUT;
+  OUT.hPosition = mul(worldViewProj, position);
+  float4 wPos = mul(world, position);
+  OUT.lPosition = mul(lightViewProj, wPos);
+  OUT.lVPosition = mul(lightView, wPos);  
+  OUT.Position = position;  
+  return OUT;
+}
+
+
+float4 distShadowPS(VS_OUT_SHADOW IN,
+					uniform float4x4 lightViewProj,
+					uniform float lightFarPlane,
+					uniform sampler2D depthShadowMap : register(s0)
+					):COLOR
+{	
+	float bias = 0.001;
+	float epsilon = 0.001;
+	float4 light = float4(1,1,1,1);
+	float4 shadow = float4(0.85,0.85,0.85,1);
+	
+	if(IN.lPosition.z > 0.0)
+	{
+		float4 pos = (IN.lPosition / IN.lPosition.w);
+		
+		float d = length(pos.xy);
+			
+		light = saturate((1.0 - d)/0.05);
+		
+		if(d <= 1.0)
+		{
+			float dist = length(IN.lVPosition.xyz) / lightFarPlane;
+			pos.xy = (pos.xy + 1.0) / 2.0;
+			pos.y = 1.0 - pos.y;
+			float4 storedDist = tex2D(depthShadowMap, pos.xy);
+			dist -= bias;
+			float lit_factor = light * (dist <= storedDist.r);	
+    	 
+			float M1 = storedDist.r;
+			float M2 = storedDist.g;
+			float v2 = min(max(M2 - M1 * M1, 0.0) +  epsilon, 1.0);
+			float m_d = M1 - dist;
+    		float pmax = v2 / (v2 + m_d * m_d);
+						
+    		// Adjust the light color based on the shadow attenuation
+    		light = max(lit_factor, pmax);
+    	
+		}
+		
+	}
+	else
+		light = 0;	
+	
+	return shadow + (1 - shadow) * light;
+}
+
+
+/*
 float4 depthShadowPS(VS_OUT_SHADOW IN,
 					uniform float4x4 lightViewProj,
@@ -126,2 +212,3 @@
 	return light;	
 }
+*/
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl	(revision 1629)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl	(revision 1671)
@@ -209,5 +209,5 @@
     float4 I = 0;
     I = texColor * ambientLight * ambient;
-	float maxlightangle = 3.14 / 2.0;
+	float maxlightangle = 90.0 / 180.0 * 3.14;
     for(int i=0; i< M; i++)
     {
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl	(revision 1638)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl	(revision 1671)
@@ -272,4 +272,189 @@
 }
 
+struct vertOUTBump
+{
+	float4 hPos :POSITION;
+	float3 wPos	:TEXCOORD1;
+	float2 texCoord :TEXCOORD0;
+	float3 mNormal  :TEXCOORD2;
+	float3 tangent  :TEXCOORD3;
+	float3 binormal :TEXCOORD4;
+};
+
+vertOUTBump DiffuseBumpVS(float4 position : POSITION,
+		float3 normal   : NORMAL,
+		half3 tangent   : TEXCOORD1, 
+		float2 texCoord : TEXCOORD0,			
+		uniform float4x4 worldViewProj,
+		uniform float4x4 world)
+{
+  vertOUTBump OUT;
+  OUT.hPos = mul(worldViewProj, position);
+  OUT.wPos = mul(world, position).xyz;  
+  OUT.mNormal = normal;
+  OUT.tangent  = tangent;
+  OUT.texCoord = texCoord;
+  OUT.binormal = cross(tangent, normal);
+  return OUT;
+}
+
+float4 DiffuseBumpPS( vertOUTBump IN,
+           uniform float3 cameraPos,
+           uniform float3 lastCenter,	//LI//
+           uniform samplerCUBE SmallEnvMapSampler : register(s0),
+           uniform samplerCUBE DistanceEnvMapSampler : register(s1),
+	   uniform sampler2D NormalMap : register(s2),
+	   uniform float4x4 worldI
+            ) : COLOR0
+{
+    float M = 4;
+	
+    float3 N = IN.mNormal;
+    N = normalize( N ); 
+    float3x3 TangentToModel = float3x3(IN.tangent, IN.binormal, N);
+    
+    half3 tNormal = tex2D(NormalMap, IN.texCoord).rgb;  
+    
+    N = mul(tNormal, TangentToModel );    
+     
+    N = normalize( N ); 
+    N = mul(N, worldI);
+
+    float3 pos = IN.wPos - lastCenter;
+    
+    //return float4(N,1)+ lastCenter.x*0.000001; 
+  //  return  readCubeMap(SmallEnvMapSampler, pos) + lastCenter.x*0.000001;
+    
+    float4 I = 0;									
+	float3 L1, L2, L3, L4, L;						
+	float4 Le;										
+	float width = 1.0 / M;							
+	float width2 = width * 2;
+	float d; 
+	
+	for (float x = 0.5; x < M; x++)			
+	 for (float y = 0.5; y < M; y++)											
+	 {																
+		float2 p, tpos; 
+	    tpos.x = x * width;
+	    tpos.y = y * width;
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L1 = float3(p.x - width, p.y - width, 1);	
+		L2 = float3(p.x + width, p.y - width, 1);	
+		L3 = float3(p.x + width, p.y + width, 1);	
+		L4 = float3(p.x - width, p.y + width, 1);
+		L = float3(p.x, p.y, 1);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);			
+			
+	}																			
+	
+	for (float x = 0.5; x < M; x++)			
+	 for (float y = 0.5; y < M; y++)											
+	 {																
+		float2 p, tpos; 
+	    tpos.x = x * width;	// 0..1
+	    tpos.y = y * width;	// 0..1
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L4 = float3(p.x - width, p.y - width, -1);	
+		L3 = float3(p.x + width, p.y - width, -1);	
+		L2 = float3(p.x + width, p.y + width, -1);	
+		L1 = float3(p.x - width, p.y + width, -1);
+		L = float3(p.x, p.y, -1);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);			
+	 }	
+	 
+	for (float x = 0.5; x < M; x++)			
+	 for (float y = 0.5; y < M; y++)											
+	 {																
+		float2 p, tpos; 
+	    tpos.x = x * width;	// 0..1
+	    tpos.y = y * width;	// 0..1
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L4 = float3(p.x - width, 1, p.y - width);
+		L3 = float3(p.x + width, 1, p.y - width);	
+		L2 = float3(p.x + width, 1, p.y + width);	
+		L1 = float3(p.x - width, 1, p.y + width);			
+		L = float3(p.x, 1, p.y);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);			
+	 }		
+	 
+	for (float x = 0.5; x < M; x++)			
+	 for (float y = 0.5; y < M; y++)											
+	 {																
+		float2 p, tpos; 
+	    tpos.x = x * width;	// 0..1
+	    tpos.y = y * width;	// 0..1
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L1 = float3(p.x - width, -1, p.y - width);
+		L2 = float3(p.x + width, -1, p.y - width);	
+		L3 = float3(p.x + width, -1, p.y + width);	
+		L4 = float3(p.x - width, -1, p.y + width);			
+		L = float3(p.x, -1, p.y);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);			
+	 }
+	 
+	 for (float x = 0.5; x < M; x++)			
+		for (float y = 0.5; y < M; y++)											
+		{																
+		float2 p, tpos; 
+	    tpos.x = x * width;	// 0..1
+	    tpos.y = y * width;	// 0..1
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L1 = float3(1, p.x - width, p.y - width);
+		L2 = float3(1, p.x + width, p.y - width);	
+		L3 = float3(1, p.x + width, p.y + width);	
+		L4 = float3(1, p.x - width, p.y + width);	
+		L = float3(1, p.x, p.y);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);			
+	}
+	 
+	for (float x = 0.5; x < M; x++)			
+	 for (float y = 0.5; y < M; y++)											
+	 {																
+		float2 p, tpos; 
+	    tpos.x = x * width;	// 0..1
+	    tpos.y = y * width;	// 0..1
+	    
+	    p = tpos.xy;    
+	    p = 2.0 * p - 1.0; //-1..1
+	    	    	    
+		L4 = float3(-1, p.x - width, p.y - width);
+		L3 = float3(-1, p.x + width, p.y - width);	
+		L2 = float3(-1, p.x + width, p.y + width);	
+		L1 = float3(-1, p.x - width, p.y + width);	
+		L = float3(-1, p.x, p.y);
+		Le = float4(readCubeMap(SmallEnvMapSampler, L).rgb, 1);
+		
+		I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);				
+	 }	
+	 float kd = 0.3;																		
+	return kd * I;
+}
+
 float4 P2PContr(float3 N, float3 Nl, float3 pos, float3 L, samplerCUBE cubemap, samplerCUBE distmap)
 {
@@ -280,8 +465,8 @@
 	float3 Lpos = L * d;
 	float3 Ldir = Lpos - pos;
-	float dist = dot(Ldir, Ldir);
+	float dist = 4 * dot(Ldir, Ldir);
 	Ldir = normalize(Ldir);
-	dist /= 10000.0;
-	return Le * max(dot(N, Ldir),0) * dot(Nl, -1 * Ldir) / dist;	
+		
+	return Le * (max(dot(N, Ldir),0) * dot(Nl, -1 * Ldir)) / dist;	
 }
 
@@ -293,5 +478,4 @@
 	float M = 4.0;	
 	
-   	//float3 N = mul( world_IT, float4(IN.mNormal,1)).xyz;
     float3 N = IN.mNormal;
     N = normalize( N ); 
@@ -302,10 +486,9 @@
 	float4 Le;										
 	float width = 1.0 / M;
-	float d;							
-	
-	//float vdir = length(pos);
-	//return (readDistanceCubeMap(DistanceEnvMapSampler, pos) - vdir);
-	//return readCubeMap(SmallEnvMapSampler, pos);
-	//return readDistanceCubeMap(DistanceEnvMapSampler, pos);
+	float d;	
+	
+	float kd = 0.3;																		
+	
+	//return kd * readCubeMap(SmallEnvMapSampler, N) + lastCenter.x * 0.00000001;
 	
 	for (float x = 0.5; x < M; x++)			
@@ -327,5 +510,4 @@
 	}
 																		
-	float kd = 0.8;																		
 	return kd * I;															
 }
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/terrain.cfg
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/terrain.cfg	(revision 1671)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/terrain.cfg	(revision 1671)
@@ -0,0 +1,71 @@
+# The main world texture (if you wish the terrain manager to create a material for you)
+WorldTexture=terrain_texture.jpg
+
+# The detail texture (if you wish the terrain manager to create a material for you)
+DetailTexture=terrain_detail.jpg
+
+#number of times the detail texture will tile in a terrain tile
+DetailTile=3
+
+# Heightmap source
+PageSource=Heightmap
+
+# Heightmap-source specific settings
+Heightmap.image=terrain.png
+
+# If you use RAW, fill in the below too
+# RAW-specific setting - size (horizontal/vertical)
+#Heightmap.raw.size=513
+# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit)
+#Heightmap.raw.bpp=2
+
+# How large is a page of tiles (in vertices)? Must be (2^n)+1
+PageSize=513
+
+# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
+TileSize=65
+
+# The maximum error allowed when determining which LOD to use
+MaxPixelError=3
+
+# The size of a terrain page, in world units
+PageWorldX=1500
+PageWorldZ=1500
+# Maximum height of the terrain 
+MaxHeight=100
+
+# Upper LOD limit
+MaxMipMapLevel=5
+
+#VertexNormals=yes
+#VertexColors=yes
+#UseTriStrips=yes
+
+# Use vertex program to morph LODs, if available
+VertexProgramMorph=no
+
+# The proportional distance range at which the LOD morph starts to take effect
+# This is as a proportion of the distance between the current LODs effective range,
+# and the effective range of the next lower LOD
+LODMorphStart=0.2
+
+# This following section is for if you want to provide your own terrain shading routine
+# Note that since you define your textures within the material this makes the 
+# WorldTexture and DetailTexture settings redundant
+
+# The name of the vertex program parameter you wish to bind the morph LOD factor to
+# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
+# to the same position as the next lower LOD
+# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING
+#MorphLODFactorParamName=morphFactor
+
+# The index of the vertex program parameter you wish to bind the morph LOD factor to
+# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
+# to the same position as the next lower LOD
+# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING
+#MorphLODFactorParamIndex=4
+
+# The name of the material you will define to shade the terrain
+#CustomMaterialName=TestTerrainMaterial
+
+
Index: GTP/trunk/App/Demos/Illum/Ogre/src/HierarchicalSystem/include/HierarchicalSystem.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/HierarchicalSystem/include/HierarchicalSystem.h	(revision 1535)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/HierarchicalSystem/include/HierarchicalSystem.h	(revision 1671)
@@ -65,51 +65,9 @@
 
 public:
-/*	virtual void go(void)
-    {
-        if (!setup())
-            return;
 
-        renderScene();
-		
-        // clean up
-        destroyScene();
-    }
-*/
 protected:
 	SceneNode* kupolaNode;
 	SceneNode* mainLightNode;
-/*		
-	void renderScene(){
-		
-		mWindow->resetStatistics();
-		while(true){		
 
-			
-			#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32            
-			// Pump events on Win32
-    		MSG  msg;
-			while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
-			{
-				TranslateMessage( &msg );
-				DispatchMessage( &msg );
-			}
-			
-			#endif
-			
-			if(!mRoot->_fireFrameStarted()){
-				break;
-			}
-			unsigned long framenum = mRoot->getCurrentFrameNumber();
-			
-			OgreIlluminationManager::getSingleton().update(framenum, mWindow);
-			
-			//mRoot->renderOneFrame();
-			mRoot->_updateAllRenderTargets();
-
-			mRoot->_fireFrameEnded();	
-			
-		}
-	}
-*/
 	void createPostproc()
 	{
@@ -120,4 +78,9 @@
 	}
     
+	 virtual void chooseSceneManager(void)
+    {
+        // Get the SceneManager, in this case a generic one
+        mSceneMgr = mRoot->createSceneManager("TerrainSceneManager");
+    }
 
 	void createScene(void)
@@ -127,5 +90,8 @@
 		OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
 		OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
-				
+		
+		std::string terrain_cfg("terrain.cfg");
+		mSceneMgr -> setWorldGeometry( terrain_cfg );
+
 		Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
 		mCamera->setPosition(0,150,100);
@@ -160,5 +126,5 @@
 		//headNode->setScale(1.5,1.5,1.5);
 		AxisAlignedBox bbox = head->getBoundingBox();
-		headNode->setPosition(0,180,20);		
+		headNode->setPosition(0,80,20);		
 		headNode->_updateBounds();
 
@@ -167,5 +133,5 @@
 		SceneNode *pSysNode = rootNode->createChildSceneNode("psys1");
 		pSysNode->attachObject(pSys1);
-		pSysNode->setPosition(0,100,0);
+		pSysNode->setPosition(0,0,0);
 		
 		//Init lights
@@ -196,5 +162,7 @@
 		mFrameListener= new ParticleDemoFrameListener(mWindow,
 											mCamera	, mainLightNode);
-        mRoot->addFrameListener(mFrameListener);
+       mFrameListener->setPriority(1);
+		OgreIlluminationManager::getSingleton().setPriority(2);
+		 mRoot->addFrameListener(mFrameListener);
 		 mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
 		
Index: GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h	(revision 1638)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h	(revision 1671)
@@ -520,12 +520,12 @@
 		SceneNode* rootNode = mSceneMgr->getRootSceneNode();
 
-      	Entity* object = mSceneMgr->createEntity("object", "santa.mesh");
+      	Entity* object = mSceneMgr->createEntity("object", "buddha.mesh");
 		object->setMaterialName("GameTools/Diffuse/use");
 		//object->setMaterialName("GameTools/Diffuse2");
 		objectNode = rootNode->createChildSceneNode();
 		objectNode->attachObject(object);
-		objectNode->scale(0.5,0.5,0.5);
+		objectNode->scale(1.8,1.8,1.8);
 		objectNode->rotate(Vector3(0,1,0),Radian(Math::PI));
-		objectNode->setPosition(0,0,2);
+		objectNode->setPosition(0,0,0);
 		objectNode->_updateBounds();
 
@@ -579,16 +579,17 @@
    {
 	   OgreIlluminationManager::getSingleton().setFocusingSM(false);
-	   OgreIlluminationManager::getSingleton().setShadowMapSize(1024);
-	  // OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
+	   OgreIlluminationManager::getSingleton().setShadowMapSize(512);
+	   OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
+	   OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GameTools/ShadowMapDistance");
 	    mSceneMgr->setAmbientLight(ColourValue(0.505 * 0.2, 0.897 * 0.2, 0.914 * 0.2));
 		
 		SceneNode* rootNode = mSceneMgr->getRootSceneNode();
 
-      	Entity* object = mSceneMgr->createEntity("object", "buddha.mesh");
+     	Entity* object = mSceneMgr->createEntity("object", "buddha.mesh");
 		object->setMaterialName("GameTools/Diffuse/use");
-		//object->setMaterialName("GameTools/Diffuse2");
+		//object->setMaterialName("GameTools/DiffuseP2P");
 		objectNode = rootNode->createChildSceneNode();
 		objectNode->attachObject(object);
-		objectNode->scale(0.5,0.5,0.5);
+		objectNode->scale(0.4,0.4,0.4);
 		objectNode->rotate(Vector3(0,1,0),Radian(Math::PI));
 		objectNode->setPosition(0,0,0);
@@ -626,5 +627,5 @@
 		mainBlueLight->setPowerScale(5.0);
 		mainBlueLight->setSpotlightRange(Degree(0),Degree(160));
-		mainBlueLight->setAttenuation(5, 0, 1, 0);
+		mainBlueLight->setAttenuation(2.5, 0, 1, 0);
 		SceneNode* mainBlueLightNode = rootNode->createChildSceneNode();
 		mainBlueLightNode->setPosition(-0.546,2.095,1.035);
