Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material.old
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material.old	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material.old	(revision 2368)
@@ -0,0 +1,255 @@
+vertex_program GTP/Demo/BumpMapped_VS hlsl
+{
+   source bump.hlsl
+   entry_point BaseVS
+   target vs_3_0
+}
+
+fragment_program GTP/Demo/BumpMapped_PS hlsl
+{
+   source bump.hlsl
+   entry_point BumpPS
+   target ps_3_0
+}
+
+material DetailTexturedBumpBase
+{
+ technique maintechnique
+ {
+  pass mainpass
+  {
+  			IllumTechniques
+			{
+				//RenderTechnique PathMap
+			 	//{
+			    //  pass_blending dest_alpha one
+			     //pass_blending none
+			     //pass_blending add
+			  	//}			   	
+			  	
+		  	}
+   			vertex_program_ref GTP/Demo/BumpMapped_VS
+   			{
+   			  param_named_auto WorldViewProj worldviewproj_matrix  
+   			  param_named_auto World world_matrix
+   			  param_named_auto WorldI inverse_world_matrix
+   			  param_named_auto wLightPos light_position 0
+   			  param_named_auto wCamPos camera_position
+   			  param_named normalCoord float 0
+   			}
+  			fragment_program_ref GTP/Demo/BumpMapped_PS
+  			{ 
+	  		  param_named_auto wLightPos light_position 0
+	  		  param_named_auto wLightDir light_direction 0 			  
+  			  param_named_auto lightRange light_attenuation 0
+   			  param_named_auto lightPower light_power 0     			    			  
+   			}
+  }
+ }
+}
+
+material GreatPillarTrunk : DetailTexturedBumpBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			ambient 1 1 1 1
+			diffuse 1 1 1 1
+			specular 0.08264 0.08264 0.08264 2
+			emissive 0 0 0
+			texture_unit tile_texture
+			{
+				texture marble.jpg
+			}
+			texture_unit detail_texture
+			{
+				texture greatpillardetail.png
+			}
+			texture_unit displace
+			{
+				texture greatpillardisplace.dds
+			}
+		}
+	}
+}
+material GreatHallFloor : DetailTexturedBumpBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			IllumTechniques
+			{
+				RenderTechnique DepthShadowReceiver
+				{
+					//pass_blending none
+					max_light_count 1
+					vertex_program_name GTP/Basic/LightCPos_VS
+					fragment_program_name GTP/Basic/SM/Dist_POINT_VSM_PS
+					//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		
+				}
+			}				
+			ambient 1 1 1 1
+			diffuse 1 1 1 1
+			specular 0.57852 0.57852 0.57852 25.49
+			emissive 0 0 0
+			vertex_program_ref GTP/Demo/BumpMapped_VS
+   			{
+   				param_named normalCoord float 1
+   			}
+			
+			texture_unit tile_texture
+			{
+				texture greatHallFloorTile.jpg				
+			}
+			texture_unit detail_texture
+			{
+				texture greathallfloordetail.png
+			}
+			texture_unit displace
+			{
+				texture floornormal.jpg
+			}
+		}
+	}
+}
+material GreatHallWall : DetailTexturedBumpBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			ambient 1 1 1 1
+			diffuse 1 1 1 1
+			specular 0.08264 0.08264 0.08264 2
+			emissive 0 0 0
+
+			texture_unit tile_texture
+			{
+				texture moriaWall.png				
+			}
+			texture_unit detail_texture
+			{
+				texture greatHallWallDetail.png
+			}
+		}
+	}
+}
+material GreatHallPillarHead : DetailTexturedBumpBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			ambient 1 1 1 1
+			diffuse 1 1 1 1
+			specular 0.08264 0.08264 0.08264 2
+			emissive 0 0 0
+
+			texture_unit tile_texture
+			{
+				texture marble.jpg				
+			}
+			texture_unit detail_texture
+			{
+				texture pillarheaddetail.png
+			}
+		}
+	}
+}
+
+material GreatHallCeiling : DetailTexturedBumpBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			ambient 1 1 1 1
+			diffuse 1 1 1 1
+			specular 0.08264 0.08264 0.08264 2
+			emissive 0 0 0
+
+			texture_unit tile_texture
+			{
+				texture marble.jpg				
+			}
+			texture_unit detail_texture
+			{
+				texture moriaceilingdetail.png
+			}
+		}
+	}
+}
+
+
+material GTP/Moria/Smoke_L_Depth_Illum
+{
+	technique
+	{
+		pass
+		{	
+			IllumTechniques
+			{
+				RenderTechnique HPS
+				{
+					particle_script GTP/Moria/Smoke_Little
+					perspective false
+					vparam_radius baseRadius
+					update_interval 1				
+				}
+				RenderTechnique SphericalBillboard
+				{
+					texture_unit_id		1					
+				}			
+				RenderTechnique IllumVolume
+				{
+				    material GTP/HPS/Smoke_IllumVolume
+					update_interval 1
+					texture_unit_id 2
+					resolution 128
+					lightmatrix_param_name lightViewProj
+				}
+			}				
+			depth_check off			
+			depth_write off
+			scene_blend alpha_blend
+			vertex_program_ref GTP/HPS/Large_Depth_Illum_VS
+			{       
+				param_named_auto worldView worldview_matrix
+				param_named_auto worldViewInv inverse_worldview_matrix
+				param_named_auto Proj projection_matrix	
+				param_named_auto width viewport_width 	
+				param_named_auto height viewport_height
+				param_named baseRadius float 1	    										    
+			} 
+			fragment_program_ref GTP/HPS/Large_Depth_Illum_PS
+			{ 
+			
+			}			
+			//impostor texture
+			texture_unit
+			{
+				//filtering none
+			}
+			//scene depth texture
+			texture_unit
+			{
+				filtering none
+			}
+			//Ilumination volume
+			texture_unit
+			{
+				//filtering none
+			}
+		}
+	}
+}
+
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/troll.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/troll.material	(revision 2336)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/troll.material	(revision 2368)
@@ -1,3 +1,3 @@
-material phong2
+material phong22
 {
 	technique
@@ -14,5 +14,5 @@
 	}
 }
