Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Sprite.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Sprite.hlsl	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Sprite.hlsl	(revision 2024)
@@ -0,0 +1,142 @@
+/////////
+///This example shader demonstrates how to use the sprite particle type added by the GTP to OGRE's particle types.
+///These sprites are quads with zero size, they should be scaled and rotated towards the camera by the vertex shader.
+///All four vertices of the quad are placed in the center of the particle, the z and w components of their texture coordinates
+///gives us the offset they should be moved in camera space (these components store the corner direction multiplied by the particle size).
+///The x and y components of the texture coordinates store the defult uv for texturing.
+////////
+struct VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 texCoord		: TEXCOORD0;
+	float4 color		: COLOR0;
+};
+
+VS_OUT Sprite_VS(float4 position : POSITION,	
+		float4 texCoord : TEXCOORD0,
+		float4 color 	: COLOR0,
+		uniform float4x4 worldView,
+		uniform float4x4 Proj)
+{
+  VS_OUT OUT;
+///transform to camera space and create a sprite with vertex offset
+   //texCoord.y = 1.0 - texCoord.y;
+   float2 offset = texCoord.zw;
+   float4 cPosition = mul(worldView, position);
+   cPosition.xy += offset;
+   
+   cPosition = float4(100*texCoord.xy,0,1);
+ ///projection 
+	OUT.hPosition = mul( Proj, cPosition );
+   OUT.texCoord = texCoord;
+  // OUT.color = float4(offset,1,1.0);
+   OUT.color = color;
+
+  return OUT;
+}
+
+///Simple texture mapping
+float4 Sprite_PS(VS_OUT IN ,
+		uniform sampler2D colorTexture : register(s0)):COLOR
+{
+	return 1;
+	return tex2D( colorTexture, IN.texCoord.xy) * IN.color;
+}
+
+//////////
+///These shaders uses the sprite particle type. They demonstrate the "spherical billboards" (SBB) particle rendering method.
+///SBB alter the opacity of a particle according to the objects of the scene it intersects. To find out the correct opacity
+///we store scene depth values in a previous step, we assume that the particle is sphere shaped and find the length of the viewray
+///that travells inside a particle before reaching an object.
+//////////
+struct SBB_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 texCoord		: TEXCOORD0;
+	float3 P		: TEXCOORD1;
+	float3 Q		: TEXCOORD2;
+	float r			: TEXCOORD3;
+	float2 screenCoord	: TEXCOORD4;	
+	float4 color		: COLOR0;
+};
+
+SBB_VS_OUT SBB_Sprite_VS (float4 position : POSITION,	
+		float4 texCoord : TEXCOORD0,
+		float4 color 	: COLOR,
+		uniform float width,
+		uniform float height,
+		uniform float4x4 worldView,
+		uniform float4x4 Proj)
+{
+	SBB_VS_OUT OUT;
+ ///transform to camera space and create a sprite with vertex offset 
+	float2 offset = texCoord.zw;
+	float4 cPosition;   
+	float4 wPosition = position;    
+	cPosition = mul(worldView, wPosition);
+/// P is the particle sphere center	
+	OUT.P = cPosition.xyz;
+	OUT.P.z = - 1 * OUT.P.z;
+	cPosition.xy += offset;
+/// Q is the shaded point (it is moved backwards to avoid unwanted frontplane clipping)				
+	OUT.Q = cPosition.xyz;	
+	OUT.Q.z = OUT.P.z;
+	OUT.r = abs(texCoord.z);   
+/// calculate screen space position 
+   OUT.hPosition = mul( Proj, cPosition );
+   OUT.screenCoord =  (OUT.hPosition.xy / OUT.hPosition.w + 1.0) / 2.0;
+   OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
+   OUT.screenCoord += float2(0.5/width, 0.5/height);   
+   
+   OUT.texCoord = texCoord;
+   OUT.color = color;
+
+  return OUT;
+} 
+
+
+float4 SBB_Sprite_PS(SBB_VS_OUT IN ,
+	//	in screenCoord : VPOS,
+	    uniform float nearplane,
+	    uniform float farplane,
+		uniform sampler2D colorTexture : register(s0),
+		uniform sampler2D DepthMap : register(s1),
+		uniform sampler2D PlanckMap : register(s2)
+		) : COLOR
+{
+	float4 Color = IN.color;
+	float alpha = 0;
+	
+/// get the depth values from the depthMap and calculate ray length in sphere	
+	float d = length( IN.Q - IN.P );
+	float Zs;
+	if( d < IN.r )
+	{
+	 
+	 float w = sqrt( IN.r * IN.r - d * d );
+	 alpha = w / IN.r;
+	 alpha *= pow( (IN.r-d) / IN.r , 2);
+	
+	 float F = IN.Q.z - w;
+	 float B = IN.Q.z + w; 
+	 
+
+	 Zs = tex2D( DepthMap, IN.screenCoord ).r;
+	 if(Zs == 0) Zs = farplane;
+	 float ds = min( Zs, B ) - max( nearplane, F );	 
+	// float ds = min( Zs, B ) - F;	 
+	 alpha *=  ds / w * 0.5;
+	
+	
+	}
+/// fetch opacity from a texture
+	Color.a *= tex2D( colorTexture, IN.texCoord.xy).r ;
+	//Color.a *= IN.color.a;
+	Color.a *= alpha;
+/// address a color map (colors of fire eg.) with the alpha
+	Color.rgb = tex2D( PlanckMap, Color.aa).rgb;
+	
+	return Color; 
+}
+
+
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.particle
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.particle	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.particle	(revision 2024)
@@ -0,0 +1,116 @@
+GTP/SBB
+{
+	renderer sprite
+	material        GTP/SBB/Basic
+	particle_width  200
+    particle_height 200
+    cull_each       false
+    quota           30
+    
+    // Area emitter
+    emitter Box
+    {
+       // colour 0.7 0.8 0.3 0
+        colour_range_start 1 1 1 0
+		colour_range_end 0.8 1 0.5 0
+
+        angle           30
+        emission_rate   6
+        time_to_live    3
+        direction       0 1 0
+        velocity    	0
+        width           120
+        height          120
+        depth           30
+    }
+    // Make em float upwards
+    affector LinearForce
+    {
+        force_vector      0 40 0
+        force_application add
+    }
+    affector ColourFader2
+    {
+       alpha1 +0.5
+       alpha2 -0.5
+       state_change 0.5
+    }
+}
+
+GTP/HPS/Smoke_Large
+{
+	renderer sprite
+	
+	material		GTP/HPS/Smoke_L_Depth_Illum
+	particle_width  1.6
+    particle_height 1.6
+    cull_each       false
+    quota           200
+    sorted			true
+    billboard_type  point
+    
+    // Area emitter
+    emitter Box
+    {
+       colour 1 1 1 0
+       //colour_range_start 1 1 1 0
+	   //colour_range_end 1 1 1 0
+
+        angle           30
+        emission_rate   3
+        time_to_live    10
+        direction       0 1 0
+        velocity    	20
+        width           70       
+        height          70
+        depth           70
+    }
+    // Make em float upwards
+  //  affector LinearForce
+  //  {
+  //      force_vector      0 40 0
+  //      force_application add
+  //  }
+
+    affector ColourFader2
+    {
+       alpha1 +0.5
+       alpha2 -0.5
+       state_change 3
+    }
+}
+
+
+GTP/HPS/Smoke_Little
+{
+	material        GTP/HPS/Smoke_S
+	renderer sprite
+    particle_width  45
+    particle_height 45
+    cull_each       false
+    quota           400
+    billboard_type  point
+    
+    // Area emitter
+    emitter Ellipsoid
+    {
+        colour 1 1 1 0
+        //colour_range_start 1 1 1 0
+		//colour_range_end 1 1 1 0
+        angle           160
+        emission_rate   20
+        time_to_live    6
+        direction       0 1 0
+        velocity    	8 
+        
+        width           20        
+        height          20
+        depth           20   
+    }
+    affector ColourFader2
+    {
+       alpha1 +0.5
+       alpha2 -0.5
+       state_change 2
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_HPS.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_HPS.hlsl	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_HPS.hlsl	(revision 2024)
@@ -0,0 +1,399 @@
+struct HPS_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 cPosition	: TEXCOORD1;
+	float2 texCoord		: TEXCOORD0;
+	float r				: TEXCOORD2;	
+	float4 center		: TEXCOORD3;
+	float4 Color		: TEXCOORD4;
+};
+
+//////////////
+///This shader used when rendering an image of the small particle system of a HPS.
+///It stores max distance from the camera in the red channel, one minus min distance in the green channel
+/// and the opacity in the alpha channel.
+/////////////
+HPS_VS_OUT GTP_HPS_Small_VS (float4 position : POSITION,	
+									float4 texCoord : TEXCOORD0,
+									float4 Color: COLOR0,
+									uniform float4x4 worldView,
+									uniform float4x4 Proj)
+{
+	HPS_VS_OUT OUT;
+ ///transform vertices to camera space and create a sprite
+	float2 offset = texCoord.zw;
+	float4 cPosition;   
+	cPosition = mul(worldView, position);
+	OUT.center = cPosition;	
+	cPosition.xy += offset;				
+	OUT.cPosition = cPosition;
+	OUT.r = abs(texCoord.z);		
+ ///projection
+    OUT.hPosition = mul( Proj, cPosition );
+     
+    OUT.texCoord = texCoord.xy;
+    OUT.Color = Color;    
+	return OUT;
+} 
+
+
+float4 GTP_HPS_Small_PS(HPS_VS_OUT IN,
+						uniform float4x4 Proj,
+						uniform sampler2D Texture	) : COLOR
+{
+	float4 Color = 0;
+	float f = 0;
+	float b = 1;
+	float alpha = 0;
+
+///calculate back and front distances		
+	float d = length( IN.cPosition.xy- IN.center.xy);
+	
+	if( d < IN.r )
+	{	 
+	 float w = sqrt( IN.r * IN.r - d * d );
+	 float4 fPosition = IN.cPosition;
+	 float4 bPosition = IN.cPosition;
+	 fPosition.z -= w;
+	 bPosition.z += w;
+	 fPosition = mul(Proj, fPosition);
+	 bPosition = mul(Proj, bPosition);
+	 f = fPosition.z / fPosition.w;
+	 b = bPosition.z / bPosition.w;
+	 
+	// alpha = pow(w / IN.r, 4);		
+	}
+	else
+	 discard;
+	
+	Color.r = b;
+	Color.g = 1 - f;
+	
+	alpha = 1;
+	Color.a = alpha * IN.Color.a;
+	Color.a *= tex2D(Texture, IN.texCoord).r * 0.7;
+	
+	
+	return Color; 
+}
+
+//////////////
+///This shader renders a HPS, the image of the smaller system is passed to the fragment shader
+/////////////
+HPS_VS_OUT HPS_Large_VS (float4 position : POSITION,	
+							float4 texCoord : TEXCOORD0,
+							float4 Color: COLOR0,
+							uniform float baseRadius,
+							uniform float4x4 worldView,
+							uniform float4x4 Proj)
+{
+///transform vertices to camera space and create a sprite
+	HPS_VS_OUT OUT;
+    float2 offset = texCoord.zw * baseRadius;
+	float4 cPosition;   
+	cPosition = mul(worldView, position);
+	OUT.center = cPosition;	
+	cPosition.xy += offset;				
+	OUT.cPosition = cPosition;
+	OUT.r = abs(offset.x);		
+ ///project
+    OUT.hPosition = mul( Proj, cPosition );
+     
+    OUT.texCoord = texCoord.xy;  
+    OUT.Color = Color;  
+	return OUT;
+} 
+
+
+float4 HPS_Large_PS(HPS_VS_OUT IN,
+					uniform sampler2D Texture	) : COLOR
+{
+	float4 Color = 0;
+	Color = tex2D(Texture, IN.texCoord);
+	Color = float4(1, 1, 1, Color.a) * IN.Color;
+	return Color; 
+}
+
+//////////////
+///This shader renders a HPS with depth calculation, the scene distance map is passed to the fragment shader
+/////////////
+struct HPS_DEPTH_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 cPosition	: TEXCOORD1;
+	float2 texCoord		: TEXCOORD0;
+	float r				: TEXCOORD2;	
+	float4 center		: TEXCOORD3;
+	float4 Color		: TEXCOORD4;	
+	float2 screenCoord	: TEXCOORD5;
+};
+
+HPS_DEPTH_VS_OUT HPS_Large_Depth_VS (float4 position : POSITION,	
+									float4 texCoord : TEXCOORD0,
+									float4 Color: COLOR0,
+									uniform float baseRadius,
+									uniform float4x4 worldView,
+									uniform float4x4 Proj)
+{
+///transform vertices to camera space and create a sprite
+	HPS_DEPTH_VS_OUT OUT;
+	float2 offset = texCoord.zw * baseRadius;
+	OUT.r = abs(offset.x);
+	float4 cPosition;   
+	cPosition = mul(worldView, position);
+	OUT.center = cPosition;	
+	cPosition.xy += offset;	
+	OUT.cPosition = cPosition;
+	OUT.cPosition.z += baseRadius;
+	OUT.cPosition.z *= -1;
+///projection
+    OUT.hPosition = mul( Proj, cPosition );
+///calculate screen space coordinates	
+    float4 sPosition = OUT.hPosition / OUT.hPosition.w;
+    OUT.screenCoord = (sPosition.xy + float2(1, 1)) / 2.0;
+    OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
+     
+    OUT.texCoord = texCoord.xy;  
+    OUT.Color = Color;  
+	return OUT;
+} 
+
+
+float4 HPS_Large_Depth_PS(HPS_DEPTH_VS_OUT IN,
+						uniform sampler2D Texture  : register(s0),
+						uniform sampler2D depthTexture : register(s1),
+						uniform sampler2D illumVolume : register(s2),
+						uniform float farplane,
+						uniform float nearplane						
+							) : COLOR
+{
+	float4 Color = 0;
+	float4 impostor = tex2D(Texture, IN.texCoord);
+	float f = 1.0 - impostor.g;
+	float b = impostor.r;
+	float alpha = 0;
+	
+	if(b == 0)
+		discard;	
+////altering opacity according to scene depth
+	float sceneDepth = tex2D(depthTexture, IN.screenCoord).r;
+	if(sceneDepth == 0)
+		sceneDepth = farplane;
+	   
+	float size = 2.0 * IN.r;
+	float frontDepth = IN.cPosition.z + size * (f - 0.5);
+	float backDepth = IN.cPosition.z +  size * (b - 0.5);
+	
+	float far = min(sceneDepth, backDepth);
+	float near = max(frontDepth, nearplane);
+	
+	alpha = (far - near) / (backDepth - frontDepth);
+	alpha = saturate(alpha) * impostor.a;
+	
+///final color	
+	Color = float4(1, 1, 1, alpha) * IN.Color;
+    return Color; 
+	
+}
+
+//////////////
+///This shader is used when rendering the illumination volume  of a HPS. Each color channel represents a layer of the volume.
+///The vertex shader decides if a color channel (ie. a layer) should be written.
+/////////////
+struct ILLUMVOLUME_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 texCoord		: TEXCOORD0;
+	float4 color		: COLOR0;
+};
+
+ILLUMVOLUME_VS_OUT HPS_IllumVolume_VS(float4 position : POSITION,	
+										float4 texCoord : TEXCOORD0,
+										float4 color 	: COLOR0,
+										uniform float baseRadius,
+										uniform float4x4 worldView,
+										uniform float4x4 Proj)
+{
+	ILLUMVOLUME_VS_OUT OUT;
+///transform vertices to camera space and create a sprite
+   texCoord.y = 1.0 - texCoord.y;
+   float2 offset = texCoord.zw * baseRadius;
+   float4 cPosition = mul(worldView, position);
+   cPosition.xy += offset;
+///project   
+   OUT.hPosition = mul( Proj, cPosition );
+   OUT.texCoord = texCoord;
+   OUT.color = color.a;
+////identify slices and set channels to zero if needed   
+   float z = OUT.hPosition.z / OUT.hPosition.w;
+	
+   float4 planes = float4(0.33, 0.5, 0.66, 1);
+   if(z > planes.x)
+	{
+		OUT.color.r = 0;
+	}
+	if(z > planes.y)
+	{
+		OUT.color.g = 0;
+	}
+	if(z > planes.z)
+	{
+		OUT.color.b = 0;
+	}
+	   
+   return OUT;
+}
+
+float4 HPS_IllumVolume_PS(ILLUMVOLUME_VS_OUT IN ,
+		uniform sampler2D colorTexture : register(s0),
+		uniform float density):COLOR //0.2
+{
+	return tex2D( colorTexture, IN.texCoord.xy).a * density * IN.color;
+}
+
+//////////////
+///This shader renders a HPS with depth calculation and with shading (light extintion).
+///The pixel shader identifies the two layers of the illumination volume between wich the shaded point is,
+/// and interpolates the stored extintion values.
+/////////////
+struct VS_OUT_DEPTH_ILLUM
+{
+	float4 hPosition	: POSITION;
+	float4 cPosition	: TEXCOORD1;
+	float2 texCoord		: TEXCOORD0;
+	float r				: TEXCOORD2;	
+	float4 center		: TEXCOORD3;
+	float4 Color		: TEXCOORD4;	
+	float2 screenCoord	: TEXCOORD5;
+	float4 lightCoord	: TEXCOORD6;
+};
+
+VS_OUT_DEPTH_ILLUM HPS_Large_Depth_Illum_VS (float4 position : POSITION,	
+												float4 texCoord : TEXCOORD0,
+												float4 Color: COLOR0,
+												uniform float width,
+												uniform float height,
+												uniform float baseRadius,
+												uniform float4x4 worldView,
+												uniform float4x4 worldViewInv,
+												uniform float4x4 lightViewProj,
+												uniform float4x4 Proj)
+{
+///transform vertices to camera space and create a sprite
+	VS_OUT_DEPTH_ILLUM OUT;
+	//texCoord.z = normalize(texCoord.z);
+	//texCoord.w = normalize(texCoord.w);
+    float2 offset = texCoord.zw * baseRadius;
+	OUT.r = abs(offset.x);
+	float4 cPosition;   
+	cPosition = mul(worldView, position);
+	OUT.center = cPosition;	
+	cPosition.xy += offset;	
+	OUT.cPosition = cPosition;
+	OUT.cPosition.z *= -1;
+	//OUT.cPosition.z = OUT.cPosition.z - OUT.r;	
+
+///	project
+    OUT.hPosition = mul( Proj, cPosition );
+/// calculate screen coordinates
+    float4 sPosition = OUT.hPosition / OUT.hPosition.w;
+    OUT.screenCoord = (sPosition.xy + float2(1.0, 1.0)) / float2(2.0, 2.0);
+    float2 halfpixel = float2(0.5 / width, 0.5 / height);
+    OUT.screenCoord += halfpixel;   
+    OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
+         
+    OUT.texCoord = texCoord.xy;  
+    OUT.Color = Color;
+///calculate ligth space coordinates
+    float4 wPosition = mul(worldViewInv, cPosition);
+    OUT.lightCoord = mul(lightViewProj, wPosition);
+	return OUT;
+} 
+
+
+float4 HPS_Large_Depth_Illum_PS(VS_OUT_DEPTH_ILLUM IN,
+						uniform sampler2D Texture  : register(s0),
+						uniform sampler2D depthTexture : register(s1),
+						uniform sampler2D illumVolume : register(s2)			
+							) : COLOR
+{
+	float4 Color = 0;
+	float4 impostor = tex2D(Texture, IN.texCoord);
+	float f = 1.0 - impostor.g;
+	float b = impostor.r;
+	float alpha = 0;
+	
+	if(b == 0)
+		discard;	
+////altering opacity according to scene depth
+	float sceneDepth = tex2D(depthTexture, IN.screenCoord).r;
+	if(sceneDepth == 0)
+	{
+		alpha = impostor.a;
+	}
+	else
+	{	
+		float size = 2.0 * IN.r;
+		float frontDepth = IN.cPosition.z + size * (f - 0.5);
+		float backDepth = IN.cPosition.z +  size * (b - 0.5);
+		
+		alpha = (sceneDepth - frontDepth) / (backDepth - frontDepth);
+		alpha = saturate(alpha) * impostor.a;
+	}
+///identify light volume slices and interpolation	
+	float2 lightCoord;
+	lightCoord = (IN.lightCoord.xy + float2(1.0, 1.0)) / 2.0;
+	lightCoord.y = 1.0 - lightCoord.y;
+	float z = IN.lightCoord.z / IN.lightCoord.w;
+		
+	float4 extintion = tex2D(illumVolume, lightCoord);
+	
+		float intensities[5];
+		intensities[0] = 1.0;
+		intensities[1] = extintion.r;
+		intensities[2] = extintion.g;
+		intensities[3] = extintion.b;
+		intensities[4] = extintion.a;
+			
+		float3 start;
+		float3 end;
+		float3 temp = 1.0;
+		float t;
+		
+		float4 planes = float4(0.33, 0.5, 0.66, 1);
+		if(z < planes.x)
+		{
+			start = intensities[0];
+			end = intensities[1];
+			t = z / planes.x;
+			temp = lerp(start, end, t);				
+		}
+		if(z > planes.x && z < planes.y)
+		{
+			start = intensities[1];
+			end = intensities[2];
+			t = (z - planes.x) / (planes.y - planes.x);
+			temp = lerp(start, end, t);					
+		}
+		if(z > planes.y && z < planes.z)
+		{
+			start = intensities[2];
+			end = intensities[3];
+			t = (z - planes.y) / (planes.z - planes.y);
+			temp = lerp(start, end, t);				
+		}
+		if(z > planes.z)
+		{
+			start = intensities[3];
+			end = intensities[4];
+			t = (z - planes.z) / (planes.a - planes.z);
+			temp = lerp(start, end, t);					
+		}
+		IN.Color.rgb *= temp;
+///final color	
+  
+	Color = float4(1, 1, 1, alpha) * IN.Color;
+    return Color;	
+}
+
+
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.program	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.program	(revision 2024)
@@ -0,0 +1,112 @@
+///Sprite frograms
+vertex_program GTP/Particles/SpriteVS hlsl
+{
+	source GTP_Sprite.hlsl
+	entry_point Sprite_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/Particles/SpritePS hlsl
+{
+	source GTP_Sprite.hlsl
+	entry_point Sprite_PS
+	target ps_2_0
+} 
+
+
+///spherical billboard sprite programs
+vertex_program GTP/Particles/SB_Sprite_VS hlsl
+{
+	source GTP_Sprite.hlsl
+	entry_point SBB_Sprite_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/Particles/SB_Sprite_PS hlsl
+{
+	source GTP_Sprite.hlsl
+	entry_point SBB_Sprite_PS
+	target ps_2_0
+}
+
+
+///hierarchical particle system programs
+
+ ///small system render
+vertex_program GTP/HPS/Small_VS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point GTP_HPS_Small_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/HPS/Small_PS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point GTP_HPS_Small_PS
+	target ps_2_0
+}
+
+
+ ///large system render default
+vertex_program GTP/HPS/Large_VS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/HPS/Large_PS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_PS
+	target ps_2_0
+} 
+
+
+ ///large system render with depth computation
+vertex_program GTP/HPS/Large_Depth_VS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_Depth_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/HPS/Large_Depth_PS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_Depth_PS
+	target ps_2_0
+}
+
+
+ ///illumination volume render
+vertex_program GTP/HPS/IllumVolume_VS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_IllumVolume_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/HPS/IllumVolume_PS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_IllumVolume_PS
+	target ps_2_0
+}
+
+
+ ///large system render with depth computation and illuminaltion volume shading
+vertex_program GTP/HPS/Large_Depth_Illum_VS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_Depth_Illum_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/HPS/Large_Depth_Illum_PS hlsl
+{
+	source GTP_HPS.hlsl
+	entry_point HPS_Large_Depth_Illum_PS
+	target ps_2_0
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.material	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPParticles/GTP_Particles.material	(revision 2024)
@@ -0,0 +1,275 @@
+material GTP/Particles/SpriteShader
+{ 
+   technique 
+   { 
+   	pass 
+      { 
+		cull_hardware none
+		depth_check off
+		scene_blend add
+		depth_write off
+		vertex_program_ref GTP/Particles/SpriteVS
+		{       
+			param_named_auto worldView worldview_matrix
+			param_named_auto Proj projection_matrix	    
+		} 
+		fragment_program_ref  GTP/Particles/SpritePS
+		{
+		 
+		}
+		texture_unit
+		{
+          texture flare.png
+		}
+       }
+    }
+}
+
+
+material GTP/SBB/Basic
+{ 
+   technique 
+   { 
+   	pass 
+    {    
+         IllumTechniques
+		 { 
+         	RenderTechnique SphericalBillboard
+		 	{
+		  		texture_unit_id		1					
+		 	}
+		 }	  
+		 scene_blend src_alpha one
+		 //scene_blend src_alpha one_minus_src_alpha
+		 depth_write off
+		 depth_check off	
+		 vertex_program_ref GTP/Particles/SB_Sprite_VS
+	     {       
+	        param_named_auto worldView worldview_matrix
+		    param_named_auto Proj projection_matrix
+		    param_named_auto width viewport_width 	
+		    param_named_auto height viewport_height 
+		 } 
+		 fragment_program_ref  GTP/Particles/SB_Sprite_PS
+	     { 
+	        param_named_auto farplane far_clip_distance	  
+		    param_named_auto nearplane near_clip_distance
+		 }
+		 texture_unit
+		 {
+		   anim_texture smokealpha.tga 32 2.0
+		   //texture flare.png
+		 }
+		 //scene depth texture
+		 texture_unit
+		 {
+		   filtering none
+		 }	
+		 texture_unit
+		 {
+		   texture planck.tga
+		 }
+    }
+   }
+}
+
+material GTP/HPS/Smoke_S
+{
+	technique
+	{
+		pass
+		{	
+			depth_check off
+			scene_blend_op max
+			scene_blend_op_alpha add
+			scene_blend_alpha one one_minus_src_alpha		
+			vertex_program_ref GTP/HPS/Small_VS
+			{       
+				param_named_auto worldView worldview_matrix
+				param_named_auto Proj projection_matrix   
+			} 
+			fragment_program_ref  GTP/HPS/Small_PS
+			{ 
+				param_named_auto Proj projection_matrix
+			}			
+			texture_unit
+			{
+				texture smoke2.jpg
+			}
+		}
+	}
+}
+
+material GTP/HPS/Smoke_L
+{
+	technique
+	{
+		pass
+		{	
+			IllumTechniques
+			{
+				RenderTechnique HPS
+				{
+					particle_script GTP/HPS/Smoke_Little
+					perspective false
+					vparam_radius baseRadius									
+				}								
+			}				
+			depth_check off			
+			scene_blend alpha_blend
+			vertex_program_ref GTP/HPS/Large_VS
+			{       
+				param_named_auto worldView worldview_matrix
+				param_named_auto Proj projection_matrix					    
+			} 
+			fragment_program_ref  GTP/HPS/Large_PS
+			{ 
+			
+			}
+			//impostor texture
+			texture_unit
+			{
+				
+			}
+		}
+	}
+}
+
+material GTP/HPS/Smoke_L_Depth
+{
+	technique
+	{
+		pass
+		{	
+			IllumTechniques
+			{
+				RenderTechnique HPS
+				{
+					particle_script GTP/HPS/Smoke_Little
+					perspective false
+					vparam_radius baseRadius
+					update_interval 1				
+				}
+				RenderTechnique SphericalBillboard
+				{
+					texture_unit_id		1					
+				}								
+			}				
+			depth_check off			
+			depth_write off
+			scene_blend alpha_blend
+			vertex_program_ref GTP/HPS/Large_Depth_VS
+			{       
+				param_named_auto worldView worldview_matrix
+				param_named_auto Proj projection_matrix	
+			} 
+			fragment_program_ref  GTP/HPS/Large_Depth_PS
+			{ 
+				param_named_auto farplane far_clip_distance
+				param_named_auto nearplane near_clip_distance				
+			}			
+			//impostor texture
+			texture_unit
+			{
+				//filtering none
+			}
+			//scene depth texture
+			texture_unit
+			{
+				filtering none
+			}
+		}
+	}
+}
+
+material GTP/HPS/Smoke_L_Depth_Illum
+{
+	technique
+	{
+		pass
+		{	
+			IllumTechniques
+			{
+				RenderTechnique HPS
+				{
+					particle_script GTP/HPS/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
+			}
+		}
+	}
+}
+
+material GTP/HPS/Smoke_IllumVolume
+{ 
+   technique 
+   { 
+   	pass 
+      { 		
+		cull_hardware none
+		cull_software none
+		lighting off
+		scene_blend zero one_minus_src_colour
+		depth_write off
+
+		vertex_program_ref GTP/HPS/IllumVolume_VS
+		{       
+			param_named_auto worldView worldview_matrix
+			param_named_auto Proj projection_matrix
+		} 
+		fragment_program_ref  GTP/HPS/IllumVolume_PS
+		{ 
+			param_named density float 0.2
+		}
+		texture_unit
+		{
+			texture pamacs.dds
+		}
+       }
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPGlow.compositor
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPGlow.compositor	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPGlow.compositor	(revision 2024)
@@ -0,0 +1,73 @@
+compositor GTP/PostProc/Glow
+{
+    technique
+    {
+        texture scene target_width target_height PF_FLOAT16_RGBA
+	texture cut 256 256 PF_FLOAT16_RGBA		        
+        texture rt0 256 256 PF_FLOAT16_RGBA        
+        texture rt1 256 256 PF_FLOAT16_RGBA
+        texture prev 256 256 PF_FLOAT16_RGBA
+   
+	target prev
+	{
+          input none
+	  only_initial on
+	  pass render_quad
+	  {
+	   material GTP/PostProc/Black				
+	  }
+	}		
+        target scene
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }		
+        target cut
+        {
+            input none			
+            pass render_quad
+            {
+               material GTP/PostProc/GlowCut
+               input 0 scene
+               input 1 prev
+            }
+        }
+        target rt0
+        {
+            input none          
+            pass render_quad
+            {
+                material GTP/PostProc/GlowBlurV
+                input 0 cut
+            }
+        } 
+        target rt1
+        {
+            input none         
+            pass render_quad
+            {
+               material GTP/PostProc/GlowBlurH
+               input 0 rt0
+            }
+	}
+        target prev        
+        {
+	   input none		    
+           pass render_quad
+           {
+		material GTP/PostProc/Copy
+		input 0 rt1				
+           }
+       }      
+       target_output
+       {
+         input none          
+         pass render_quad
+         {
+               material GTP/PostProc/Add
+               input 0 scene
+               input 1 rt1
+         }
+       }
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.material	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.material	(revision 2024)
@@ -0,0 +1,236 @@
+material GTP/PostProc/Black
+{
+   technique 
+   { 
+      pass 
+      {
+	 vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+	 fragment_program_ref GTP/PostProc/PostProc_Black_PS
+         { 
+	
+         }
+       }
+    }
+}
+
+material GTP/PostProc/Copy
+{
+   technique 
+   { 
+      pass 
+      {
+	vertex_program_ref GTP/PostProc/PostProc_VS
+        {
+       
+        } 
+	fragment_program_ref GTP/PostProc/Copy_PS
+        { 
+		param_named_auto width viewport_width 	
+	        param_named_auto height viewport_height 
+	        
+        }
+        texture_unit
+        {
+	   // filtering none	
+        }		 
+      }
+   }
+}
+
+material GTP/PostProc/Add
+{
+   technique 
+   { 
+      pass 
+      {
+	 vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+         fragment_program_ref GTP/PostProc/Add_PS
+         { 
+	     param_named_auto width viewport_width 	
+	     param_named_auto height viewport_height 
+	 }
+         texture_unit
+	 {
+	   // filtering none	  
+	 }
+	 texture_unit
+	 {
+	   // filtering none	
+	 }
+      }
+   }
+}
+
+material GTP/PostProc/Luminance
+{
+   technique 
+   { 
+      pass 
+      {
+         vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+         fragment_program_ref GTP/PostProc/Luminance_PS
+         { 
+	   param_named_auto width viewport_width 	
+	   param_named_auto height viewport_height 	        
+         }
+         
+         texture_unit
+	 {
+	    //filtering none	
+	 }		 
+		
+      }
+   }
+}
+
+material GTP/PostProc/GlowCut
+{
+   technique 
+   { 
+      pass 
+      {
+	vertex_program_ref GTP/PostProc/PostProc_VS
+        {       
+        } 
+	fragment_program_ref GTP/PostProc/GlowCut_PS
+        { 
+		param_named_auto width viewport_width 	
+	        param_named_auto height viewport_height
+		param_named cutValue float 10.0
+		//param_named cutValue float 4.5
+		param_named timeBlur float 0.4	        
+        }
+        texture_unit
+	{
+	    //filtering none
+	}
+	texture_unit
+	{
+	    //filtering none
+	}	
+      }
+   }
+}
+
+material GTP/PostProc/GlowBlurH
+{
+   technique 
+   { 
+      pass 
+      {
+	 vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+         fragment_program_ref GTP/PostProc/GlowBlurH_PS
+         { 
+	   param_named_auto width viewport_width 	
+	   param_named_auto height viewport_height 
+	   param_named Stretch float 1.5
+	   //param_named timeBlur float 0.5
+         }
+
+         texture_unit
+	 {
+	    tex_address_mode mirror 
+         }		 	
+      }
+   }
+}
+
+material GTP/PostProc/GlowBlurV
+{
+   technique 
+   { 
+      pass 
+      {
+         vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+         fragment_program_ref GTP/PostProc/GlowBlurV_PS
+         { 
+		param_named_auto width viewport_width 	
+	        param_named_auto height viewport_height 
+	        param_named Stretch float 1.5
+	        // param_named timeBlur float 0.5
+         }
+         texture_unit
+	 {
+	     tex_address_mode mirror 
+	     
+	 }		 
+      }
+   }
+}
+
+material GTP/PostProc/GlowBlurH_TB
+{
+   technique 
+   { 
+      pass 
+      {
+        scene_blend alpha_blend
+	vertex_program_ref GTP/PostProc/PostProc_VS
+        {       
+        } 
+	fragment_program_ref GTP/PostProc/GlowBlurH_PS
+        { 
+	  param_named_auto width viewport_width 	
+	  param_named_auto height viewport_height 
+	  param_named Stretch float 1.2
+	  param_named timeBlur float 0.025
+        }
+        texture_unit
+	{
+	  tex_address_mode mirror 
+        }		 
+      }
+   }
+}
+
+material GTP/PostProc/ToneMap
+{
+   technique 
+   { 
+      pass 
+      {
+	 vertex_program_ref GTP/PostProc/PostProc_VS
+         {
+       
+         } 
+	 fragment_program_ref GTP/PostProc/ToneMap_PS
+         { 
+		param_named_auto width viewport_width 	
+	        param_named_auto height viewport_height 
+	        param_named Gain float 0.5
+         }
+        
+         texture_unit
+	 {
+	   // filtering none
+	 }
+	 texture_unit
+	 {
+	   // filtering none	
+         }
+	 texture_unit
+	 {
+	   // filtering none
+	 }
+	 texture_unit
+	 {
+	   // filtering none
+	 }
+      }
+   }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.hlsl	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.hlsl	(revision 2024)
@@ -0,0 +1,159 @@
+struct VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float2 texCoord		: TEXCOORD0;	
+};
+
+VS_OUT Default_VS(float4 position : POSITION,	
+				float4 texCoord : TEXCOORD0)
+{
+   VS_OUT OUT;  
+   OUT.hPosition = float4(sign(position.xy),0,1);	
+   OUT.texCoord = (float2(OUT.hPosition.x, -OUT.hPosition.y) + 1.0) / 2.0;	
+   return OUT;
+}
+
+float4 Black_PS(VS_OUT IN):COLOR
+{
+   return float4(0,0,0,1);
+}
+
+float4 Copy_PS(VS_OUT IN,
+		uniform float width,
+		uniform float height,
+		uniform sampler2D Texture: register(s0)) : COLOR 
+{
+   IN.texCoord += float2(0.5/width, 0.5/height);
+   return tex2D(Texture, IN.texCoord);
+}
+
+float4 Add_PS(VS_OUT IN,
+		uniform float width,
+		uniform float height,
+		uniform sampler2D Texture1: register(s0),
+		uniform sampler2D Texture2: register(s1)
+		 ):COLOR
+{	
+   IN.texCoord += float2(0.5/width, 0.5/height);
+   return tex2D(Texture1,IN.texCoord ) + tex2D(Texture2,IN.texCoord );
+}
+
+half4 Luminance_PS(VS_OUT IN,
+		uniform half width,
+		uniform half height,
+		uniform sampler2D Texture: register(s0)
+		):COLOR
+{	
+   IN.texCoord += half2(0.5/width, 0.5/height);
+   half4 sample = tex2D(Texture,IN.texCoord );
+	
+   // D65 white conversion and weighting
+   half avg = sample.r * 0.21f + sample.g * 0.39f + sample.b * 0.4f;
+   return half4(avg, 0, 0, 1);
+}
+
+float4 GlowCut_PS(VS_OUT IN,
+		uniform float width,
+		uniform float height,
+		uniform float cutValue,
+		uniform float timeBlur,
+		uniform sampler2D Texture: register(s0)
+		,uniform sampler2D LastTexture: register(s1)
+		 ):COLOR
+{	
+   IN.texCoord += float2(0.5/width, 0.5/height);
+   float4 sample = 2.0 * tex2D(Texture,IN.texCoord );
+   float luminance = dot(sample.rgb, float3(1.0, 4.5907, 0.0601));
+   if (luminance < cutValue) sample = float4(0,0,0,0);
+   float alpha = timeBlur;
+   sample = sample * alpha + tex2D(LastTexture, IN.texCoord) * (1.0 - alpha);
+	
+   return sample;
+}
+
+float4 GlowBlurH_PS(VS_OUT IN,
+		uniform float Stretch,
+		uniform float width,
+		uniform float height,
+		uniform float timeBlur,
+		uniform sampler2D Texture: register(s0)) : COLOR
+{
+   float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
+   float4 texLookUp_h;
+			
+	/*texLookUp_h =	 tex2D(Texture, float2(tex0.x-(3.86979f*Stretch/width), tex0.y)) +
+					 tex2D(Texture, float2(tex0.x-(1.72291f*Stretch/width ), tex0.y)) +
+					 tex2D(Texture, tex0) +
+					 tex2D(Texture, float2(tex0.x+(1.72291f*Stretch/width), tex0.y)) +
+					 tex2D(Texture, float2(tex0.x+(3.86979f*Stretch/width), tex0.y));*/
+	
+   texLookUp_h = tex2D(Texture, float2(tex0.x-(2.0*Stretch/width), tex0.y))  +
+		 tex2D(Texture, float2(tex0.x-(1.0*Stretch/width ), tex0.y)) +
+		 tex2D(Texture, tex0)                                        +
+		 tex2D(Texture, float2(tex0.x+(1.0*Stretch/width), tex0.y))  +
+		 tex2D(Texture, float2(tex0.x+(2.0*Stretch/width), tex0.y));
+
+   return float4(texLookUp_h.rgb / 5.0, timeBlur) ;
+}
+
+float4 GlowBlurV_PS(VS_OUT IN,
+		uniform float Stretch,
+		uniform float width,
+		uniform float height,
+		uniform float timeBlur,
+		uniform sampler2D Texture: register(s0)) : COLOR
+{
+  float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
+  float4 texLookUp_v;
+		
+           /*texLookUp_v =    tex2D(Texture, float2(tex0.x, tex0.y-(3.86979f*Stretch/height)))+
+					 tex2D(Texture, float2(tex0.x, tex0.y-(1.72291f*Stretch/height)))+
+					 tex2D(Texture, tex0)+
+					 tex2D(Texture, float2(tex0.x, tex0.y+(1.72291f*Stretch/height)))+
+					 tex2D(Texture, float2(tex0.x, tex0.y+(3.86979f*Stretch/height)));*/
+
+   texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(2*Stretch/height))) +
+		 tex2D(Texture, float2(tex0.x, tex0.y-(1*Stretch/height))) +
+		 tex2D(Texture, tex0)                                      +
+		 tex2D(Texture, float2(tex0.x, tex0.y+(1*Stretch/height))) +
+		 tex2D(Texture, float2(tex0.x, tex0.y+(2*Stretch/height)));
+	
+   return float4(texLookUp_v.rgb / 5.0, timeBlur);
+}
+
+float4 ToneMap_PS(VS_OUT IN,
+		uniform half width,
+		uniform half height,
+		uniform half Gain,
+		uniform sampler2D Scene: register(s0),
+		uniform sampler2D AvrLuminanceTexture: register(s1),
+		uniform sampler2D LuminanceTexture: register(s2),
+		uniform sampler2D GlobalLuminanceTexture: register(s3)
+		 ):COLOR
+{	
+	IN.texCoord += half2(0.5/width, 0.5/height);
+	
+	float gLum = tex2D(GlobalLuminanceTexture, float2(0.5,0.5)).r;
+	gLum = max(gLum, 0.31415);
+	
+	// Automatic key calculation
+	//half Key = 1.03f - 2.0f / (2.0f + log10(tex2D(AvrLuminanceTexture, IN.texCoord).r + 1.0f));	
+	//half Key = 1 / (tex2D(AvrLuminanceTexture, IN.texCoord).r / 1 + tex2D(AvrLuminanceTexture, IN.texCoord).r);
+	//return 1 / Key;
+	// Relative luminance
+	//half RelLum =  Key* tex2D(LuminanceTexture, IN.texCoord).r / 
+	//					  tex2D(AvrLuminanceTexture, IN.texCoord).r;
+	half Key = 1.03f - 2.0f / (2.0f + log10(gLum + 1.0f));	
+	half RelLum =  Key* tex2D(LuminanceTexture, IN.texCoord).r / gLum;
+	half Lum = RelLum / (1 + RelLum);
+	// Color weghting
+	half4 Color = tex2D(Scene, IN.texCoord) /  gLum * 0.4f;
+	// Gamma correction
+	
+	//Color = pow(Color * half4(1.05f, 0.97f, 1.27f, 1.0f), Gain);
+	return Color + 0.0000000000001 * Gain;
+	return float4(tex2D(GlobalLuminanceTexture, IN.texCoord).r,
+				  tex2D(GlobalLuminanceTexture, IN.texCoord).r,
+				  tex2D(GlobalLuminanceTexture, IN.texCoord).r,
+				  1);
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.program	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPPostProc.program	(revision 2024)
@@ -0,0 +1,62 @@
+vertex_program GTP/PostProc/PostProc_VS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point Default_VS
+	target vs_2_0
+} 
+
+fragment_program GTP/PostProc/PostProc_Black_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point Black_PS
+	target ps_2_0
+}
+
+fragment_program GTP/PostProc/Copy_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point Copy_PS
+	target ps_2_0
+} 
+
+fragment_program GTP/PostProc/Add_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point Add_PS
+	target ps_2_0
+} 
+
+fragment_program GTP/PostProc/Luminance_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point Luminance_PS
+	target ps_2_0
+}
+
+fragment_program GTP/PostProc/GlowCut_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point GlowCut_PS
+	target ps_2_0
+}
+
+fragment_program GTP/PostProc/GlowBlurH_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point GlowBlurH_PS
+	target ps_2_0
+} 
+
+fragment_program GTP/PostProc/GlowBlurV_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point GlowBlurV_PS
+	target ps_2_0
+}
+
+fragment_program GTP/PostProc/ToneMap_PS hlsl
+{
+	source GTPPostProc.hlsl
+	entry_point ToneMap_PS
+	target ps_2_0
+} 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPToneMap.compositor
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPToneMap.compositor	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPPostProc/GTPToneMap.compositor	(revision 2024)
@@ -0,0 +1,106 @@
+compositor GTP/PostProc/ToneMap
+{
+    technique
+    {
+        texture scene target_width target_height PF_FLOAT16_RGBA
+	texture luminance 256 256 PF_FLOAT16_RGBA		        
+        texture rt0 256 256 PF_FLOAT16_RGBA        
+        texture rt1 256 256 PF_FLOAT16_RGBA
+        texture rt2 128 128 PF_FLOAT16_RGBA
+        texture rt3 32 32 PF_FLOAT16_RGBA
+        texture rt4 8  8  PF_FLOAT16_RGBA
+        texture rt5 2  2  PF_FLOAT16_RGBA
+        
+        target scene
+        {
+            input previous		 
+        }
+        target luminance
+        {
+            input none           
+            pass render_quad
+            {
+                material GTP/PostProc/Luminance
+                input 0 scene
+            }
+        }
+        target rt0
+        {
+            input none            
+            pass render_quad
+            {
+                material GTP/PostProc/GlowBlurV
+                input 0 luminance
+            }
+        } 
+        target rt1
+        {
+            input none
+            pass render_quad
+            {
+               material GTP/PostProc/GlowBlurH
+                input 0 rt0			    
+            }
+	} 
+	target rt2
+        {
+            input none
+            pass render_quad
+            {
+               material GTP/PostProc/GlowBlurV
+               input 0 rt1			    
+            }
+	} 
+	target rt3
+        {
+            input none
+            pass render_quad
+            {
+               material GTP/PostProc/GlowBlurH
+               input 0 rt2			    
+            }
+	} 
+	target rt4
+        {
+            input none
+            pass render_quad
+            {
+               material GTP/PostProc/GlowBlurV
+               input 0 rt3			    
+            }
+        } 
+	target rt5
+	{
+	    input none
+	    only_initial on
+	    pass clear
+	    {
+	    }
+	}
+	target rt5
+        {
+            input none            
+            pass render_quad
+            {
+	      clear
+	      {
+	        buffers depth
+	      }
+              material GTP/PostProc/GlowBlurH_TB
+              input 0 rt4			    
+            }
+	} 
+	target_output
+        {
+          input none
+          pass render_quad
+          {
+              material GTP/PostProc/ToneMap
+              input 0 scene
+              input 1 rt1
+	      input 2 luminance
+	      input 3 rt5			
+          }
+        }
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.programs
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.programs	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.programs	(revision 2024)
@@ -0,0 +1,41 @@
+fragment_program GTP/Caustic/PhotonMapHitEnv_PS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point PhotonMapHitEnvPS
+   target ps_3_0
+}
+
+vertex_program GTP/Caustic/CauCube_PointSprite_VS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point CauCube_PointSprite_VS
+   target vs_3_0
+}
+
+fragment_program GTP/Caustic/CauCube_PointSprite_PS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point CauCube_PointSprite_VS
+   target ps_3_0
+}
+
+vertex_program GTP/Caustic/CauCube_Triangles_VS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point CauCube_Triangles_VS
+   target vs_3_0
+}
+
+fragment_program GTP/Caustic/CauCube_Triangles_PS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point CauCube_Triangles_PS
+   target ps_3_0
+}
+
+fragment_program GTP/Caustic/GatherCaustic_Cube_PS hlsl
+{
+   source GTPCaustic.hlsl
+   entry_point GatherCaustic_Cube_PS
+   target ps_3_0
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.materials
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.materials	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.materials	(revision 2024)
@@ -0,0 +1,81 @@
+material GTP/Caustic/PhotonMap_HitEnv
+{
+ technique
+ {
+  pass
+  {   
+   vertex_program_ref GTP/Basic/Shaded_VS
+   {
+     param_named_auto WorldViewProj worldviewproj_matrix
+     param_named_auto World         world_matrix
+     param_named_auto WorldInv      inverse_world_matrix
+   } 
+   vertex_program_ref GTP/Caustic/PhotonMapHitEnv_PS
+   {
+     param_named_auto cameraPos camera_position
+     param_named float3 lastCenter 0 0 0
+     param_named float  reflIndex 0.85	
+   }
+  }
+ }
+}
+
+material GTP/Caustic/CauCube_PointSprite
+{
+ technique
+ {
+  pass
+  { 
+   cull_hardware none
+   scene_blend src_alpha one
+   depth_check off
+   point_sprites on
+   vertex_program_ref GTP/Caustic/CauCube_PointSprite_VS
+   {
+     param_named_auto WorldView     worldview_matrix
+     param_named_auto Proj          proj_matrix
+     param_named CauSpriteSize      float 20.0
+   } 
+   vertex_program_ref GTP/Caustic/CauCube_PointSprite_PS
+   {
+     param_named CausticColor float4          0.7 0.7 0.5 0.15
+   }
+   texture_unit
+   {
+     vertex_texture true	 
+   }
+   texture_unit
+   {
+     texture PowerOfPhotonHitTexel.dds
+   }
+
+  }
+ }
+}
+
+material GTP/Caustic/CauCube_Triangles
+{
+ technique
+ {
+  pass
+  { 
+   cull_hardware none
+   scene_blend src_alpha one
+   depth_write off
+   vertex_program_ref GTP/Caustic/CauCube_Triangles_VS
+   {
+     param_named_auto WorldView      worldview_matrix
+     param_named_auto Proj           proj_matrix
+     param_named PhotonMapResolution float 64
+   } 
+   vertex_program_ref GTP/Caustic/CauCube_Triangles_PS
+   {
+     param_named CausticColor float4 0.7 0.7 0.5 1
+   }
+   texture_unit
+   {
+     vertex_texture true	 
+   }
+  }
+ }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl	(revision 2024)
@@ -0,0 +1,265 @@
+struct Shaded_OUT
+{
+ float4 vPos : POSITION;
+ float4 wNormal : TEXCOORD0;
+ float4 wPos    : TEXCOORD1; 
+};
+
+/////////
+/// Photon Map shaders
+/////////
+float readDistanceCubeMap(samplerCUBE dcm, float3 coord)		
+{
+	float dist = texCUBE(dcm, float4(coord.xy, - coord.z, 0)).r;
+	if(dist == 0) dist = 1000; ///sky
+	return dist;
+}
+
+#define SECANT_ITERATIONCOUNT 2
+
+///Localization with secant iteration
+float3 Hit( float3 x, float3 R, samplerCUBE mp )
+{
+	float rl = readDistanceCubeMap( mp, R);				// |r|
+	
+	float ppp = length( x ) /  readDistanceCubeMap( mp, x);			// |p|/|p|
+	float dun = 0, pun = ppp, dov = 0, pov = 0;
+	float dl = rl * ( 1 - ppp );							// eq. 2
+	float3 l = x + R * dl;									// ray equation
+
+	// iteration
+	for( int i = 0; i < SECANT_ITERATIONCOUNT; i++ )
+	{
+		float llp = length( l ) / readDistanceCubeMap( mp, l);		// |l|/|l|
+		if ( llp < 0.999f )									// undershooting
+		{
+			dun = dl; pun = llp;							// last undershooting
+			dl += ( dov == 0 ) ? rl * ( 1 - llp ) :			// eq. 2
+				( dl - dov ) * ( 1 - llp ) / ( llp - pov );	// eq. 3
+		} else if ( llp > 1.001f )							// overshooting
+		{
+			dov = dl; pov = llp;							// last overshooting
+			dl += ( dl -dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3
+		}
+		l = x + R * dl;										// ray equation
+	}
+	return l;												// computed hit point
+}
+
+//Hit the environment sampled by DistanceMap (single refraction)
+float4 PhotonMapHitEnvPS(  Shaded_OUT IN,
+                           uniform float3 lastCenter,
+		                   uniform float3 cameraPos,
+		                   uniform float reflIndex,
+		                   uniform samplerCUBE DistanceMap : register(s0)):COLOR0
+{
+	
+	float4 Color = float4(1,1,1,1);
+	float3 wNormal = normalize(IN.wNormal);
+	float3 dir;	
+	float3 cubeMapPos = IN.wPos.xyz - lastCenter;
+	float3 V = normalize(IN.wPos.xyz - cameraPos);
+		
+	float3 R = refract(V, wNormal, reflIndex);		
+	
+	dir = R;			
+	dir = Hit(cubeMapPos, R, DistanceMap);
+		
+	Color = float4(dir, 1);
+	
+	if(dot(V, wNormal)>0)
+	{
+		Color = float4(1,0,0,0);		
+	}		
+	return Color;
+}
+
+//////
+/// Caustic CubeMap shaders
+//////
+
+///point sprite caustic spots
+struct CauCube_PointSprite_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 texCoord		: TEXCOORD0;
+	float4 color		: COLOR0;
+	float2 r			: TEXCOORD1;
+	float2 center		: TEXCOORD2;
+	float4 position		: TEXCOORD3;
+	float pSize			: PSIZE;
+	float dist			: TEXCOORD4;
+};
+
+CauCube_PointSprite_VS_OUT CauCube_PointSprite_VS(
+								float4 position : POSITION,	
+								float4 texCoord : TEXCOORD0,
+								float4 color 	: COLOR0,
+								uniform float4x4 WorldView,
+								uniform float4x4 Proj,
+								uniform float CauSpriteSize,
+						        uniform sampler2D PhotonHitMap : register(s0))
+{
+  CauCube_PointSprite_VS_OUT OUT;
+     
+  float radius = CauSpriteSize;
+  OUT.pSize = radius;
+  float4 cPosition;  
+
+  float4 pos = tex2Dlod(PhotonHitMap, float4(position.x, 1.0 - position.y,0,0)).rgba;
+	
+  if(pos.a == 0)//no photon hit
+  {
+	OUT.center = 1000.0f;
+	OUT.position = OUT.hPosition = -1000.0f; //transform out of view
+  }
+  else
+  {
+   		float4 wPosition = float4(normalize(pos.xyz),1); 
+    
+		cPosition = mul(WorldView, wPosition);
+		OUT.center = cPosition.xy;
+		OUT.position = cPosition;	
+		OUT.hPosition = mul(Proj, cPosition);		
+  }	
+  
+  OUT.r.x = radius;
+  OUT.r.y = radius;
+  OUT.texCoord = texCoord;
+  OUT.color = float4(pos);
+  OUT.dist = length(pos.xyz);
+   
+  return OUT;
+}
+
+float4 CauCube_PointSprite_PS(CauCube_PointSprite_VS_OUT IN,
+								uniform float4 CausticColor,
+								uniform sampler2D intensityTex : register(s1)
+								 ):COLOR
+{
+  IN.color = CausticColor;
+  float intens = tex2D(intensityTex, IN.texCoord).r;
+  IN.color.a *= intens;
+  return IN.color;  
+}
+
+//transformed caustic caster
+
+struct CauCube_Triangles_VS_OUT
+{
+	float4 hPosition	: POSITION;
+	float4 color		: COLOR0;	
+};
+
+CauCube_Triangles_VS_OUT CauCube_Triangles_VS(
+				        float4 position : POSITION,	
+						float4 texCoord : TEXCOORD0,
+						float4 color 	: COLOR0,
+						uniform float4x4 WorldView,
+						uniform float4x4 Proj,
+						uniform float PhotonMapResolution,
+						uniform sampler2D PhotonHitMap : register(s0))
+{
+  CauCube_Triangles_VS_OUT OUT;
+     
+  float4 cPosition;
+  float pixel = 1.0 / PhotonMapResolution;   
+  float2 uv = float2(position.x, 1.0 - position.y);
+  float4 pos = tex2Dlod(PhotonHitMap, float4(uv,0,0)).rgba;
+
+   if(pos.a == 0)//no photon hit
+   {
+		OUT.color = float4(0,0,0,0);		
+		OUT.hPosition = float4(0, 0, -1000000, 1);
+   }
+   else
+   {
+   		float4 wPosition = float4(normalize(pos.xyz),1);    
+		cPosition = mul(WorldView, wPosition);
+		OUT.hPosition = mul(Proj, cPosition);
+		
+		float intensity = 0.25;
+		
+		//read four neighbours
+		float sumdist = 0;
+		float dist;
+		float valids = 0;
+		float4 pos1 = tex2Dlod(PhotonHitMap, float4(uv + float2(pixel, pixel),0,0));
+		if(pos1.a != 0)
+		{
+			dist = length(pos1.xyz - pos.xyz);
+			sumdist += dist;
+			valids++;
+		}			
+		
+		float4 pos2 = tex2Dlod(PhotonHitMap, float4(uv + float2(-pixel, pixel),0,0));
+		if(pos2.a != 0)
+		{
+			dist = length(pos2.xyz - pos.xyz);
+			sumdist += dist;
+			valids++;
+		}
+		
+		float4 pos3 = tex2Dlod(PhotonHitMap, float4(uv + float2(pixel, -pixel),0,0));
+		if(pos3.a != 0)
+		{
+			dist = length(pos3.xyz - pos.xyz);
+			sumdist += dist;
+			valids++;
+		}
+		
+		float4 pos4 = tex2Dlod(PhotonHitMap, float4(uv + float2(-pixel, -pixel),0,0));
+		if(pos4.a != 0)
+		{
+			dist = length(pos4.xyz - pos.xyz);
+			sumdist += dist;
+			valids++;
+		}
+		//if(valids == 0) sumdist = 100000;		
+		float avrdist = sumdist / valids;
+		//float maxdist = 10;
+		//intensity = max(maxdist - avrdist, 0.0) / maxdist;
+		intensity = 60.0 / (avrdist * avrdist * 3.14);
+		//intensity = valids / 4.0;//avrdist;
+		
+		//OUT.color = float4(1,1,1,intensity);
+		OUT.color = intensity;
+	}  
+   
+   return OUT;
+}
+
+float4 CauCube_Triangles_PS(CauCube_Triangles_VS_OUT IN,
+		uniform float4 CausticColor ):COLOR
+{ 
+  return IN.color * CausticColor;  
+}
+
+///////
+/// Caustic gather shaders
+//////
+
+float4 GatherCaustic_Cube_PS(Shaded_OUT IN,
+				uniform samplerCUBE CauCubeMap : register(s0),
+				uniform samplerCUBE DistanceCubeMap : register(s1),
+				uniform float3 cubeMapCameraPosition,
+				uniform float attenuation):COLOR
+{
+	float4 Color = float4(1,1,1,1);	
+	
+	float3 dir = IN.wPos - cubeMapCameraPosition;
+	float4 caustic = texCUBE(CauCubeMap, float3(dir.xy, -dir.z) );
+	float  mydist = length(dir);
+	float  dist = readDistanceCubeMap(DistanceCubeMap, dir);
+	
+	float EPSILON = 1.0;
+
+	if(mydist > dist + EPSILON) caustic = 0;
+	//caustic.rgb *= max(attenuation - mydist, 0.0) / attenuation;
+			
+	Color = caustic;
+	Color += attenuation;
+	Color.a = 1;	
+	return Color;
+}
+
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/diffuse/Diffuse.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/diffuse/Diffuse.material	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/diffuse/Diffuse.material	(revision 2024)
@@ -0,0 +1,310 @@
+material GameTools/CubeMap/Reduce
+{ 
+
+   technique 
+   { 
+       pass 
+       { 
+       //depth_check off
+	   lighting off
+	
+	    vertex_program_ref GameTools/CubeMap/VertexPrograms/ReduceVS
+         {       
+           // param_named_auto worldViewProj worldviewproj_matrix
+	       // param_named_auto world world_matrix 
+         } 
+	 fragment_program_ref GameTools/CubeMap/FragmentPrograms/ReducePS
+         { 
+		//param_named_auto cameraPos camera_position	 
+         param_named nFace int 0
+         param_named CUBEMAP_SIZE int 256
+         //param_named RATE int 2
+         
+        } 
+		
+	 //Cube map for reflections and refractions	
+	 texture_unit
+	 {
+	   filtering point point point
+	   cubic_texture cubemap.jpg combinedUVW
+	   tex_address_mode clamp
+	  // env_map cubic_reflection
+	   colour_op modulate
+	 }
+
+
+	}
+    }
+}
+
+material GameTools/Diffuse
+{ 
+   technique 
+   { 
+      pass 
+      { 
+		
+		IllumTechniques
+		{
+			RenderTechnique DistanceCubeMap
+			{
+				update_interval		1
+				distance_calc false						
+			}
+			RenderTechnique ReducedColorCubeMap
+			{
+				update_interval		1
+				reduced_resolution 4
+				resolution 128
+				distance_calc false
+				face_angle_calc false
+				update_all_face		true
+			}
+		}
+      
+
+		vertex_program_ref GameTools/DiffuseVS
+		{       
+		 param_named_auto worldViewProj worldviewproj_matrix 
+    		param_named_auto world world_matrix  
+        
+		} 
+		fragment_program_ref GameTools/DiffusePS
+		{ 
+			param_named REDUCED_CUBEMAP_SIZE int 8
+			param_named lastCenter float3 0 0 0		
+		} 
+		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{
+			cubic_texture cubemap.jpg combinedUVW
+			tex_address_mode clamp
+			colour_op replace
+		}
+
+		//Cube map of distances
+		texture_unit
+		 {
+		   cubic_texture cubemap.jpg combinedUVW
+		   tex_address_mode clamp
+		   colour_op replace
+		 }
+	 }
+   }
+}
+
+
+
+vertex_program Diffuse2VS hlsl
+{
+	source GameTools_Diffuse.hlsl
+	entry_point DiffuseVS
+	target vs_3_0	
+} 
+
+fragment_program Diffuse2PS hlsl
+{
+	source GameTools_Diffuse.hlsl
+	entry_point DiffusePS
+	target ps_3_0
+	flow_control prefer
+} 
+
+
+
+material GameTools/Diffuse/use
+{ 
+   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 Diffuse2VS
+		{       
+			param_named_auto worldViewProj worldviewproj_matrix 
+    		param_named_auto worldI inverse_world_matrix  
+    		param_named_auto world world_matrix
+        
+		} 
+		fragment_program_ref Diffuse2PS
+		{ 
+			param_named lastCenter float3 0 0 0
+		} 
+		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{
+			
+		}
+
+		//Cube map of distances
+		texture_unit
+		 {
+		  
+		 }
+	 }
+   }
+}
+
+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
+	flow_control prefer
+} 
+
+
+
+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
+{
+	source GameTools_Diffuse.hlsl
+	entry_point EnvMapDiffuseP2PPS
+	target ps_3_0
+	flow_control prefer
+} 
+
+material GameTools/DiffuseP2P
+{ 
+   technique 
+   { 
+      pass 
+      { 
+		
+		IllumTechniques
+		{
+			RenderTechnique DistanceCubeMap
+			{
+				update_interval		1
+				resolution 128
+				distance_calc false	
+				face_angle_calc false
+				update_all_face		true					
+			}
+			RenderTechnique ReducedColorCubeMap
+			{
+				update_interval		1
+				reduced_resolution 4
+				resolution 128
+				distance_calc false
+				face_angle_calc false
+				update_all_face		true
+			}
+		}
+      
+
+		vertex_program_ref Diffuse2VS
+		{       
+			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 lastCenter float3 0 0 0				
+		} 
+		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{
+			
+		}
+
+		//Cube map of distances
+		texture_unit
+		 {
+		  
+		 }
+	 }
+   }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material	(revision 1691)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material	(revision 2024)
@@ -309,4 +309,35 @@
 }
 