-material phong4
+material phong44
 {
 	technique
@@ -30,5 +30,5 @@
 	}
 }
-material phong1
+material phong11
 {
 	technique
@@ -49,5 +49,5 @@
 vertex_program TrollSkinningOneWeight cg
 {
-   source trollvs.cg
+   source trollvs.hlsl
    entry_point trollSkinning_One_Weight_vp
    profiles vs_2_0
@@ -55,5 +55,14 @@
 }
 
-material phong22
+vertex_program TrollSkinningSMGen cg
+{
+   source trollvs.hlsl
+   entry_point trollSkinning_SMGen_One_Weight_vp
+   profiles vs_2_0
+   includes_skeletal_animation true   
+}
+
+
+material trollShadowMapGen_POINT
 {
 	technique
@@ -61,9 +70,31 @@
 		pass
 		{
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.5 0.5 0.5 20
-			emissive 0 0 0
-			
+			vertex_program_ref TrollSkinningSMGen
+			{
+				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto viewMatrix view_matrix				
+			}
+		  fragment_program_ref GTP/Basic/CDistNorm_PS
+		   {	
+		    param_named_auto farPlane far_clip_distance
+		   }  
+		}
+	}
+}
+
+material trollBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
+			IllumTechniques
+			{
+				RenderTechnique Triggers
+				{
+					ILLUM_TRIGGER_SM_POINT trollShadowMapGen_POINT
+				}
+			}
 			vertex_program_ref TrollSkinningOneWeight
 			{
@@ -77,14 +108,17 @@
 			
 			}
-			// alternate shadow caster program
-			shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
+			texture_unit basetexture
 			{
-				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
-				param_named_auto viewProjectionMatrix viewproj_matrix
-				param_named_auto ambient ambient_light_colour
-			
 			}
-			
-			texture_unit
+		}
+	}
+}
+material phong2 : trollBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{			
+			texture_unit basetexture
 			{
 				texture eyeball.jpg
@@ -95,32 +129,11 @@
 	}
 }