+material GameTools/BlurLightVolume
+{ 
+
+   technique 
+   { 
+      
+      pass 
+      { 
+        depth_check off
+        cull_hardware none
+        scene_blend alpha_blend	
+        	
+		vertex_program_ref GameTools/BlurVS
+        {       
+                     
+	    } 
+		fragment_program_ref  GameTools/CopyPS
+        { 
+            param_named_auto width viewport_width
+			param_named_auto height viewport_height
+			param_named float alpha 0.3	
+        }
+        texture_unit
+        {
+			filtering bilinear
+        }
+        
+       }
+    }
+}
+
 material GameTools/BlurCubeFace
 { 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program	(revision 1691)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program	(revision 2024)
@@ -10,4 +10,11 @@
 	source GameTools_Blur.hlsl
 	entry_point BlurPS
+	target ps_3_0
+} 
+
+fragment_program GameTools/CopyPS hlsl
+{
+	source GameTools_Blur.hlsl
+	entry_point CopyPS
 	target ps_3_0
 } 
@@ -41,77 +48,4 @@
 } 
 
-vertex_program GameTools/PostProc1_VS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point defaultVS
-	target vs_2_0
-} 
-
-fragment_program GameTools/PostProc_Black hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point BlackPS
-	target ps_2_0
-
-} 
-
-fragment_program GameTools/PostProc1_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point defaultPS
-	target ps_2_0
-
-} 
-
-fragment_program GameTools/GlowCut_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point GlowCutPS
-	target ps_2_0
-
-} 
-
-fragment_program GameTools/Luminance_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point LuminancePS
-	target ps_2_0
-
-} 
-
-fragment_program GameTools/GlowAdd_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point GlowAddPS
-	target ps_2_0
-} 
-
-fragment_program GameTools/ToneMap_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point ToneMapPS
-	target ps_2_0
-} 
-
-fragment_program GameTools/GlowBlurH_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point GlowBlurHPS
-	target ps_2_0
-} 
-
-fragment_program GameTools/GlowBlurV_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point GlowBlurVPS
-	target ps_2_0
-} 
-
-fragment_program GameTools/TextureCopy_PS hlsl
-{
-	source GameTools_PostProc.hlsl
-	entry_point CopyPS
-	target ps_2_0
-} 
 
 
@@ -342,33 +276,5 @@
 } 
 