-material phong44
+material phong4 : trollBase
 {
-	technique
+	technique maintechnique
 	{
-		pass
-		{
-			
-			vertex_program_ref TrollSkinningOneWeight
-			{
-				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
-				param_named_auto viewProjectionMatrix viewproj_matrix
-				param_named_auto lightPos[0] light_position 0
-				param_named_auto lightPos[1] light_position 1
-				param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
-				param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
-				param_named_auto ambient ambient_light_colour
-			
-			}
-			// alternate shadow caster program
-			shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
-			{
-				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
-				param_named_auto viewProjectionMatrix viewproj_matrix
-				param_named_auto ambient ambient_light_colour
-			
-			}
-
-			texture_unit
+		pass mainpass
+		{			
+			texture_unit basetexture
 			{
 				texture trollbody.png
@@ -131,32 +144,11 @@
 	}
 }
-material phong11
+material phong1 : trollBase
 {
-	technique
+	technique maintechnique
 	{
-		pass
-		{
-			
-			vertex_program_ref TrollSkinningOneWeight
-			{
-				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
-				param_named_auto viewProjectionMatrix viewproj_matrix
-				param_named_auto lightPos[0] light_position 0
-				param_named_auto lightPos[1] light_position 1
-				param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
-				param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
-				param_named_auto ambient ambient_light_colour
-			
-			}
-			// alternate shadow caster program
-			shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
-			{
-				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
-				param_named_auto viewProjectionMatrix viewproj_matrix
-				param_named_auto ambient ambient_light_colour
-			
-			}
-			
-			texture_unit
+		pass mainpass
+		{		
+			texture_unit basetexture
 			{
 				texture trollhead.png
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl	(revision 2368)
@@ -0,0 +1,99 @@
+//#define VARIANCE_SHADOW_MAPPING
+
+#define MAX_LIGHT 2
+#define MAX_CAU_CASTER 2
+#define SPOT_ANGLE 2.093
+#define SPOT_FALLOFF 1
+#define SHADOW_COLOR float4(0.3,0.3,0.3,1.0)
+#define SHADOW_BIAS_POINT 0.0001
+#define SHADOW_EPSILON_POINT 0.0001
+
+#include "illum.hlsl"
+
+uniform sampler2D tileTexture : register(s0);
+uniform sampler2D detailTexture : register(s1);
+uniform sampler2D bumpMap : register(s2);
+uniform sampler2D PathMap : register(s3);
+uniform sampler2D WeightIndexMap : register(s4);
+uniform sampler2D WeightMap : register(s5);
+uniform samplerCUBE ShadowMap1Point : register(s6);
+uniform samplerCUBE ShadowMap2Point : register(s7);
+
+uniform float4x4 WorldViewProj;
+uniform float4x4 World;
+uniform float4x4 WorldI;
+
+uniform float3 wCamPos;
+
+uniform float4x4 LightView[MAX_LIGHT];
+uniform float lightFarPlane[MAX_LIGHT];
+
+uniform float specularity;
+
+
+struct MORIA_HALL_BASE_VSOUT
+{
+	float4 hPos : POSITION;
+	float4 texCoord   	  : TEXCOORD0;
+	float2 bumpTexCoord   : TEXCOORD1;
+	float3 wView		  : TEXCOORD2;
+	float3 wTangent 	  : TEXCOORD3;
+	float3 wBinormal 	  : TEXCOORD4;
+	float3 wNormal 		  : TEXCOORD5;
+	float3 wPos			  : TEXCOORD6;	
+};
+
+MORIA_HALL_BASE_VSOUT MoriaHallBase_VS(float4 position :POSITION,
+										float3 normal :NORMAL,
+										float2 texCoord1 : TEXCOORD0,
+										float2 texCoord2 : TEXCOORD1,
+										float3 tangent   : TEXCOORD3,
+										uniform float normalCoord)
+{
+	MORIA_HALL_BASE_VSOUT OUT = (MORIA_HALL_BASE_VSOUT) 0;
+	
+	OUT.texCoord = float4(texCoord1.xy, texCoord2.xy);	
+	if(normalCoord == 0)
+		OUT.bumpTexCoord = texCoord1;
+	else
+		OUT.bumpTexCoord = texCoord2;
+		
+	OUT.hPos = mul(WorldViewProj, position);
+	OUT.wPos = mul(World, position);
+	
+	OUT.wView = wCamPos - OUT.wPos;
+	
+	OUT.wTangent = normalize(mul(float4(tangent, 1),WorldI)).xyz;
+	OUT.wNormal = normalize(mul(float4(normal, 1),WorldI)).xyz;		
+	OUT.wBinormal = cross(OUT.wTangent, OUT.wNormal).xyz;		
+		
+	return OUT;
+}
+
+float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN,
+						uniform float4 wLightPos,
+						uniform float4 lightRange,
+						uniform float lightPower,
+						uniform float4 lightColor):COLOR0
+{	
+	float4 Color = 0;
+	float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.bumpTexCoord, bumpMap);
+	float3 V = normalize(IN.wView);
+	// read textures
+	float4 diffuseColor = tex2D(tileTexture, IN.texCoord.zw) * tex2D(detailTexture, IN.texCoord.xy);
+		
+	//light dir
+	float3 L = wLightPos.xyz - IN.wPos * wLightPos.w;
+	//illumination
+	float4 col;
+	col = Illumination(N, L, V, lightColor * lightPower, lightRange, diffuseColor, specularity);
+	//shadowing
+	float3 lightCPos = mul(LightView[0], float4(IN.wPos, 1)).xyz;
+	float shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane[0]);
+	Color += col * shadow;	
+	
+	//do Path Map to gather indirect illumination
+	//gather caustics for all casters
+	//return diffuseColor;
+	return Color;
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material	(revision 2345)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material	(revision 2368)
@@ -1,17 +1,17 @@
-vertex_program GTP/Demo/BumpMapped_VS hlsl
-{
-   source bump.hlsl
-   entry_point BaseVS
+vertex_program GTP/MoriaDemo/MoriaHallBase_VS hlsl
+{
+   source MoriaHallBase.hlsl
+   entry_point MoriaHallBase_VS
    target vs_3_0
 }
 
-fragment_program GTP/Demo/BumpMapped_PS hlsl
-{
-   source bump.hlsl
-   entry_point BumpPS
+fragment_program GTP/MoriaDemo/MoriaHallBase_PS hlsl
+{
+   source MoriaHallBase.hlsl
+   entry_point MoriaHallBase_PS
    target ps_3_0
 }
 
-material DetailTexturedBumpBase
+material MoriaHallBase
 {
  technique maintechnique
@@ -21,57 +21,75 @@
   			IllumTechniques
 			{
-				RenderTechnique DepthShadowReceiver
-				{
-					//pass_blending none
+				//RenderTechnique PathMap
+			 	//{
+			    //	new_passes false
+				//	start_tex_id 3
+			  	//}	
+			 	RenderTechnique DepthShadowReceiver
+				{
 					max_light_count 1
-					vertex_program_name GTP/Basic/LightCPos_VS
-					fragment_program_name GTP/Basic/SM/Dist_POINT_VSM_PS
-					//fragment_program_name GTP/Basic/SM/Dist_VSM_PS
+					set_light_viewproj false
 					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
-			 	{
-			      pass_blending dest_alpha one
-			     //pass_blending none
-			     //pass_blending add
-			  	}			   	
-			  	
+					new_passes false
+					start_tex_id 6
+				}			  	
 		  	}
-   			vertex_program_ref GTP/Demo/BumpMapped_VS
+   			vertex_program_ref GTP/MoriaDemo/MoriaHallBase_VS
    			{
    			  param_named_auto WorldViewProj worldviewproj_matrix  
    			  param_named_auto World world_matrix
    			  param_named_auto WorldI inverse_world_matrix
-   			  param_named_auto wLightPos light_position 0
    			  param_named_auto wCamPos camera_position
    			  param_named normalCoord float 0
    			}
-  			fragment_program_ref GTP/Demo/BumpMapped_PS
+  			fragment_program_ref GTP/MoriaDemo/MoriaHallBase_PS
   			{ 
 	  		  param_named_auto wLightPos light_position 0
-	  		  param_named_auto wLightDir light_direction 0 			  
-  			  param_named_auto lightRange light_attenuation 0
-   			  param_named_auto lightPower light_power 0     			    			  
+   			  //param_named_auto wLightPos light_position 1   			  
+	  		  param_named_auto lightRange light_attenuation 0
+  			  //param_named_auto lightRange[1] light_attenuation 1
+   			  param_named_auto lightPower light_power 0
+   			  //param_named_auto lightPower[1] light_power 1
+   			  param_named_auto lightColor light_diffuse_colour 0
+   			  //param_named_auto lightColor[1] light_diffuse_colour 1
+   			  param_named specularity float 120
    			}
+   			texture_unit tile_texture
+			{
+			}
+			texture_unit detail_texture
+			{
+			}
+			texture_unit displace
+			{
+			}
+			texture_unit pathMap
+			{
+			}
+			texture_unit PMweightIndex
+			{
+			}
+			texture_unit PMweight
+			{
+			}
+			texture_unit SM1
+			{
+			}
+			texture_unit SM2
+			{
+			}			
   }
  }
 }
 
-material GreatPillarTrunk : DetailTexturedBumpBase
-{
-	technique maintechnique
-	{
-		pass mainpass
-		{
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.08264 0.08264 0.08264 2
-			emissive 0 0 0
+material GreatPillarTrunk : MoriaHallBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
 			texture_unit tile_texture
 			{
@@ -89,16 +107,11 @@
 	}
 }
-material GreatHallFloor : DetailTexturedBumpBase
-{
-	technique maintechnique
-	{
-		pass mainpass
-		{
-							
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.57852 0.57852 0.57852 25.49
-			emissive 0 0 0
-			vertex_program_ref GTP/Demo/BumpMapped_VS
+material GreatHallFloor : MoriaHallBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{			
+			vertex_program_ref GTP/MoriaDemo/MoriaHallBase_VS
    			{
    				param_named normalCoord float 1
@@ -120,15 +133,10 @@
 	}
 }
-material GreatHallWall : DetailTexturedBumpBase
-{
-	technique maintechnique
-	{
-		pass mainpass
-		{
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.08264 0.08264 0.08264 2
-			emissive 0 0 0
-
+material GreatHallWall : MoriaHallBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
 			texture_unit tile_texture
 			{
@@ -142,15 +150,10 @@
 	}
 }
-material GreatHallPillarHead : DetailTexturedBumpBase
-{
-	technique maintechnique
-	{
-		pass mainpass
-		{
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.08264 0.08264 0.08264 2
-			emissive 0 0 0
-
+material GreatHallPillarHead : MoriaHallBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
 			texture_unit tile_texture
 			{
@@ -165,15 +168,10 @@
 }
 
-material GreatHallCeiling : DetailTexturedBumpBase
-{
-	technique maintechnique
-	{
-		pass mainpass
-		{
-			ambient 1 1 1 1
-			diffuse 1 1 1 1
-			specular 0.08264 0.08264 0.08264 2
-			emissive 0 0 0
-
+material GreatHallCeiling : MoriaHallBase
+{
+	technique maintechnique
+	{
+		pass mainpass
+		{
 			texture_unit tile_texture
 			{
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/trollvs.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/trollvs.hlsl	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/trollvs.hlsl	(revision 2368)
@@ -0,0 +1,52 @@
+void trollSkinning_One_Weight_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float  blendIdx : BLENDINDICES,
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	uniform float3x4   worldMatrix3x4Array[67],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) 
+	//	+(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1])
+	;
+	
+}	
+
+
+void trollSkinning_SMGen_One_Weight_vp(
+	float4 position : POSITION,
+	float  blendIdx : BLENDINDICES,
+	out float4 oPosition : POSITION,
+	out float3 cPos:TEXCOORD0,	
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[67],
+	uniform float4x4 viewMatrix,
+	uniform float4x4 viewProjectionMatrix)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	cPos = mul(viewMatrix, blendPos).xyz;
+	oPosition = mul(viewProjectionMatrix, blendPos);	
+}	
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/illum.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/illum.hlsl	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/illum.hlsl	(revision 2368)
@@ -0,0 +1,54 @@
+
+float4 Illumination(float3 N, float3 L, float3 V, float4 lightColor, float4 lightRange, float4 diffuseColor, float specularity)
+{
+	// Blinn lighting
+	float d = length(L);
+	L = normalize(L);
+	float3 H = normalize(L + V);
+	float4 Lighting = lit(dot(N, L), dot(N, H), specularity);
+	
+	return   lightColor * (Lighting.y * diffuseColor + Lighting.z) //color
+			 / (lightRange.y + d * lightRange.z + d * d * lightRange.w) //attenuation
+			 ;
+}
+
+float3 NormalMap(float3 tangent, float3 binormal, float3 normal, float2 texCoord, sampler2D normalMap)
+{	
+	normal = normalize(normal);	
+	//return normal;
+	float3 mNormal;
+	float3 tNormal = tex2D(normalMap, texCoord).rgb;
+	if(length(tNormal == 0))	
+		mNormal = normal;
+    else
+    {
+    	tangent = normalize(tangent);
+		binormal = normalize(binormal);	
+		float3x3 TangentToModel = float3x3(tangent, binormal, normal );
+		
+    	tNormal.xy = (tNormal.xy *2.0) - 1.0;
+    	mNormal = normalize( mul( tNormal, TangentToModel ) );
+	}
+    return mNormal;
+}
+
+
+float shadowPoint(samplerCUBE shadowMap, float3 lightCPos, float lightFarPlane)
+{
+	  float light = 1;
+	  
+	  float dist = length(lightCPos) / lightFarPlane;
+	  float4 storedDist = texCUBE(shadowMap, float3(lightCPos.xy, -lightCPos.z));
+	  dist -= SHADOW_BIAS_POINT;
+	  float lit_factor = (dist <= storedDist.r);	
+	    	 
+	  float M1 = storedDist.r;
+	  float M2 = storedDist.g;
+	  float v2 = min(max(M2 - M1 * M1, 0.0) +  SHADOW_EPSILON_POINT, 1.0);
+	  float m_d = M1 - dist;
+	  float pmax = v2 / (v2 + m_d * m_d);
+							
+	  light = max(lit_factor, pmax);   	
+	  	  
+	  return (SHADOW_COLOR + (1 - SHADOW_COLOR) * light);
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/trollvs.cg
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/trollvs.cg	(revision 2336)
+++ 	(revision )
@@ -1,37 +1,0 @@
-void trollSkinning_One_Weight_vp(
-	float4 position : POSITION,
-	float3 normal   : NORMAL,
-	float2 uv       : TEXCOORD0,
-	float  blendIdx : BLENDINDICES,
-	
-
-	out float4 oPosition : POSITION,
-	out float2 oUv       : TEXCOORD0,
-	out float4 colour           : COLOR,
-	// Support up to 24 bones of float3x4
-	// vs_1_1 only supports 96 params so more than this is not feasible
-	uniform float3x4   worldMatrix3x4Array[67],
-	uniform float4x4 viewProjectionMatrix,
-	uniform float4   lightPos[2],
-	uniform float4   lightDiffuseColour[2],
-	uniform float4   ambient)
-{
-	// transform by indexed matrix
-	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
-	// view / projection
-	oPosition = mul(viewProjectionMatrix, blendPos);
-	// transform normal
-	float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal);
-	// Lighting - support point and directional
-	float3 lightDir0 = 	normalize(
-		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
-	float3 lightDir1 = 	normalize(
-		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
-
-	oUv = uv;
-	colour = ambient + 
-		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) 
-	//	+(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1])
-	;
-	
-}	