-vertex_program GameTools/SpriteVS hlsl
-{
-	source GameTools_Sprite.hlsl
-	entry_point SpriteVS
-	target vs_2_0
-} 
-
-fragment_program GameTools/SpritePS hlsl
-{
-	source GameTools_Sprite.hlsl
-	entry_point SpritePS
-	target ps_2_0
-
-} 
-
-vertex_program GameTools/SBBVS hlsl
-{
-	source GameTools_Sprite.hlsl
-	entry_point SBB_SpriteVS
-	target vs_3_0
-} 
-
-fragment_program GameTools/SBBPS hlsl
-{
-	source GameTools_Sprite.hlsl
-	entry_point SBB_SpritePS
-	target ps_3_0
-
-} 
+
 
 vertex_program GameTools/SceneCameraDepthVS hlsl
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/bultibounce/MetalTeapot.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/bultibounce/MetalTeapot.material	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/bultibounce/MetalTeapot.material	(revision 2024)
@@ -0,0 +1,433 @@
+vertex_program DefaultVS hlsl
+{
+	source MetalTeapot.hlsl
+	entry_point DefaultVS
+	target vs_2_0 
+} 
+
+fragment_program Metal1BouncePS hlsl
+{
+	source MetalTeapot.hlsl
+	entry_point Metal1BouncePS
+	target ps_3_0
+} 
+
+material MetalTeapot
+{ 
+   technique 
+   { 
+      pass 
+      { 
+		IllumTechniques
+		{
+			RenderTechnique ColorCubeMap
+			{
+				update_interval		0
+				distance_calc false
+				face_angle_calc false					
+			}
+			RenderTechnique DistanceCubeMap
+			{
+				update_interval		0
+				distance_calc true false
+				face_angle_calc true false		
+			}
+		
+		 }
+		 vertex_program_ref DefaultVS
+         {       
+            param_named_auto worldViewProj worldviewproj_matrix 
+    	    param_named_auto world world_matrix
+    	    param_named_auto worldview worldview_matrix
+    	    param_named_auto worldI inverse_world_matrix	    
+         } 
+		 fragment_program_ref 	Metal1BouncePS
+         { 
+			param_named_auto cameraPos camera_position
+			//param_named n float3 0.21 0.96 1.17
+			//param_named k float3 4.16 2.57 2.32
+			param_named F0 float3 0.95 0.63 0.54			
+		} 
+		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{
+			
+		}
+
+		//Cube map of distances
+		texture_unit
+		{
+			
+		}
+	  }
+    }
+}
+
+fragment_program NormalDistancePS hlsl
+{
+	source MetalTeapot.hlsl
+	entry_point NormalDistancePS
+	target ps_3_0
+} 
+
+material NormalDistanceCW
+{
+ technique 
+ { 
+  pass 
+  { 
+    cull_hardware clockwise
+    
+	vertex_program_ref DefaultVS
+    {       
+        param_named_auto worldViewProj worldviewproj_matrix 
+	    param_named_auto world world_matrix
+	    param_named_auto worldview worldview_matrix
+    	param_named_auto worldI inverse_world_matrix    
+    }
+    fragment_program_ref NormalDistancePS
+    { 
+		param_named refIndex float 200		
+	} 
+  }
+ }
+}
+
+material NormalDistanceCCW
+{
+ technique 
+ { 
+  pass 
+  { 
+    cull_hardware anticlockwise
+	vertex_program_ref DefaultVS
+    {       
+        param_named_auto worldViewProj worldviewproj_matrix 
+	    param_named_auto world world_matrix
+	    param_named_auto worldview worldview_matrix
+    	param_named_auto worldI inverse_world_matrix    
+    }
+    fragment_program_ref NormalDistancePS
+    { 
+		param_named refIndex float 200	
+	} 
+  }
+ }
+}
+
+fragment_program DistanceMinMaxPS hlsl
+{
+	source MetalTeapot.hlsl
+	entry_point DistanceMinMaxPS
+	target ps_3_0
+} 
+
+material DistanceMinMaxCW
+{
+ technique 
+ { 
+  pass 
+  { 
+    cull_hardware clockwise
+    scene_blend max
+    depth_test off
+    polygon_mode points
+    
+	vertex_program_ref DefaultVS
+    {       
+        param_named_auto worldViewProj worldviewproj_matrix 
+	    param_named_auto world world_matrix
+	    param_named_auto worldview worldview_matrix
+    	param_named_auto worldI inverse_world_matrix    
+    }
+    fragment_program_ref DistanceMinMaxPS
+    { 			
+	} 
+  }
+ }
+}
+
+material DistanceMinMaxCCW
+{
+ technique 
+ { 
+  pass 
+  { 
+    cull_hardware anticlockwise
+    scene_blend max
+    depth_test off
+    polygon_mode points
+        
+	vertex_program_ref DefaultVS
+    {       
+        param_named_auto worldViewProj worldviewproj_matrix 
+	    param_named_auto world world_matrix
+	    param_named_auto worldview worldview_matrix
+    	param_named_auto worldI inverse_world_matrix    
+    }
+    fragment_program_ref DistanceMinMaxPS
+    { 		
+	} 
+  }
+ }
+}
+
+fragment_program MetalMultipleBouncePS hlsl
+{
+	//source MetalTeapot.hlsl
+	//entry_point MetalMultipleBouncePS
+	source MetalTeapotNew.hlsl
+    entry_point mainPS
+
+	target ps_3_0
+	flow_control prefer
+} 
+
+material MetalTeapotMultipleBounce_0
+{ 
+   technique 
+   { 
+      pass 
+      { 
+        //cull_hardware none
+		IllumTechniques
+		{
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true					
+			}
+			RenderTechnique DistanceCubeMap
+			{
+				resolution 1024
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				layer 1
+				texture_unit_id 2
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material NormalDistanceCCW
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				layer 2
+				texture_unit_id 3
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material NormalDistanceCW
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1
+				layer 3				
+				attach_to_texture_unit false
+				get_minmax true
+				max_var_name minmax
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env true
+				render_self false
+				env_material DistanceMinMaxCW
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1
+				layer 4
+				attach_to_texture_unit false
+				get_minmax true
+				max_var_name minmax1
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material DistanceMinMaxCCW
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1
+				layer 5
+				attach_to_texture_unit false
+				get_minmax true
+				max_var_name minmax2
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material DistanceMinMaxCW
+			}			
+		 }
+		 vertex_program_ref DefaultVS
+         {       
+            param_named_auto worldViewProj worldviewproj_matrix 
+    	    param_named_auto world world_matrix
+    	    param_named_auto worldview worldview_matrix
+    	    param_named_auto worldI inverse_world_matrix
+	    
+         } 
+		 fragment_program_ref 	MetalMultipleBouncePS
+         { 
+			param_named_auto cameraPos camera_position
+			//param_named n float3 0.21 0.96 1.17
+			//param_named k float3 4.16 2.57 2.32
+			param_named F0 float3 0.95 0.95 0.95
+			param_named SingleBounce float 0.0
+			param_named refIndex float 0.6667			
+		} 
+		
+		//Cube map of environment
+		texture_unit
+		{
+			//filtering none
+		}
+		//Cube map of environment distances
+		texture_unit
+		{
+			filtering none
+		}
+		
+		//Cube map of reflective object's normals and distances CCW
+		texture_unit
+		{
+			filtering none
+		}		
+		//Cube map of reflective object's normals and distances CW
+		texture_unit
+		{
+			filtering none
+		}
+	  }
+    }
+}
+
+
+
+
+material MetalTeapotMultipleBounce
+{ 
+   technique 
+   { 
+      pass 
+      { 
+        //cull_hardware none
+		IllumTechniques
+		{
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+								
+			}
+			RenderTechnique DistanceCubeMap
+			{
+				resolution 1024
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				get_minmax true
+				min_var_name min
+				max_var_name max
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				layer 1
+				texture_unit_id 2
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material NormalDistanceCCW
+				get_minmax true
+				min_var_name min1
+				max_var_name max1
+			}
+			RenderTechnique ColorCubeMap
+			{
+				resolution 1024
+				layer 2
+				texture_unit_id 3
+				update_interval		0
+				distance_calc false
+				face_angle_calc false
+				update_all_face true
+				render_env false
+				render_self true
+				self_material NormalDistanceCW
+				get_minmax true
+				min_var_name min2
+				max_var_name max2
+			}				
+		 }
+		 vertex_program_ref DefaultVS
+         {       
+            param_named_auto worldViewProj worldviewproj_matrix 
+    	    param_named_auto world world_matrix
+    	    param_named_auto worldview worldview_matrix
+    	    param_named_auto worldI inverse_world_matrix
+	    
+         } 
+		 fragment_program_ref 	MetalMultipleBouncePS
+         { 
+			param_named_auto cameraPos camera_position
+			//param_named n float3 0.21 0.96 1.17
+			//param_named k float3 4.16 2.57 2.32
+			param_named F0 float3 0.95 0.95 0.95
+			param_named SingleBounce float 0.0
+			param_named refIndex float 0.6667			
+		} 
+		
+		//Cube map of environment
+		texture_unit
+		{
+			//filtering none
+		}
+		//Cube map of environment distances
+		texture_unit
+		{
+			filtering none
+		}
+		
+		//Cube map of reflective object's normals and distances CCW
+		texture_unit
+		{
+			filtering none
+		}		
+		//Cube map of reflective object's normals and distances CW
+		texture_unit
+		{
+			filtering none
+		}
+	  }
+    }
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Diffuse.material	(revision 1955)
+++ 	(revision )
@@ -1,310 +1,0 @@
-material GameTools/CubeMap/Reduce
-{ 
-
-   technique 
-   { 
-       pass 
-       { 
-       //depth_check off
-	   lighting off
-	
-	    vertex_program_ref GameTools/CubeMap/VertexPrograms/ReduceVS
-         {       
-           // param_named_auto worldViewProj worldviewproj_matrix
-	       // param_named_auto world world_matrix 
-         } 
-	 fragment_program_ref GameTools/CubeMap/FragmentPrograms/ReducePS
-         { 
-		//param_named_auto cameraPos camera_position	 
-         param_named nFace int 0
-         param_named CUBEMAP_SIZE int 256
-         //param_named RATE int 2
-         
-        } 
-		
-	 //Cube map for reflections and refractions	
-	 texture_unit
-	 {
-	   filtering point point point
-	   cubic_texture cubemap.jpg combinedUVW
-	   tex_address_mode clamp
-	  // env_map cubic_reflection
-	   colour_op modulate
-	 }
-
-
-	}
-    }
-}
-
-material GameTools/Diffuse
-{ 
-   technique 
-   { 
-      pass 
-      { 
-		
-		IllumTechniques
-		{
-			RenderTechnique DistanceCubeMap
-			{
-				update_interval		1
-				distance_calc false						
-			}
-			RenderTechnique ReducedColorCubeMap
-			{
-				update_interval		1
-				reduced_resolution 4
-				resolution 128
-				distance_calc false
-				face_angle_calc false
-				update_all_face		true
-			}
-		}
-      
-
-		vertex_program_ref GameTools/DiffuseVS
-		{       
-		 param_named_auto worldViewProj worldviewproj_matrix 
-    		param_named_auto world world_matrix  
-        
-		} 
-		fragment_program_ref GameTools/DiffusePS
-		{ 
-			param_named REDUCED_CUBEMAP_SIZE int 8
-			param_named lastCenter float3 0 0 0		
-		} 
-		
-		//Cube map for reflections and refractions	
-		texture_unit
-		{
-			cubic_texture cubemap.jpg combinedUVW
-			tex_address_mode clamp
-			colour_op replace
-		}
-
-		//Cube map of distances
-		texture_unit
-		 {
-		   cubic_texture cubemap.jpg combinedUVW
-		   tex_address_mode clamp
-		   colour_op replace
-		 }
-	 }
-   }
-}
-
-
-
-vertex_program Diffuse2VS hlsl
-{
-	source GameTools_Diffuse.hlsl
-	entry_point DiffuseVS
-	target vs_3_0	
-} 
-
-fragment_program Diffuse2PS hlsl
-{
-	source GameTools_Diffuse.hlsl
-	entry_point DiffusePS
-	target ps_3_0
-	flow_control prefer
-} 
-
-
-
-material GameTools/Diffuse/use
-{ 
-   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 Diffuse2VS
-		{       
-			param_named_auto worldViewProj worldviewproj_matrix 
-    		param_named_auto worldI inverse_world_matrix  
-    		param_named_auto world world_matrix
-        
-		} 
-		fragment_program_ref Diffuse2PS
-		{ 
-			param_named lastCenter float3 0 0 0
-		} 
-		
-		//Cube map for reflections and refractions	
-		texture_unit
-		{
-			
-		}
-
-		//Cube map of distances
-		texture_unit
-		 {
-		  
-		 }
-	 }
-   }
-}
-
-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
-	flow_control prefer
-} 
-
-
-
-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
-{
-	source GameTools_Diffuse.hlsl
-	entry_point EnvMapDiffuseP2PPS
-	target ps_3_0
-	flow_control prefer
-} 
-
-material GameTools/DiffuseP2P
-{ 
-   technique 
-   { 
-      pass 
-      { 
-		
-		IllumTechniques
-		{
-			RenderTechnique DistanceCubeMap
-			{
-				update_interval		1
-				resolution 128
-				distance_calc false	
-				face_angle_calc false
-				update_all_face		true					
-			}
-			RenderTechnique ReducedColorCubeMap
-			{
-				update_interval		1
-				reduced_resolution 4
-				resolution 128
-				distance_calc false
-				face_angle_calc false
-				update_all_face		true
-			}
-		}
-      
-
-		vertex_program_ref Diffuse2VS
-		{       
-			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 lastCenter float3 0 0 0				
-		} 
-		
-		//Cube map for reflections and refractions	
-		texture_unit
-		{
-			
-		}
-
-		//Cube map of distances
-		texture_unit
-		 {
-		  
-		 }
-	 }
-   }
-}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Particles.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/Particles.material	(revision 1424)
+++ 	(revision )
@@ -1,115 +1,0 @@
-material GameTools/SpriteShader
-{ 
-
-   technique 
-   { 
-   	pass 
-      { 
-		
-		cull_hardware none
-		cull_software none
-		lighting off
-		scene_blend add
-		depth_write off
-
-		vertex_program_ref GameTools/SpriteVS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				param_named_auto worldView worldview_matrix
-				param_named_auto Proj projection_matrix	    
-			} 
-		fragment_program_ref  GameTools/SpritePS
-			{ 
-			 
-			}
-
-		texture_unit
-		{
-		texture flare.png
-		}
-
-       }
-    }
-}
-
-
-material GameTools/SBB
-{ 
-
-   technique 
-   { 
-   	pass 
-      { 
-	lighting off
-	
-	scene_blend src_alpha one
-	//scene_blend src_alpha one_minus_src_alpha
-	depth_write off
-	depth_check off
-	
-	 vertex_program_ref GameTools/SBBVS
-         {       
-            param_named_auto worldViewProj worldviewproj_matrix 
-            param_named_auto worldView worldview_matrix
-	    param_named_auto Proj projection_matrix
-	    param_named_auto width viewport_width 	
-	    param_named_auto height viewport_height 
-	    	
-	    
-         } 
-	 fragment_program_ref  GameTools/SBBPS
-         { 
-            param_named_auto farplane far_clip_distance	  
-	    param_named_auto nearplane near_clip_distance
-	   	  
-         }
-
-	 texture_unit
-	 {
-	   anim_texture smokealpha.tga 32 2.0
-		//texture flare.png
-	 }
-
-	 texture_unit
-	 {
-	   filtering none
-	 }
-	
-	 texture_unit
-	 {
-	   texture planck.tga
-	 }
-
-       }
-    }
-}
-
-material GameTools/HPS
-{ 
-
-   technique 
-   { 
-      pass 
-      { 
-		IllumTechniques
-		{
-			RenderTechnique HPS
-			{
-				particle_script GameTools/Little
-				perspective false
-			}			
-		}
-		
-		scene_blend add
-		
-		lighting off		
-		depth_check off
-		
-	    texture_unit
-		{
-			texture 
-		}		
-	}
-  }
-}
-
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools_HPS.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools_HPS.material	(revision 1879)
+++ 	(revision )
@@ -1,308 +1,0 @@
-vertex_program HPS_Smoke_S_VS hlsl
-{
-	source GameTools_HPS_Smoke_S.hlsl
-	entry_point HPS_Smoke_S_VS
-	target vs_3_0
-} 
-
-fragment_program HPS_Smoke_S_PS hlsl
-{
-	source GameTools_HPS_Smoke_S.hlsl
-	entry_point HPS_Smoke_S_PS
-	target ps_3_0
-} 
-
-
-
-material HPS_SMOKE_S
-{
-	technique
-	{
-		pass
-		{			
-			vertex_program_ref HPS_Smoke_S_VS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				param_named_auto worldView worldview_matrix
-				param_named_auto Proj projection_matrix	    
-			} 
-			fragment_program_ref  HPS_Smoke_S_PS
-			{ 
-				param_named_auto Proj projection_matrix
-			}
-			
-			texture_unit
-			{
-				texture smoke2.jpg
-			}
-			
-			depth_check off
-			scene_blend_op max
-			scene_blend_op_alpha add
-			scene_blend_alpha one one_minus_src_alpha
-
-		}
-	}
-}
-
-
-vertex_program HPS_Smoke_L_VS hlsl
-{
-	source GameTools_HPS_Smoke_L.hlsl
-	entry_point HPS_Smoke_L_VS
-	target vs_3_0
-} 
-
-fragment_program HPS_Smoke_L_PS hlsl
-{
-	source GameTools_HPS_Smoke_L.hlsl
-	entry_point HPS_Smoke_L_PS
-	target ps_3_0
-} 
-
-
-
-material HPS_SMOKE_L
-{
-	technique
-	{
-		pass
-		{	
-			IllumTechniques
-			{
-				RenderTechnique HPS
-				{
-					particle_script GameTools/Little
-					perspective false
-					vparam_radius baseRadius									
-				}
-								
-			}
-				
-			vertex_program_ref HPS_Smoke_L_VS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				param_named_auto worldView worldview_matrix
-				param_named_auto Proj projection_matrix					    
-			} 
-			fragment_program_ref  HPS_Smoke_L_PS
-			{ 
-				param_named_auto Proj projection_matrix
-			}
-			
-			depth_check off			
-			scene_blend alpha_blend
-			
-			//impostor texture
-			texture_unit
-			{
-				
-			}
-			
-
-		}
-	}
-}
-
-vertex_program HPS_Smoke_L_Depth_VS hlsl
-{
-	source GameTools_HPS_Smoke_L_Depth.hlsl
-	entry_point HPS_Smoke_L_Depth_VS
-	target vs_3_0
-} 
-
-fragment_program HPS_Smoke_L_Depth_PS hlsl
-{
-	source GameTools_HPS_Smoke_L_Depth.hlsl
-	entry_point HPS_Smoke_L_Depth_PS
-	target ps_3_0
-} 
-
-material HPS_SMOKE_L_Depth
-{
-	technique
-	{
-		pass
-		{	
-			IllumTechniques
-			{
-				RenderTechnique HPS
-				{
-					particle_script GameTools/FogLittle
-					perspective false
-					vparam_radius baseRadius
-					update_interval 1				
-				}
-				RenderTechnique SphericalBillboard
-				{
-					texture_unit_id		1					
-				}								
-			}
-				
-			vertex_program_ref HPS_Smoke_L_Depth_VS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				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								    
-			} 
-			fragment_program_ref  HPS_Smoke_L_Depth_PS
-			{ 
-				param_named_auto Proj projection_matrix
-				param_named_auto farplane far_clip_distance
-				param_named_auto nearplane near_clip_distance
-				
-				
-			}
-			
-			depth_check off			
-			depth_write off
-			scene_blend alpha_blend
-			
-			//impostor texture
-			texture_unit
-			{
-				//filtering none
-			}
-			//scene depth texture
-			texture_unit
-			{
-				filtering none
-			}
-		}
-	}
-}
-
-vertex_program HPS_Smoke_L_Depth_Illum_VS hlsl
-{
-	source GameTools_HPS_Smoke_L_Depth.hlsl
-	entry_point HPS_Smoke_L_Depth_Illum_VS
-	target vs_3_0
-} 
-
-fragment_program HPS_Smoke_L_Depth_Illum_PS hlsl
-{
-	source GameTools_HPS_Smoke_L_Depth.hlsl
-	entry_point HPS_Smoke_L_Depth_Illum_PS
-	target ps_3_0
-} 
-
-
-material HPS_SMOKE_L_Depth_Illum
-{
-	technique
-	{
-		pass
-		{	
-			IllumTechniques
-			{
-				RenderTechnique HPS
-				{
-					particle_script GameTools/Little
-					perspective false
-					vparam_radius baseRadius
-					update_interval 1				
-				}
-				RenderTechnique SphericalBillboard
-				{
-					texture_unit_id		1					
-				}			
-				RenderTechnique IllumVolume
-				{
-					update_interval 1
-					//depths 4
-					resolution 128
-				}	
-			}
-				
-			vertex_program_ref HPS_Smoke_L_Depth_Illum_VS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				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								    
-			} 
-			fragment_program_ref  HPS_Smoke_L_Depth_Illum_PS
-			{ 
-				param_named_auto Proj projection_matrix
-				param_named_auto farplane far_clip_distance
-				
-				
-			}
-			
-			depth_check off			
-			depth_write off
-			scene_blend alpha_blend
-			
-			//impostor texture
-			texture_unit
-			{
-				//filtering none
-			}
-			//scene depth texture
-			texture_unit
-			{
-				filtering none
-			}
-			//lightVolume
-			texture_unit
-			{
-				//filtering none
-			}
-
-		}
-	}
-}
-
-vertex_program Smoke_IllumVolume_VS hlsl
-{
-	source GameTools_Smoke_IllumVolume.hlsl
-	entry_point SmokeIllumVolumeVS
-	target vs_3_0
-} 
-
-fragment_program HPS_IllumVolume_PS hlsl
-{
-	source GameTools_Smoke_IllumVolume.hlsl
-	entry_point SmokeIllumVolumePS
-	target ps_3_0
-} 
-
-material Smoke_IllumVolume
-{ 
-
-   technique 
-   { 
-   	pass 
-      { 
-		
-		cull_hardware none
-		cull_software none
-		lighting off
-		scene_blend zero one_minus_src_colour
-		depth_write off
-
-		vertex_program_ref Smoke_IllumVolume_VS
-			{       
-				param_named_auto worldViewProj worldviewproj_matrix 
-				param_named_auto worldView worldview_matrix
-				param_named_auto Proj projection_matrix	    
-			} 
-		fragment_program_ref  HPS_IllumVolume_PS
-			{ 
-			 
-			}
-
-		texture_unit
-		{
-		texture pamacs.dds
-		}
-
-       }
-    }
-}
-
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material	(revision 1959)
+++ 	(revision )
@@ -1,433 +1,0 @@
-vertex_program DefaultVS hlsl
-{
-	source MetalTeapot.hlsl
-	entry_point DefaultVS
-	target vs_2_0 
-} 
-
-fragment_program Metal1BouncePS hlsl
-{
-	source MetalTeapot.hlsl
-	entry_point Metal1BouncePS
-	target ps_3_0
-} 
-
-material MetalTeapot
-{ 
-   technique 
-   { 
-      pass 
-      { 
-		IllumTechniques
-		{
-			RenderTechnique ColorCubeMap
-			{
-				update_interval		0
-				distance_calc false
-				face_angle_calc false					
-			}
-			RenderTechnique DistanceCubeMap
-			{
-				update_interval		0
-				distance_calc true false
-				face_angle_calc true false		
-			}
-		
-		 }
-		 vertex_program_ref DefaultVS
-         {       
-            param_named_auto worldViewProj worldviewproj_matrix 
-    	    param_named_auto world world_matrix
-    	    param_named_auto worldview worldview_matrix
-    	    param_named_auto worldI inverse_world_matrix	    
-         } 
-		 fragment_program_ref 	Metal1BouncePS
-         { 
-			param_named_auto cameraPos camera_position
-			//param_named n float3 0.21 0.96 1.17
-			//param_named k float3 4.16 2.57 2.32
-			param_named F0 float3 0.95 0.63 0.54			
-		} 
-		
-		//Cube map for reflections and refractions	
-		texture_unit
-		{
-			
-		}
-
-		//Cube map of distances
-		texture_unit
-		{
-			
-		}
-	  }
-    }
-}
-
-fragment_program NormalDistancePS hlsl
-{
-	source MetalTeapot.hlsl
-	entry_point NormalDistancePS
-	target ps_3_0
-} 
-
-material NormalDistanceCW
-{
- technique 
- { 
-  pass 
-  { 
-    cull_hardware clockwise
-    
-	vertex_program_ref DefaultVS
-    {       
-        param_named_auto worldViewProj worldviewproj_matrix 
-	    param_named_auto world world_matrix
-	    param_named_auto worldview worldview_matrix
-    	param_named_auto worldI inverse_world_matrix    
-    }
-    fragment_program_ref NormalDistancePS
-    { 
-		param_named refIndex float 200		
-	} 
-  }
- }
-}
-
-material NormalDistanceCCW
-{
- technique 
- { 
-  pass 
-  { 
-    cull_hardware anticlockwise
-	vertex_program_ref DefaultVS
-    {       
-        param_named_auto worldViewProj worldviewproj_matrix 
-	    param_named_auto world world_matrix
-	    param_named_auto worldview worldview_matrix
-    	param_named_auto worldI inverse_world_matrix    
-    }
-    fragment_program_ref NormalDistancePS
-    { 
-		param_named refIndex float 200	
-	} 
-  }
- }
-}
-
-fragment_program DistanceMinMaxPS hlsl
-{
-	source MetalTeapot.hlsl
-	entry_point DistanceMinMaxPS
-	target ps_3_0
-} 
-
-material DistanceMinMaxCW
-{
- technique 
- { 
-  pass 
-  { 
-    cull_hardware clockwise
-    scene_blend_op max
-    depth_test off
-    polygon_mode points
-    
-	vertex_program_ref DefaultVS
-    {       
-        param_named_auto worldViewProj worldviewproj_matrix 
-	    param_named_auto world world_matrix
-	    param_named_auto worldview worldview_matrix
-    	param_named_auto worldI inverse_world_matrix    
-    }
-    fragment_program_ref DistanceMinMaxPS
-    { 			
-	} 
-  }
- }
-}
-
-material DistanceMinMaxCCW
-{
- technique 
- { 
-  pass 
-  { 
-    cull_hardware anticlockwise
-    scene_blend_op max
-    depth_test off
-    polygon_mode points
-        
-	vertex_program_ref DefaultVS
-    {       
-        param_named_auto worldViewProj worldviewproj_matrix 
-	    param_named_auto world world_matrix
-	    param_named_auto worldview worldview_matrix
-    	param_named_auto worldI inverse_world_matrix    
-    }
-    fragment_program_ref DistanceMinMaxPS
-    { 		
-	} 
-  }
- }
-}
-
-fragment_program MetalMultipleBouncePS hlsl
-{
-	//source MetalTeapot.hlsl
-	//entry_point MetalMultipleBouncePS
-	source MetalTeapotNew.hlsl
-    entry_point mainPS
-
-	target ps_3_0
-	flow_control prefer
-} 
-
-material MetalTeapotMultipleBounce
-{ 
-   technique 
-   { 
-      pass 
-      { 
-        //cull_hardware none
-		IllumTechniques
-		{
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true					
-			}
-			RenderTechnique DistanceCubeMap
-			{
-				resolution 1024
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				layer 1
-				texture_unit_id 2
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material NormalDistanceCCW
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				layer 2
-				texture_unit_id 3
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material NormalDistanceCW
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1
-				layer 3				
-				attach_to_texture_unit false
-				get_minmax true
-				max_var_name minmax
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env true
-				render_self false
-				env_material DistanceMinMaxCW
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1
-				layer 4
-				attach_to_texture_unit false
-				get_minmax true
-				max_var_name minmax1
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material DistanceMinMaxCCW
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1
-				layer 5
-				attach_to_texture_unit false
-				get_minmax true
-				max_var_name minmax2
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material DistanceMinMaxCW
-			}			
-		 }
-		 vertex_program_ref DefaultVS
-         {       
-            param_named_auto worldViewProj worldviewproj_matrix 
-    	    param_named_auto world world_matrix
-    	    param_named_auto worldview worldview_matrix
-    	    param_named_auto worldI inverse_world_matrix
-	    
-         } 
-		 fragment_program_ref 	MetalMultipleBouncePS
-         { 
-			param_named_auto cameraPos camera_position
-			//param_named n float3 0.21 0.96 1.17
-			//param_named k float3 4.16 2.57 2.32
-			param_named F0 float3 0.95 0.95 0.95
-			param_named SingleBounce float 0.0
-			param_named refIndex float 0.6667			
-		} 
-		
-		//Cube map of environment
-		texture_unit
-		{
-			//filtering none
-		}
-		//Cube map of environment distances
-		texture_unit
-		{
-			filtering none
-		}
-		
-		//Cube map of reflective object's normals and distances CCW
-		texture_unit
-		{
-			filtering none
-		}		
-		//Cube map of reflective object's normals and distances CW
-		texture_unit
-		{
-			filtering none
-		}
-	  }
-    }
-}
-
-
-
-
-material MetalTeapotMultipleBounce_0
-{ 
-   technique 
-   { 
-      pass 
-      { 
-        //cull_hardware none
-		IllumTechniques
-		{
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-								
-			}
-			RenderTechnique DistanceCubeMap
-			{
-				resolution 1024
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				get_minmax true
-				min_var_name min
-				max_var_name max
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				layer 1
-				texture_unit_id 2
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material NormalDistanceCCW
-				get_minmax true
-				min_var_name min1
-				max_var_name max1
-			}
-			RenderTechnique ColorCubeMap
-			{
-				resolution 1024
-				layer 2
-				texture_unit_id 3
-				update_interval		0
-				distance_calc false
-				face_angle_calc false
-				update_all_face true
-				render_env false
-				render_self true
-				self_material NormalDistanceCW
-				get_minmax true
-				min_var_name min2
-				max_var_name max2
-			}				
-		 }
-		 vertex_program_ref DefaultVS
-         {       
-            param_named_auto worldViewProj worldviewproj_matrix 
-    	    param_named_auto world world_matrix
-    	    param_named_auto worldview worldview_matrix
-    	    param_named_auto worldI inverse_world_matrix
-	    
-         } 
-		 fragment_program_ref 	MetalMultipleBouncePS
-         { 
-			param_named_auto cameraPos camera_position
-			//param_named n float3 0.21 0.96 1.17
-			//param_named k float3 4.16 2.57 2.32
-			param_named F0 float3 0.95 0.95 0.95
-			param_named SingleBounce float 0.0
-			param_named refIndex float 0.6667			
-		} 
-		
-		//Cube map of environment
-		texture_unit
-		{
-			//filtering none
-		}
-		//Cube map of environment distances
-		texture_unit
-		{
-			filtering none
-		}
-		
-		//Cube map of reflective object's normals and distances CCW
-		texture_unit
-		{
-			filtering none
-		}		
-		//Cube map of reflective object's normals and distances CW
-		texture_unit
-		{
-			filtering none
-		}
-	  }
-    }
-}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl	(revision 1691)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl	(revision 2024)
@@ -38,4 +38,19 @@
   return sum;
   return tex2D(Texture, uv);
+}
+
+float4 CopyPS(VS_OUTPUT IN,
+			uniform sampler2D Texture : register(s0),
+			uniform float alpha,
+			uniform float width,
+			uniform float height ) : COLOR
+{  
+  float2 pixel = float2(1.0 / width, 1.0 / height);
+  float2 uv = IN.Position + pixel * 0.5;
+
+  float4 Color = tex2D(Texture, uv);
+  Color.a = alpha;  
+  //Color = float4(0,0,0,1);
+  return Color;
 }
 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl	(revision 1959)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl	(revision 2024)
@@ -525,5 +525,9 @@
     I = readCubeMap(NormDistMap1, p);
   }
+<<<<<<< .mine
+I = max1 + 0.0000000000001 *x.x;
+=======
  I = max1 + 0.000000001 * x.x;
+>>>>>>> .r1994
   //I = readCubeMap(NormDistMap1, R)+0.00000000001*x.x; 
   return I;	
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Sprite.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Sprite.hlsl	(revision 777)
+++ 	(revision )
@@ -1,147 +1,0 @@
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 texCoord		: TEXCOORD0;
-	float4 color		: COLOR0;
-};
-
-VS_OUT SpriteVS(float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 color 	: COLOR0,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-  VS_OUT OUT;
-
-   //texCoord.y = 1.0 - texCoord.y;
-   float2 offset = texCoord.zw;
-   float4 cPosition = mul(worldView, position);
-   cPosition.xy += offset;
-   
-	OUT.hPosition = mul( Proj, cPosition );
-   OUT.texCoord = texCoord;
-   OUT.color = float4(offset,1,1.0);
-
-
-  return OUT;
-}
-
-
-float4 SpritePS(VS_OUT IN ,
-		uniform sampler2D colorTexture : register(s0)):COLOR
-{
-
-	return tex2D( colorTexture, IN.texCoord.xy) * IN.color;
-}
-
-
-
-
-
-
-//////////-----------------------------------------
-
-
-float farplane = 1000.0; //far plane
-float nearplane = 0.1; //far plane
-float width = 800;
-float height = 600;
-
-struct SBB_VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 texCoord		: TEXCOORD0;
-	float3 P		: TEXCOORD1;
-	float3 Q		: TEXCOORD2;
-	float r			: TEXCOORD3;
-	float2 screenCoord	: TEXCOORD4;	
-	float4 color		: COLOR0;
-};
-
-SBB_VS_OUT SBB_SpriteVS (float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 color 	: COLOR,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	SBB_VS_OUT OUT;
-  
-	float2 offset = texCoord.zw;
-	float4 cPosition;   
-	float4 wPosition = position;    
-	cPosition = mul(worldView, wPosition);	
-	OUT.P = cPosition.xyz;
-	OUT.P.z = - 1 * OUT.P.z;
-	cPosition.xy += offset;				
-	OUT.Q = cPosition.xyz;	
-	OUT.Q.z = OUT.P.z;
-	OUT.r = abs(texCoord.z);		
-
-   /*texCoord.y = 1.0 - texCoord.y;
-   float2 offset = texCoord.xy * 2.0 - 1.0;
-   float4 cPosition = mul(worldView, position);
-   OUT.P = cPosition.xyz;
-   OUT.P.z = - 1 * OUT.P.z; // - texCoord.w;
-   cPosition.xy += offset * texCoord.w;
-   OUT.Q = cPosition.xyz;
-   OUT.Q.z = OUT.P.z;
-   OUT.r = texCoord.w;*/
-  
-   OUT.hPosition = mul( Proj, cPosition );
-   OUT.screenCoord =  (OUT.hPosition.xy / OUT.hPosition.w + 1.0) / 2.0;
-   OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
-   OUT.screenCoord += float2(0.5/width, 0.5/height);   
-   
-   OUT.texCoord = texCoord;
-   OUT.color = color;
-
-
-  return OUT;
-} 
-
-
-float4 SBB_SpritePS(SBB_VS_OUT IN ,
-	//	in screenCoord : VPOS,
-		uniform sampler2D colorTexture : register(s0),
-		uniform sampler2D DepthMap : register(s1)
-		,uniform sampler2D PlanckMap : register(s2)
-		) : COLOR
-{
-	float4 Color = IN.color;
-	float alpha = 0;
-	
-	
-	float d = length( IN.Q - IN.P );
-	float Zs;
-	if( d < IN.r )
-	{
-	 
-	 float w = sqrt( IN.r * IN.r - d * d );
-	 alpha = w / IN.r;
-	 alpha *= pow( (IN.r-d) / IN.r , 2);
-	
-	 float F = IN.Q.z - w;
-	 float B = IN.Q.z + w; 
-	 
-
-	 Zs = tex2D( DepthMap, IN.screenCoord ).r;
-	 if(Zs == 0) Zs = farplane;
-	 float ds = min( Zs, B ) - max( nearplane, F );	 
-	// float ds = min( Zs, B ) - F;	 
-	 alpha *=  ds / w * 0.5;
-	
-	
-	}
-	
-	Color.a *= tex2D( colorTexture, IN.texCoord.xy).r ;
-	//Color.a *= IN.color.a;
-	Color.a *= alpha;
-	
-	Color.rgb = tex2D( PlanckMap, Color.aa).rgb;
-	
-	return Color; 
-}
-
-
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/_oldGameTools_DepthShadow.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/_oldGameTools_DepthShadow.hlsl	(revision 1094)
+++ 	(revision )
@@ -1,81 +1,0 @@
-///////depth map
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 Position	: TEXCOORD0;
-};
-
-VS_OUT hDepthVS(float4 position : POSITION,	
-		uniform float4x4 worldView,
-		uniform float4x4 worldViewProj)
-{
-  
-  VS_OUT OUT;
-  OUT.hPosition = mul(worldViewProj, position);
-  OUT.Position = mul(worldView, position);
-  OUT.Position.z *= -1.0;
-  return OUT;
-}
-
-
-
-float4 DepthPS(VS_OUT IN ):COLOR
-{
-	float dist = length(IN.Position.xyz);
-	return float4(dist, dist, dist, 1);	
-}
-
-///////////////Shadow
-
-struct VS_OUT_SHADOW
-{
-	float4 hPosition	: POSITION;
-	float4 Position		: TEXCOORD0;
-};
-
-VS_OUT_SHADOW depthShadowVS(float4 position : POSITION,	
-		uniform float4x4 world,
-		uniform float4x4 worldViewProj)
-{
-  VS_OUT_SHADOW OUT;
-  OUT.hPosition = mul(worldViewProj, position);
-  OUT.Position = mul(world, position);
-  return OUT;
-}
-
-
-float4 depthShadowPS(VS_OUT_SHADOW IN,
-					uniform float4x4 lightView,
-					uniform float4x4 lightViewProj,
-					uniform sampler2D depthShadowMap ):COLOR
-{
-	float bias = 0.0;
-	float4 shadowColor = float4(0.4, 0.4, 0.4, 1.0);
-
-	float4 light = 1;
-	
-	float4 lightCamPos = mul(lightView, IN.Position);
-	float d = length(lightCamPos.xyz);
-	
-	float4 lightScreenPos = mul(lightViewProj, IN.Position);
-	lightScreenPos = lightScreenPos / lightScreenPos.w ;
-	float dist = length(lightScreenPos.xy);
-	
-	if(dist < 1.0 && lightCamPos.z < 0)
-	{
-		lightScreenPos = ( lightScreenPos + 1.0 ) / 2.0;
-		lightScreenPos.y = 1.0 - lightScreenPos.y;
-		float4 storedDepth = tex2D(depthShadowMap, lightScreenPos.xy);
-			
-		
-		if(storedDepth.r + bias < d)
-			light = shadowColor;
-		if(storedDepth.r == 0)
-			light = 1;			
-	}
-	else
-		light = 1;
-		
-	return light;	
-}
-
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Smoke_IllumVolume.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Smoke_IllumVolume.hlsl	(revision 1424)
+++ 	(revision )
@@ -1,53 +1,0 @@
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 texCoord		: TEXCOORD0;
-	float4 color		: COLOR0;
-};
-
-VS_OUT SmokeIllumVolumeVS(float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 color 	: COLOR0,
-		uniform float baseRadius,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	VS_OUT OUT;
-
-   texCoord.y = 1.0 - texCoord.y;
-   float2 offset = texCoord.zw * baseRadius;
-   float4 cPosition = mul(worldView, position);
-   cPosition.xy += offset;
-   
-   OUT.hPosition = mul( Proj, cPosition );
-   OUT.texCoord = texCoord;
-   OUT.color = 1;
-   
-   float z = OUT.hPosition.z / OUT.hPosition.w;
-	
-   float4 planes = float4(0.33, 0.5, 0.66, 1);
-   if(z > planes.x)
-	{
-		OUT.color.r = 0;
-	}
-	if(z > planes.y)
-	{
-		OUT.color.g = 0;
-	}
-	if(z > planes.z)
-	{
-		OUT.color.b = 0;
-	}
-
-   
-   return OUT;
-}
-
-
-float4 SmokeIllumVolumePS(VS_OUT IN ,
-		uniform sampler2D colorTexture : register(s0)):COLOR
-{
-
-	return tex2D( colorTexture, IN.texCoord.xy).a * 0.1 * IN.color;
-}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_S.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_S.hlsl	(revision 1451)
+++ 	(revision )
@@ -1,74 +1,0 @@
-
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 cPosition	: TEXCOORD1;
-	float2 texCoord		: TEXCOORD0;
-	float r				: TEXCOORD2;	
-	float4 center		: TEXCOORD3;
-	float4 Color		: TEXCOORD4;
-};
-
-VS_OUT HPS_Smoke_S_VS (float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 Color: COLOR0,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	VS_OUT OUT;
-  
-	float2 offset = texCoord.zw;
-	float4 cPosition;   
-	cPosition = mul(worldView, position);
-	OUT.center = cPosition;	
-	cPosition.xy += offset;				
-	OUT.cPosition = cPosition;
-	OUT.r = abs(texCoord.z);		
- 
-    OUT.hPosition = mul( Proj, cPosition );
-     
-    OUT.texCoord = texCoord.xy;
-    OUT.Color = Color;    
-	return OUT;
-} 
-
-
-float4 HPS_Smoke_S_PS(VS_OUT IN,
-						uniform float4x4 Proj,
-						uniform sampler2D Texture	) : COLOR
-{
-	float4 Color = 0;
-	float f = 0;
-	float b = 1;
-	float alpha = 0;
-		
-	float d = length( IN.cPosition.xy- IN.center.xy);
-	
-	if( d < IN.r )
-	{	 
-	 float w = sqrt( IN.r * IN.r - d * d );
-	 float4 fPosition = IN.cPosition;
-	 float4 bPosition = IN.cPosition;
-	 fPosition.z -= w;
-	 bPosition.z += w;
-	 fPosition = mul(Proj, fPosition);
-	 bPosition = mul(Proj, bPosition);
-	 f = fPosition.z / fPosition.w;
-	 b = bPosition.z / bPosition.w;
-	 
-	// alpha = pow(w / IN.r, 4);		
-	}
-	else
-	 discard;
-	
-	Color.r = b;
-	Color.g = 1 - f;
-	
-	alpha = 1;
-	Color.a = alpha * IN.Color.a;
-	Color.a *= tex2D(Texture, IN.texCoord).r * 0.7;
-	
-	
-	return Color; 
-}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/HPS_ILLUM_L_PS.asm
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/HPS_ILLUM_L_PS.asm	(revision 1565)
+++ 	(revision )
@@ -1,74 +1,0 @@
-//
-// Generated by Microsoft (R) D3DX9 Shader Compiler 9.12.589.0000
-//
-//   fxc /T ps_3_0 /E HPS_Smoke_L_Depth_Illum_PS /Fo HPS_L_Illum_PS.o /Fc
-//    HPS_ILLUM_L_PS.ac GameTools_HPS_Smoke_L_Depth.hlsl
-//
-//
-// Parameters:
-//
-//   sampler2D $Texture;
-//   sampler2D $depthTexture;
-//   sampler2D $illumVolume;
-//
-//
-// Registers:
-//
-//   Name          Reg   Size
-//   ------------- ----- ----
-//   $Texture      s0       1
-//   $depthTexture s1       1
-//   $illumVolume  s2       1
-//
-
-    ps_3_0
-    def c0, 1, 0, 0.5, -0.5
-    def c1, -0.330000013, -0.5, -0.660000026, 3.030303
-    def c2, 5.88235283, 6.25, 2.94117641, 0
-    dcl_texcoord1 v0.z
-    dcl_texcoord v1.xy
-    dcl_texcoord2 v2.x
-    dcl_texcoord4 v3
-    dcl_texcoord5 v4.xy
-    dcl_texcoord6 v5
-    dcl_2d s0
-    dcl_2d s1
-    dcl_2d s2
-    texld r1, v1, s0
-    cmp r0.w, -r1_abs.x, c0.x, c0.y
-    mov r0, -r0.w
-    texkill r0
-    mad r0.xy, v5, c0.zwzw, c0.z
-    texld r0, r0, s2
-    rcp r2.w, v5.w
-    mul r1.z, r2.w, v5.z
-    add r2.z, r0.x, -c0.x
-    mul r1.z, r1.z, c1.w
-    mad r1.z, r1.z, r2.z, c0.x
-    mad r3.xyz, v5.z, r2.w, c1
-    mad r2.xyz, v5.z, -r2.w, -c1
-    cmp r3.w, r3.x, c0.x, r1.z
-    cmp r2.xy, r2, c0.y, c0.x
-    cmp r4.xy, r3.yzzw, c0.y, c0.x
-    mul r3.xyz, r3, c2
-    add r2.w, v2.x, v2.x
-    add r1.z, r1.x, c0.w
-    add r1.y, -r1.y, c0.z
-    mad r1.z, r2.w, r1.z, v0.z
-    mad r4.w, r2.w, r1.y, v0.z
-    mul r2.xy, r2, r4
-    add r2.w, r1.z, -r4.w
-    lrp r1.xyz, r3, r0.yzww, r0
-    rcp r2.w, r2.w
-    texld r0, v4, s1
-    add r0.w, -r4.w, r0.x
-    cmp r0.z, -r2.x, r3.w, r1.x
-    mul_sat r0.w, r2.w, r0.w
-    cmp r0.z, -r2.y, r0.z, r1.y
-    mul r0.w, r1.w, r0.w
-    cmp r0.z, r2.z, r0.z, r1.z
-    cmp r0.w, -r0_abs.x, r1.w, r0.w
-    mul oC0.xyz, r0.z, v3
-    mul oC0.w, r0.w, v3.w
-
-// approximately 36 instruction slots used (3 texture, 33 arithmetic)
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_L_Depth.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_L_Depth.hlsl	(revision 1879)
+++ 	(revision )
@@ -1,257 +1,0 @@
-#define method1
-
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 cPosition	: TEXCOORD1;
-	float2 texCoord		: TEXCOORD0;
-	float r				: TEXCOORD2;	
-	float4 center		: TEXCOORD3;
-	float4 Color		: TEXCOORD4;	
-	float2 screenCoord	: TEXCOORD5;
-};
-
-VS_OUT HPS_Smoke_L_Depth_VS (float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 Color: COLOR0,
-		uniform float baseRadius,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	VS_OUT OUT;
-	float2 offset = texCoord.zw * baseRadius;
-	OUT.r = abs(offset.x);
-	float4 cPosition;   
-	cPosition = mul(worldView, position);
-	OUT.center = cPosition;	
-	cPosition.xy += offset;	
-	OUT.cPosition = cPosition;
-	OUT.cPosition.z += baseRadius;
-	OUT.cPosition.z *= -1;
-	
-    OUT.hPosition = mul( Proj, cPosition );
-    float4 sPosition = OUT.hPosition / OUT.hPosition.w;
-    OUT.screenCoord = (sPosition.xy + float2(1, 1)) / 2.0;
-    OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
-     
-    OUT.texCoord = texCoord.xy;  
-    OUT.Color = Color;  
-	return OUT;
-} 
-
-
-float4 HPS_Smoke_L_Depth_PS(VS_OUT IN,
-						uniform float4x4 Proj,
-						uniform sampler2D Texture  : register(s0),
-						uniform sampler2D depthTexture : register(s1),
-						uniform sampler2D illumVolume : register(s2),
-						uniform float farplane,
-						uniform float nearplane						
-							) : COLOR
-{
-	float4 Color = 0;
-	float4 impostor = tex2D(Texture, IN.texCoord);
-	float f = 1.0 - impostor.g;
-	float b = impostor.r;
-	float alpha = 0;
-	
-	if(b == 0)
-		discard;	
-
-	float sceneDepth = tex2D(depthTexture, IN.screenCoord).r;
-	if(sceneDepth == 0)
-		sceneDepth = farplane;
-	   
-	float size = 2.0 * IN.r;
-	float frontDepth = IN.cPosition.z + size * (f - 0.5);
-	float backDepth = IN.cPosition.z +  size * (b - 0.5);
-	
-	float far = min(sceneDepth, backDepth);
-	float near = max(frontDepth, nearplane);
-	
-	alpha = (far - near) / (backDepth - frontDepth);
-	alpha = saturate(alpha) * impostor.a;
-	
-	
-	Color = float4(1, 1, 1, alpha) * IN.Color;
-    return Color; 
-	
-}
-
-struct VS_OUT_ILLUM
-{
-	float4 hPosition	: POSITION;
-	float4 cPosition	: TEXCOORD1;
-	float2 texCoord		: TEXCOORD0;
-	float r				: TEXCOORD2;	
-	float4 center		: TEXCOORD3;
-	float4 Color		: TEXCOORD4;	
-	float2 screenCoord	: TEXCOORD5;
-	float4 lightCoord	: TEXCOORD6;
-};
-
-VS_OUT_ILLUM HPS_Smoke_L_Depth_Illum_VS (float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 Color: COLOR0,
-		uniform float width,
-		uniform float height,
-		uniform float baseRadius,
-		uniform float4x4 worldView,
-		uniform float4x4 worldViewInv,
-		uniform float4x4 lightViewProj,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	VS_OUT_ILLUM OUT;
-	//texCoord.z = normalize(texCoord.z);
-	//texCoord.w = normalize(texCoord.w);
-    float2 offset = texCoord.zw * baseRadius;
-	OUT.r = abs(offset.x);
-	float4 cPosition;   
-	cPosition = mul(worldView, position);
-	OUT.center = cPosition;	
-	cPosition.xy += offset;	
-	OUT.cPosition = cPosition;
-	OUT.cPosition.z *= -1;
-	//OUT.cPosition.z = OUT.cPosition.z - OUT.r;	
-	
-    OUT.hPosition = mul( Proj, cPosition );
-    float4 sPosition = OUT.hPosition / OUT.hPosition.w;
-    OUT.screenCoord = (sPosition.xy + float2(1.0, 1.0)) / float2(2.0, 2.0);
-    float2 halfpixel = float2(0.5 / width, 0.5 / height);
-    OUT.screenCoord += halfpixel;   
-    OUT.screenCoord.y = 1.0 - OUT.screenCoord.y;
-         
-    OUT.texCoord = texCoord.xy;  
-    OUT.Color = Color;
-    float4 wPosition = mul(worldViewInv, cPosition);
-    OUT.lightCoord = mul(lightViewProj, wPosition);
-	return OUT;
-} 
-
-float ext(float z, sampler2D illumVolume, float2 lightCoord)
-{
-	float4 extintion = tex2D(illumVolume, lightCoord);
-	
-	float intensities[5];
-	intensities[0] = 1.0;
-	intensities[1] = extintion.r;
-	intensities[2] = extintion.g;
-	intensities[3] = extintion.b;
-	intensities[4] = extintion.a;
-	
-	z = 4.0 * z;
-	int start = floor(z);
-	return lerp( intensities[start], intensities[start + 1], z - ((float) start));	
-}
-
-float4 HPS_Smoke_L_Depth_Illum_PS(VS_OUT_ILLUM IN,
-						uniform float4x4 Proj,
-						uniform sampler2D Texture  : register(s0),
-						uniform sampler2D depthTexture : register(s1),
-						uniform sampler2D illumVolume : register(s2),
-						uniform float farplane						
-							) : COLOR
-{
-	float4 Color = 0;
-	float4 impostor = tex2D(Texture, IN.texCoord);
-	float f = 1.0 - impostor.g;
-	float b = impostor.r;
-	float alpha = 0;
-	
-	if(b == 0)
-		discard;	
-
-	float sceneDepth = tex2D(depthTexture, IN.screenCoord).r;
-	if(sceneDepth == 0)
-	{
-		alpha = impostor.a;
-	}
-	else
-	{	
-		float size = 2.0 * IN.r;
-		float frontDepth = IN.cPosition.z + size * (f - 0.5);
-		float backDepth = IN.cPosition.z +  size * (b - 0.5);
-		
-		alpha = (sceneDepth - frontDepth) / (backDepth - frontDepth);
-		alpha = saturate(alpha) * impostor.a;
-	}
-	
-	float2 lightCoord;
-	lightCoord = (IN.lightCoord.xy + float2(1.0, 1.0)) / 2.0;
-	lightCoord.y = 1.0 - lightCoord.y;
-	float z = IN.lightCoord.z / IN.lightCoord.w;
-	
-#ifdef method1
-	
-		float4 extintion = tex2D(illumVolume, lightCoord);
-	
-		float intensities[5];
-		intensities[0] = 1.0;
-		intensities[1] = extintion.r;
-		intensities[2] = extintion.g;
-		intensities[3] = extintion.b;
-		intensities[4] = extintion.a;
-			
-		float3 start;
-		float3 end;
-		float3 temp = 1.0;
-		float t;
-		
-		float4 planes = float4(0.33, 0.5, 0.66, 1);
-		if(z < planes.x)
-		{
-			start = intensities[0];
-			end = intensities[1];
-			t = z / planes.x;
-			temp = lerp(start, end, t);				
-		}
-		if(z > planes.x && z < planes.y)
-		{
-			start = intensities[1];
-			end = intensities[2];
-			t = (z - planes.x) / (planes.y - planes.x);
-			temp = lerp(start, end, t);					
-		}
-		if(z > planes.y && z < planes.z)
-		{
-			start = intensities[2];
-			end = intensities[3];
-			t = (z - planes.y) / (planes.z - planes.y);
-			temp = lerp(start, end, t);				
-		}
-		if(z > planes.z)
-		{
-			start = intensities[3];
-			end = intensities[4];
-			t = (z - planes.z) / (planes.a - planes.z);
-			temp = lerp(start, end, t);					
-		}
-		IN.Color.rgb *= temp;
-
-#else
-	
-	float4 extintion = tex3D(illumVolume, float3(lightCoord, z));
-	IN.Color.rgb *= extintion;
-	/*
-	float intensities[5];
-	intensities[0] = 1.0;
-	intensities[1] = extintion.r;
-	intensities[2] = extintion.g;
-	intensities[3] = extintion.b;
-	intensities[4] = extintion.a;
-	
-	z = 4.0 * z;
-	int start = floor(z);
-	float ext = lerp( intensities[start], intensities[start + 1], z - ((float) start));	
-	IN.Color.rgb *= ext;*/
-
-#endif
-	
-	Color = float4(1, 1, 1, alpha) * IN.Color;
-      return Color; 
-	
-}
-
-
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_L.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_HPS_Smoke_L.hlsl	(revision 1424)
+++ 	(revision )
@@ -1,45 +1,0 @@
-
-struct VS_OUT
-{
-	float4 hPosition	: POSITION;
-	float4 cPosition	: TEXCOORD1;
-	float2 texCoord		: TEXCOORD0;
-	float r				: TEXCOORD2;	
-	float4 center		: TEXCOORD3;
-	float4 Color		: TEXCOORD4;	
-};
-
-VS_OUT HPS_Smoke_L_VS (float4 position : POSITION,	
-		float4 texCoord : TEXCOORD0,
-		float4 Color: COLOR0,
-		uniform float baseRadius,
-		uniform float4x4 worldView,
-		uniform float4x4 Proj,
-		uniform float4x4 worldViewProj)
-{
-	VS_OUT OUT;
-    float2 offset = texCoord.zw * baseRadius;
-	float4 cPosition;   
-	cPosition = mul(worldView, position);
-	OUT.center = cPosition;	
-	cPosition.xy += offset;				
-	OUT.cPosition = cPosition;
-	OUT.r = abs(offset.x);		
- 
-    OUT.hPosition = mul( Proj, cPosition );
-     
-    OUT.texCoord = texCoord.xy;  
-    OUT.Color = Color;  
-	return OUT;
-} 
-
-
-float4 HPS_Smoke_L_PS(VS_OUT IN,
-						uniform float4x4 Proj,
-						uniform sampler2D Texture	) : COLOR
-{
-	float4 Color = 0;
-	Color = tex2D(Texture, IN.texCoord);
-	Color = float4(1, 1, 1, Color.a) * IN.Color;
-	return Color; 
-}
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 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_PS.hlsl	(revision 2024)
@@ -0,0 +1,65 @@
+struct Plain_OUT
+{
+ float4 vPos : POSITION;
+ float4 color :COLOR0;
+};
+
+struct PlainTex_OUT
+{
+ float4 vPos : POSITION;
+ float4 color :COLOR0;
+ float4 texCoord: TEXCOORD0;
+};
+
+struct VPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 VPosition : TEXCOORD0;
+};
+
+struct CPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 CPos : TEXCOORD0;
+};
+
+
+float4 VDepth(VPos_OUT IN) : COLOR
+{
+ float4 pos = IN.VPosition / IN.VPosition.w;
+ return float4(pos.z, pos.z * pos.z, 1, 1);	
+}
+
+float4 CDepth(CPos_OUT IN) : COLOR
+{
+ return IN.CPos.z;	
+}
+
+float4 CDist(CPos_OUT IN) : COLOR
+{
+ float dist = length(IN.CPos.xyz);
+ return float4(dist, dist * dist, 1, dist);	
+}
+
+float4 Plain(Plain_OUT IN) :COLOR0
+{
+ return IN.color;
+}
+
+float4 PlainTex2D(PlainTex_OUT IN,
+                uniform sampler2D Texture) : COLOR
+{
+ return IN.color * tex2D(Texture, IN.texCoord.xy);
+}
+
+float4 PlainTex1D(PlainTex_OUT IN,
+                  uniform sampler1D Texture) : COLOR
+{
+ return IN.color * tex1D(Texture, IN.texCoord.x);
+}
+
+float4 PlainTex3D(PlainTex_OUT IN,
+                  uniform sampler3D Texture) : COLOR
+{
+ return IN.color * tex3D(Texture, IN.texCoord.xyz);
+}
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 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl	(revision 2024)
@@ -0,0 +1,138 @@
+struct LightVPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 LightVPos : TEXCOORD0;
+};
+
+struct LightCPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 LightVPos : TEXCOORD0;
+ float4 LightCPos : TEXCOORD1;
+};
+
+#define DEPTH_BIAS      0.001
+#define DEPTH_BIAS_VSM  0.001
+#define DEPTH_EPSILON   0.001
+#define DIST_BIAS       0.001
+#define DIST_BIAS_VSM   0.001
+#define DIST_EPSILON    0.001
+
+const float4 shadowColor = float4(0.85,0.85,0.85,1);
+
+float4 shadowMapDepth(LightVPos_OUT IN,
+                      uniform sampler2D shadowMap) : COLOR
+{
+  float4 light = shadowColor;	
+  float4 pos = (IN.LightVPos / IN.LightVPos.w);
+  if( pos.z > 0.0)
+  {
+    pos.xy = (pos.xy + 1.0) / 2.0;
+    pos.y = 1.0 - pos.y;
+    float storedDepth = tex2D(shadowMap, pos.xy).r;
+
+    if(pos.z - DEPTH_BIAS <= storedDepth.r)
+      light = 1;
+  }
+ 
+  return light;	
+}
+
+float4 shadowMapDepth_Variance(LightVPos_OUT IN,
+                               uniform sampler2D shadowMap) : COLOR
+{
+  float4 light = float4(1,1,1,1);
+	
+  float4 pos = (IN.LightVPos / IN.LightVPos.w);
+  
+  if( pos.z > 0.0)
+  {	
+    {
+	float depth = pos.z;
+	pos.xy = (pos.xy + 1.0) / 2.0;
+	pos.y = 1.0 - pos.y;
+	float4 storedDepth = tex2D(shadowMap, pos.xy);
+	depth -= DEPTH_BIAS_VSM;
+	float lit_factor = light * (depth <= storedDepth.r);	
+    	 
+	float M1 = storedDepth.r;
+	float M2 = storedDepth.g;
+	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);
+						
+    	// Adjust the light color based on the shadow attenuation
+    	light = max(lit_factor, pmax);
+    	
+     }
+  }
+  else
+   light = 0;	
+	
+  return shadowColor + (1 - shadowColor) * light;	
+  
+}
+
+float4 shadowMapDist(LightCPos_OUT IN,                     
+                     uniform sampler2D shadowMap) : COLOR
+{
+  float4 light = shadowColor;	
+  float4 pos = (IN.LightVPos / IN.LightVPos.w);
+  
+  if( pos.z > 0.0)
+  {	
+    //float d = length(pos.xy);
+    //light = saturate((1.0 - d)/0.05);		
+    //if(d <= 1.0)
+    {
+	float dist = length(IN.LightCPos.xyz);
+	pos.xy = (pos.xy + 1.0) / 2.0;
+	pos.y = 1.0 - pos.y;
+	float storedDist = tex2D(shadowMap, pos.xy).r;
+	dist -= DIST_BIAS;
+
+	if(dist <= storedDist);
+          light = 1;
+     }
+  }  
+	
+  return light;
+}
+
+float4 shadowMapDist_Variance(LightCPos_OUT IN,
+                              uniform float lightFarPlane,
+                              uniform sampler2D shadowMap) : COLOR
+{
+  float4 light = float4(1,1,1,1);
+	
+  float4 pos = (IN.LightVPos / IN.LightVPos.w);
+  
+  if( pos.z > 0.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;
+	pos.y = 1.0 - pos.y;
+	float4 storedDist = tex2D(shadowMap, pos.xy);
+	dist -= DIST_BIAS_VSM;
+	float lit_factor = light * (dist <= storedDist.r);	
+    	 
+	float M1 = storedDist.r;
+	float M2 = storedDist.g;
+	float v2 = min(max(M2 - M1 * M1, 0.0) +  DIST_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 shadowColor + (1 - shadowColor) * light;
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.program	(revision 2024)
@@ -0,0 +1,155 @@
+///-------------------------
+///Vertex Programs
+///-------------------------
+
+vertex_program GTP/Basic/Plain_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point Plain_VS
+   target vs_1_1
+}
+
+vertex_program GTP/Basic/PlainTex_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point PlainTex_VS
+   target vs_1_1
+} 
+
+vertex_program GTP/Basic/Shaded_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point Shaded_VS
+   target vs_1_1
+} 
+
+vertex_program GTP/Basic/ShadedTex_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point ShadedTex_VS
+   target vs_1_1
+}
+
+vertex_program GTP/Basic/ShadedBump_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point ShadedBump_VS
+   target vs_1_1
+}   
+
+vertex_program GTP/Basic/ShadedBumpTex_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point ShadedBumpTex_VS
+   target vs_1_1
+}
+
+vertex_program GTP/Basic/VPos_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point VPos
+   target vs_1_1
+}   
+
+vertex_program GTP/Basic/CPos_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point CPos
+   target vs_1_1
+}
+
+vertex_program GTP/Basic/LightVPos_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point LightVPos
+   target vs_1_1
+}   
+
+vertex_program GTP/Basic/LightCPos_VS hlsl
+{
+   source GTPBasic_VS.hlsl
+   entry_point LightCPos
+   target vs_1_1
+}
+
+///-------------------------
+///Fragment Programs
+///-------------------------
+
+fragment_program GTP/Basic/VDepth_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point VDepth
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/CDepth_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point CDepth
+   target ps_2_0
+} 
+
+fragment_program GTP/Basic/CDist_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point CDist
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/Plain_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point Plain
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/PlainTex1D_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point PlainTex1D
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/PlainTex2D_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point PlainTex2D
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/PlainTex3D_PS hlsl
+{
+   source GTPBasic_PS.hlsl
+   entry_point PlainTex3D
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/SM/Depth_PS hlsl
+{
+   source GTPShadowMap_PS.hlsl
+   entry_point shadowMapDepth
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/SM/Depth_VSM_PS hlsl
+{
+   source GTPShadowMap_PS.hlsl
+   entry_point shadowMapDepth_Variance
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/SM/Dist_PS hlsl
+{
+   source GTPShadowMap_PS.hlsl
+   entry_point shadowMapDist
+   target ps_2_0
+}
+
+fragment_program GTP/Basic/SM/Dist_VSM_PS hlsl
+{
+   source GTPShadowMap_PS.hlsl
+   entry_point shadowMapDist_Variance
+   target ps_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 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic_VS.hlsl	(revision 2024)
@@ -0,0 +1,207 @@
+struct Plain_OUT
+{
+ float4 vPos : POSITION;
+ float4 color :COLOR0;
+};
+
+Plain_OUT Plain_VS(float4 position : POSITION,
+		   float4 color : COLOR0,
+                   uniform float4x4 WorldViewProj)
+{
+ Plain_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.color = color;
+ return OUT;
+}
+
+
+struct PlainTex_OUT
+{
+ float4 vPos : POSITION;
+ float4 color :COLOR0;
+ float4 texCoord: TEXCOORD0;
+};
+
+PlainTex_OUT PlainTex_VS(float4 position : POSITION,
+		   float4 color : COLOR0,
+                   float4 texCoord : TEXCOORD0,
+                   uniform float4x4 WorldViewProj)
+{
+ PlainTex_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.color = color;
+ OUT.texCoord = texCoord;
+ return OUT;
+}
+
+
+struct Shaded_OUT
+{
+ float4 vPos : POSITION;
+ float4 wNormal : TEXCOORD0;
+ float4 wPos    : TEXCOORD1; 
+};
+
+Shaded_OUT Shaded_VS(float4 position : POSITION,
+                     float4 normal : NORMAL,
+                     uniform float4x4 WorldViewProj,
+                     uniform float4x4 World,
+                     uniform float4x4 WorldInv)
+{
+ Shaded_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.wPos = mul(World, position);
+ OUT.wNormal = mul(normal, WorldInv);
+ return OUT; 
+}
+
+
+struct ShadedTex_OUT
+{
+ float4 vPos : POSITION;
+ float4 texCoord : TEXCOORD0;
+ float4 wNormal : TEXCOORD1;
+ float4 wPos    : TEXCOORD2;  
+};
+
+ShadedTex_OUT ShadedTex_VS(float4 position : POSITION,
+                           float4 normal : NORMAL,
+                           float4 texCoord : TEXCOORD0,
+                           uniform float4x4 WorldViewProj,
+                           uniform float4x4 World,
+                           uniform float4x4 WorldInv)
+{
+ ShadedTex_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.wPos = mul(World, position);
+ OUT.wNormal = mul(normal, WorldInv);
+ OUT.texCoord = texCoord;
+ return OUT; 
+}
+
+
+struct ShadedBump_OUT
+{
+ float4 vPos : POSITION;
+ float4 wNormal : TEXCOORD1; 
+ float4 tangent : TEXCOORD2; 
+ float4 binormal: TEXCOORD3;
+ float4 wPos    : TEXCOORD4; 
+};
+
+ShadedBump_OUT ShadedBump_VS(float4 position : POSITION,
+                           float4 normal : NORMAL,
+                           float4 texCoord : TEXCOORD0,
+                           float4 tangent  : TANGENT,
+                           float4 binormal : BINORMAL,
+                           uniform float4x4 WorldViewProj,
+                           uniform float4x4 World,
+                           uniform float4x4 WorldInv)
+{
+ ShadedBump_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.wPos = mul(World, position);
+ OUT.wNormal = mul(normal, WorldInv);
+ OUT.binormal = binormal;
+ OUT.tangent = tangent;
+ return OUT; 
+}
+
+
+struct ShadedBumpTex_OUT
+{
+ float4 vPos : POSITION;
+ float4 texCoord : TEXCOORD0;
+ float4 wNormal : TEXCOORD1; 
+ float4 tangent : TEXCOORD2; 
+ float4 binormal : TEXCOORD3;
+ float4 wPos    : TEXCOORD4; 
+};
+
+ShadedBumpTex_OUT ShadedBumpTex_VS(float4 position : POSITION,
+                           float4 normal : NORMAL,
+                           float4 texCoord : TEXCOORD0,
+                           float4 tangent  : TANGENT,
+                           float4 binormal : BINORMAL,
+                           uniform float4x4 WorldViewProj,
+                           uniform float4x4 World,
+                           uniform float4x4 WorldInv)
+{
+ ShadedBumpTex_OUT OUT;
+ OUT.vPos = mul(WorldViewProj, position);
+ OUT.wPos = mul(World, position);
+ OUT.wNormal = mul(normal, WorldInv);
+ OUT.texCoord = texCoord;
+ OUT.binormal = binormal;
+ OUT.tangent = tangent;
+ return OUT; 
+}
+
+
+struct VPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 VPosition : TEXCOORD0;
+};
+
+VPos_OUT VPos(float4 position : POSITION0,
+              uniform float4x4 WorldViewProj)
+{
+ VPos_OUT OUT;
+ OUT.VPos = OUT. VPosition = mul(WorldViewProj, position);
+ return OUT;
+}
+
+
+struct CPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 CPos : TEXCOORD0;
+};
+
+CPos_OUT CPos(float4 position : POSITION0,
+              uniform float4x4 WorldViewProj,
+              uniform float4x4 WorldView)
+{
+ CPos_OUT OUT;
+ OUT.VPos = mul(WorldViewProj, position);
+ OUT.CPos = mul(WorldView, position);
+ return OUT;
+}
+
+
+struct LightVPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 LightVPos : TEXCOORD0;
+};
+
+LightVPos_OUT LightVPos(float4 position : POSITION0,
+              uniform float4x4 WorldViewProj,
+              uniform float4x4 LightWorldViewProj)
+{
+ LightVPos_OUT OUT;
+ OUT.VPos = mul(WorldViewProj, position);
+ OUT.LightVPos = mul(LightWorldViewProj, position);
+ return OUT;
+}
+
+
+struct LightCPos_OUT
+{
+ float4 VPos : POSITION;
+ float4 LightVPos : TEXCOORD0;
+ float4 LightCPos : TEXCOORD1;
+};
+
+LightCPos_OUT LightCPos(float4 position : POSITION0,
+              uniform float4x4 WorldViewProj,
+              uniform float4x4 LightWorldViewProj,
+              uniform float4x4 LightWorldView)
+{
+ LightCPos_OUT OUT;
+ OUT.VPos = mul(WorldViewProj, position);
+ OUT.LightVPos = mul(LightWorldViewProj, position);
+ OUT.LightCPos = mul(LightWorldView, position);
+ return OUT;
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material	(revision 2024)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPBasic.material	(revision 2024)
@@ -0,0 +1,116 @@
+material GTP/Basic/Plain
+{
+ technique
+ {
+  pass
+  {
+   cull_hardware clockwise   
+   vertex_program_ref GTP/Basic/Plain_VS
+   {
+     param_named_auto WorldViewProj worldviewproj_matrix  
+   } 
+   vertex_program_ref GTP/Basic/Plain_PS
+   {	
+   }
+  }
+ }
+}
+
+material GTP/Basic/PlainTex
+{
+ technique
+ {
+  pass
+  {
+   cull_hardware clockwise
+   vertex_program_ref GTP/Basic/PlainTex_VS
+   {  
+     param_named_auto WorldViewProj worldviewproj_matrix     
+   } 
+   vertex_program_ref GTP/Basic/PlainTex2D_PS
+   {	
+   }   
+   texture_unit
+   {
+   }
+  }
+ }
+}
+
+material GTP/Basic/Depth
+{
+ technique
+ {
+  pass
+  {
+   cull_hardware clockwise
+   vertex_program_ref GTP/Basic/VPos_VS
+   {  
+     param_named_auto WorldViewProj worldviewproj_matrix     
+   } 
+   vertex_program_ref GTP/Basic/VDepth_PS
+   {	
+   }   
+  }
+ }
+}
+
+material GTP/Basic/DepthCCW : GTP/Basic/Depth
+{
+ technique 0
+ {
+  pass 0
+  {
+   cull_hardware anticlockwise   
+  }
+ }
+}
+
+material GTP/Basic/CameraDepth
+{
+ technique
+ {
+  pass
+  {
+   cull_hardware clockwise
+   vertex_program_ref GTP/Basic/CPos_VS
+   {  
+     param_named_auto WorldViewProj worldviewproj_matrix
+     param_named_auto WorldView     worldview_matrix     
+   } 
+   vertex_program_ref GTP/Basic/CDepth_PS
+   {	
+   }   
+  }
+ }
+}
+
+material GTP/Basic/Distance
+{
+ technique
+ {
+  pass
+  {
+   cull_hardware clockwise
+   vertex_program_ref GTP/Basic/CPos_VS
+   {  
+     param_named_auto WorldViewProj worldviewproj_matrix     
+     param_named_auto WorldView     worldview_matrix
+   } 
+   vertex_program_ref GTP/Basic/CDist
+   {	
+   }   
+  }
+ }
+}
+
+material GTP/Basic/DistanceCCW : GTP/Basic/Distance
+{
+ technique 0
+ {
+  pass 0
+  {
+   cull_hardware anticlockwise   
+  }
+ }
+}
