Index: code/branches/skybox/Media/materials/programs/AmbientOneTexture.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/AmbientOneTexture.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/AmbientOneTexture.glsl	(revision 390)
@@ -0,0 +1,13 @@
+uniform vec4 ambient;
+
+/*
+  Basic ambient lighting vertex program
+*/
+void main()
+{
+	gl_Position = ftransform();
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+	gl_FrontColor = ambient;
+}
+
+
Index: code/branches/skybox/Media/materials/programs/Bloom_ps20.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Bloom_ps20.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Bloom_ps20.hlsl	(revision 390)
@@ -0,0 +1,52 @@
+sampler Blur1: register(s1);
+sampler RT: register(s0);
+
+
+float luminance(float3 c)
+{
+	return dot( c, float3(0.3, 0.59, 0.11) );
+}
+
+float4 main(float2 texCoord: TEXCOORD0) : COLOR {
+	float4 sharp = tex2D(RT,   texCoord);
+	float4 blur  = tex2D(Blur1, texCoord);
+
+
+
+	return ( sharp + blur * 1.8 ) / 2;
+
+//	float4 color	= lerp( sharp, blur, 0.4f );
+
+//	return color;
+
+
+/*
+	return ( sharp + blur * 1.8 ) / 2 +
+			 luminance(blur) * 
+			 float4( 0.5, 0.5, 0.5, 0) +
+			 luminance(sharp) *
+			 float4( 0.3, 0.3, 0.3, 0);
+*/
+/*
+	return ( sharp + blur * 0.9) / 2 +
+			 luminance(blur) * float4(0.1, 0.15, 0.7, 0);
+*/
+
+/*
+	return ( sharp + blur * 0.9) / 2 +
+			 luminance(blur) * float4(0.1, 0.15, 0.7, 0);
+*/
+
+//	float4 retColor = luminance( sharp ) +
+//							luminance( blur ) + blur / 2;
+//	return retColor;
+}
+
+
+
+
+
+
+
+
+
Index: code/branches/skybox/Media/materials/programs/Bloom_vs11.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Bloom_vs11.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Bloom_vs11.hlsl	(revision 390)
@@ -0,0 +1,21 @@
+
+struct VS_OUTPUT {
+   float4 Pos: POSITION;
+   float2 texCoord: TEXCOORD0;
+};
+
+VS_OUTPUT main(float4 Pos: POSITION){
+   VS_OUTPUT Out;
+
+   // Clean up inaccuracies
+   Pos.xy = sign(Pos.xy);
+
+   Out.Pos = float4(Pos.xy, 0, 1);
+   // Image-space
+   Out.texCoord.x = 0.5 * (1 + Pos.x);
+   Out.texCoord.y = 0.5 * (1 - Pos.y);
+
+   return Out;
+}
+
+
Index: code/branches/skybox/Media/materials/programs/Blur0_ps20.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur0_ps20.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur0_ps20.hlsl	(revision 390)
@@ -0,0 +1,31 @@
+sampler RT: register(s0);
+// Simple blur filter
+
+float4 main(float2 texCoord: TEXCOORD0) : COLOR {
+
+	float2 samples[12] = {
+   	-0.326212, -0.405805,
+   	-0.840144, -0.073580,
+   	-0.695914,  0.457137,
+   	-0.203345,  0.620716,
+    	0.962340, -0.194983,
+    	0.473434, -0.480026,
+    	0.519456,  0.767022,
+    	0.185461, -0.893124,
+    	0.507431,  0.064425,
+    	0.896420,  0.412458,
+   	-0.321940, -0.932615,
+   	-0.791559, -0.597705,
+	};
+
+   float4 sum = tex2D(RT, texCoord);
+   for (int i = 0; i < 12; i++){
+      sum += tex2D(RT, texCoord + 0.025 * samples[i]);
+   }
+   return sum / 13;
+
+}
+
+
+
+
Index: code/branches/skybox/Media/materials/programs/Blur0_vs.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur0_vs.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur0_vs.glsl	(revision 390)
@@ -0,0 +1,15 @@
+varying vec2 texCoord[5];
+
+void main()                    
+{
+	vec2 inPos = sign(gl_Vertex.xy);
+	gl_Position = vec4(inPos.xy, 0.0, 1.0);
+	
+	texCoord[0]  = (vec2(inPos.x, -inPos.y) + 1.0)/2.0;
+	
+	const float size = 0.01;
+	texCoord[1] = texCoord[0] + vec2(1.0, 0.0)*size;
+	texCoord[2] = texCoord[0] + vec2(2.0, 0.0)*size;
+	texCoord[3] = texCoord[0] + vec2(-1.0, 0.0)*size;
+	texCoord[4] = texCoord[0] + vec2(-2.0, 0.0)*size;
+}
Index: code/branches/skybox/Media/materials/programs/Blur0_vs11.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur0_vs11.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur0_vs11.hlsl	(revision 390)
@@ -0,0 +1,22 @@
+struct VS_OUTPUT {
+   float4 Pos: POSITION;
+   float2 texCoord: TEXCOORD0;
+};
+
+VS_OUTPUT main(float4 Pos: POSITION){
+   VS_OUTPUT Out;
+
+   // Clean up inaccuracies
+   Pos.xy = sign(Pos.xy);
+
+   Out.Pos = float4(Pos.xy, 0, 1);
+   // Image-space
+   Out.texCoord.x = 0.5 * (1 + Pos.x);
+   Out.texCoord.y = 0.5 * (1 - Pos.y);
+
+   return Out;
+}
+
+
+
+
Index: code/branches/skybox/Media/materials/programs/Blur1_ps20.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur1_ps20.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur1_ps20.hlsl	(revision 390)
@@ -0,0 +1,28 @@
+sampler Blur0: register(s0);
+// Simple blur filter
+
+float4 main(float2 texCoord: TEXCOORD0) : COLOR {
+
+	float2 samples[12] = {
+   	-0.326212, -0.405805,
+   	-0.840144, -0.073580,
+   	-0.695914,  0.457137,
+   	-0.203345,  0.620716,
+    	0.962340, -0.194983,
+    	0.473434, -0.480026,
+    	0.519456,  0.767022,
+    	0.185461, -0.893124,
+    	0.507431,  0.064425,
+    	0.896420,  0.412458,
+   	-0.321940, -0.932615,
+   	-0.791559, -0.597705,
+	};
+
+   float4 sum = tex2D(Blur0, texCoord);
+   for (int i = 0; i < 12; i++){
+      sum += tex2D(Blur0, texCoord + 0.025 * samples[i]);
+   }
+   return sum / 13;
+
+}
+
Index: code/branches/skybox/Media/materials/programs/Blur1_vs.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur1_vs.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur1_vs.glsl	(revision 390)
@@ -0,0 +1,15 @@
+varying vec2 texCoord[5];
+
+void main()                    
+{
+	vec2 inPos = sign(gl_Vertex.xy);
+	gl_Position = vec4(inPos.xy, 0.0, 1.0);
+	
+	texCoord[0]  = (vec2(inPos.x, -inPos.y) + 1.0)/2.0;
+	
+	const float size = 0.01;
+	texCoord[1] = texCoord[0] + vec2(0.0, 1.0)*size;
+	texCoord[2] = texCoord[0] + vec2(0.0, 2.0)*size;
+	texCoord[3] = texCoord[0] + vec2(0.0, -1.0)*size;
+	texCoord[4] = texCoord[0] + vec2(0.0, -2.0)*size;
+}
Index: code/branches/skybox/Media/materials/programs/Blur1_vs11.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur1_vs11.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur1_vs11.hlsl	(revision 390)
@@ -0,0 +1,19 @@
+struct VS_OUTPUT {
+   float4 Pos: POSITION;
+   float2 texCoord: TEXCOORD0;
+};
+
+VS_OUTPUT main(float4 Pos: POSITION){
+   VS_OUTPUT Out;
+
+   // Clean up inaccuracies
+   Pos.xy = sign(Pos.xy);
+
+   Out.Pos = float4(Pos.xy, 0, 1);
+   // Image-space
+   Out.texCoord.x = 0.5 * (1 + Pos.x);
+   Out.texCoord.y = 0.5 * (1 - Pos.y);
+
+   return Out;
+}
+
Index: code/branches/skybox/Media/materials/programs/Blur_ps.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Blur_ps.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Blur_ps.glsl	(revision 390)
@@ -0,0 +1,14 @@
+uniform sampler2D tex0;
+
+varying vec2 texCoord[5];
+
+void main()
+{
+	vec4 sum = texture2D(tex0, texCoord[0]) + 
+			   texture2D(tex0, texCoord[1]) +
+			   texture2D(tex0, texCoord[2]) + 
+			   texture2D(tex0, texCoord[3]) +
+			   texture2D(tex0, texCoord[4]);
+	gl_FragColor = sum / 5.0;
+}
+
Index: code/branches/skybox/Media/materials/programs/Combine_fp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Combine_fp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Combine_fp.cg	(revision 390)
@@ -0,0 +1,15 @@
+float4 Combine_fp
+(
+    in float2 texCoord: TEXCOORD0,
+    
+    uniform sampler RT : register(s0),
+    uniform sampler Sum : register(s1),
+
+    uniform float blur
+) : COLOR
+{
+   float4 render = tex2D(RT, texCoord);
+   float4 sum = tex2D(Sum, texCoord);
+
+   return lerp(render, sum, blur);
+}
Index: code/branches/skybox/Media/materials/programs/DOF_ps.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/DOF_ps.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DOF_ps.cg	(revision 390)
@@ -0,0 +1,47 @@
+// Simple blur filter
+
+const float2 samples[8] = {
+    {-1, 1},
+    {-1, 0},
+    {-1, -1},
+    {0, -1},
+    {1, -1},
+    {1, 0},
+    {1, 1},
+    {0, 1}
+};
+
+float4 blur(
+
+    in float2 texCoord: TEXCOORD0,
+    uniform float sampleDistance: register(c0),
+    uniform sampler Blur0: register(s0)
+
+) : COLOR
+{
+   float4 sum = tex2D(Blur0, texCoord);
+   for (int i = 0; i < 8; ++i){
+      sum += tex2D(Blur0, texCoord + sampleDistance * samples[i]);
+   }
+   return sum / 9;
+}
+
+
+
+float4 blend
+(
+    in float2 texCoord: TEXCOORD0,
+
+    uniform sampler Blur0 : register(s0),
+    uniform sampler Blur1 : register(s1),
+
+    uniform float focus: register(c0),
+    uniform float range: register(c1)
+) : COLOR
+{
+   float4 sharp = tex2D(Blur0, texCoord);
+   float4 blur  = tex2D(Blur1, texCoord);
+
+   // alpha channel of sharp RT has depth info
+   return lerp(sharp, blur, saturate(range * abs(focus - sharp.a)));
+}
Index: code/branches/skybox/Media/materials/programs/DepthShadowmap.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmap.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmap.hlsl	(revision 390)
@@ -0,0 +1,309 @@
+/* This file implements standard programs for depth shadow mapping. 
+   These particular ones are suitable for additive lighting models, and
+   include 3 techniques to reduce depth fighting on self-shadowed surfaces,
+   constant bias, gradient (slope-scale) bias, and a fuzzy shadow map comparison*/
+
+
+// Shadow caster vertex program.
+void casterVP(
+	float4 position			: POSITION,
+	out float4 outPos		: POSITION,
+	out float2 outDepth		: TEXCOORD0,
+
+	uniform float4x4 worldViewProj,
+	uniform float4 texelOffsets,
+	uniform float4 depthRange
+	)
+{
+	outPos = mul(worldViewProj, position);
+
+	// fix pixel / texel alignment
+	outPos.xy += texelOffsets.zw * outPos.w;
+	// linear depth storage
+	// offset / scale range output
+#if LINEAR_RANGE
+	outDepth.x = (outPos.z - depthRange.x) * depthRange.w;
+#else
+	outDepth.x = outPos.z;
+#endif
+	outDepth.y = outPos.w;
+}
+
+
+// Shadow caster fragment program for high-precision single-channel textures	
+void casterFP(
+	float2 depth			: TEXCOORD0,
+	out float4 result		: COLOR)
+	
+{
+#if LINEAR_RANGE
+	float finalDepth = depth.x;
+#else
+	float finalDepth = depth.x / depth.y;
+#endif
+	// just smear across all components 
+	// therefore this one needs high individual channel precision
+	result = float4(finalDepth, finalDepth, finalDepth, 1);
+}
+
+
+	
+void receiverVP(
+	float4 position		: POSITION,
+	float4 normal		: NORMAL,
+
+	out float4 outPos			: POSITION,
+	out float4 outColour		: COLOR,
+	out float4 outShadowUV		: TEXCOORD0,
+
+	uniform float4x4 world,
+	uniform float4x4 worldIT,
+	uniform float4x4 worldViewProj,
+	uniform float4x4 texViewProj,
+	uniform float4 lightPosition,
+	uniform float4 lightColour,
+	uniform float4 shadowDepthRange
+	)
+{
+	float4 worldPos = mul(world, position);
+	outPos = mul(worldViewProj, position);
+
+	float3 worldNorm = mul(worldIT, normal).xyz;
+
+	// calculate lighting (simple vertex lighting)
+	float3 lightDir = normalize(
+		lightPosition.xyz -  (worldPos.xyz * lightPosition.w));
+
+	outColour = lightColour * max(dot(lightDir, worldNorm), 0.0);
+
+	// calculate shadow map coords
+	outShadowUV = mul(texViewProj, worldPos);
+#if LINEAR_RANGE
+	// adjust by fixed depth bias, rescale into range
+	outShadowUV.z = (outShadowUV.z - shadowDepthRange.x) * shadowDepthRange.w;
+#endif
+	
+
+
+	
+}
+
+void receiverFP(
+	float4 position			: POSITION,
+	float4 shadowUV			: TEXCOORD0,
+	float4 vertexColour		: COLOR,
+
+	uniform sampler2D shadowMap : register(s0),
+	uniform float inverseShadowmapSize,
+	uniform float fixedDepthBias,
+	uniform float gradientClamp,
+	uniform float gradientScaleBias,
+	uniform float shadowFuzzyWidth,
+	
+	out float4 result		: COLOR)
+{
+	// point on shadowmap
+#if LINEAR_RANGE
+	shadowUV.xy = shadowUV.xy / shadowUV.w;
+#else
+	shadowUV = shadowUV / shadowUV.w;
+#endif
+	float centerdepth = tex2D(shadowMap, shadowUV.xy).x;
+    
+    // gradient calculation
+  	float pixeloffset = inverseShadowmapSize;
+    float4 depths = float4(
+    	tex2D(shadowMap, shadowUV.xy + float2(-pixeloffset, 0)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(+pixeloffset, 0)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(0, -pixeloffset)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(0, +pixeloffset)).x);
+
+	float2 differences = abs( depths.yw - depths.xz );
+	float gradient = min(gradientClamp, max(differences.x, differences.y));
+	float gradientFactor = gradient * gradientScaleBias;
+
+	// visibility function
+	float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth);
+	float finalCenterDepth = centerdepth + depthAdjust;
+
+	// shadowUV.z contains lightspace position of current object
+
+#if FUZZY_TEST
+	// fuzzy test - introduces some ghosting in result and doesn't appear to be needed?
+	//float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth));
+	float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w);
+
+	result = vertexColour * visibility;
+#else
+	// hard test
+#if PCF
+	// use depths from prev, calculate diff
+	depths += depthAdjust.xxxx;
+	float final = (finalCenterDepth > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.x > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.y > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.z > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.w > shadowUV.z) ? 1.0f : 0.0f;
+	
+	final *= 0.2f;
+
+	result = float4(vertexColour.xyz * final, 1);
+	
+#else
+	result = (finalCenterDepth > shadowUV.z) ? vertexColour : float4(0,0,0,1);
+#endif
+
+#endif
+   
+
+	
+}
+
+
+
+
+// Expand a range-compressed vector
+float3 expand(float3 v)
+{
+	return (v - 0.5) * 2;
+}
+
+
+/* Normal mapping plus depth shadowmapping receiver programs
+*/
+void normalMapShadowReceiverVp(float4 position	: POSITION,
+			 float3 normal		: NORMAL,
+			 float2 uv			: TEXCOORD0,
+			 float3 tangent     : TANGENT0,
+			 
+			 // outputs
+			 out float4 outPos    	 : POSITION,
+			 out float4 outShadowUV	 : TEXCOORD0,
+			 out float2 oUv	 		 : TEXCOORD1,
+			 out float3 oTSLightDir  : TEXCOORD2,
+			 // parameters
+			 uniform float4 lightPosition, // object space
+			 uniform float4x4 world,
+			 uniform float4x4 worldViewProj,
+			 uniform float4x4 texViewProj)
+{
+	float4 worldPos = mul(world, position);
+	outPos = mul(worldViewProj, position);
+
+	// calculate shadow map coords
+	outShadowUV = mul(texViewProj, worldPos);
+#if LINEAR_RANGE
+	// adjust by fixed depth bias, rescale into range
+	outShadowUV.z = (outShadowUV.z - shadowDepthRange.x) * shadowDepthRange.w;
+#endif
+	
+	// pass the main uvs straight through unchanged
+	oUv = uv;
+
+	// calculate tangent space light vector
+	// Get object space light direction
+	// Non-normalised since we'll do that in the fragment program anyway
+	float3 lightDir = lightPosition.xyz -  (position * lightPosition.w);
+
+	// Calculate the binormal (NB we assume both normal and tangent are
+	// already normalised)
+	// NB looks like nvidia cross params are BACKWARDS to what you'd expect
+	// this equates to NxT, not TxN
+	float3 binormal = cross(tangent, normal);
+	
+	// Form a rotation matrix out of the vectors
+	float3x3 rotation = float3x3(tangent, binormal, normal);
+	
+	// Transform the light vector according to this matrix
+	oTSLightDir = mul(rotation, lightDir);
+
+	
+}
+
+
+void normalMapShadowReceiverFp(
+			  float4 shadowUV	: TEXCOORD0,
+			  float2 uv			: TEXCOORD1,
+			  float3 TSlightDir : TEXCOORD2,
+
+			  out float4 result	: COLOR,
+
+			  uniform float4 lightColour,
+			  uniform float inverseShadowmapSize,
+			  uniform float fixedDepthBias,
+			  uniform float gradientClamp,
+			  uniform float gradientScaleBias,
+			  uniform float shadowFuzzyWidth,
+			  
+			  uniform sampler2D   shadowMap : register(s0),
+			  uniform sampler2D   normalMap : register(s1),
+			  uniform samplerCUBE normalCubeMap : register(s2))
+{
+
+	// retrieve normalised light vector, expand from range-compressed
+	float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz);
+
+	// get bump map vector, again expand from range-compressed
+	float3 bumpVec = expand(tex2D(normalMap, uv).xyz);
+
+	// Calculate dot product
+	float4 vertexColour = lightColour * dot(bumpVec, lightVec);
+
+
+	// point on shadowmap
+#if LINEAR_RANGE
+	shadowUV.xy = shadowUV.xy / shadowUV.w;
+#else
+	shadowUV = shadowUV / shadowUV.w;
+#endif
+	float centerdepth = tex2D(shadowMap, shadowUV.xy).x;
+    
+    // gradient calculation
+  	float pixeloffset = inverseShadowmapSize;
+    float4 depths = float4(
+    	tex2D(shadowMap, shadowUV.xy + float2(-pixeloffset, 0)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(+pixeloffset, 0)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(0, -pixeloffset)).x,
+    	tex2D(shadowMap, shadowUV.xy + float2(0, +pixeloffset)).x);
+
+	float2 differences = abs( depths.yw - depths.xz );
+	float gradient = min(gradientClamp, max(differences.x, differences.y));
+	float gradientFactor = gradient * gradientScaleBias;
+
+	// visibility function
+	float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth);
+	float finalCenterDepth = centerdepth + depthAdjust;
+
+	// shadowUV.z contains lightspace position of current object
+
+#if FUZZY_TEST
+	// fuzzy test - introduces some ghosting in result and doesn't appear to be needed?
+	//float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth));
+	float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w);
+
+	result = vertexColour * visibility;
+#else
+	// hard test
+#if PCF
+	// use depths from prev, calculate diff
+	depths += depthAdjust.xxxx;
+	float final = (finalCenterDepth > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.x > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.y > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.z > shadowUV.z) ? 1.0f : 0.0f;
+	final += (depths.w > shadowUV.z) ? 1.0f : 0.0f;
+	
+	final *= 0.2f;
+
+	result = float4(vertexColour.xyz * final, 1);
+	
+#else
+	result = (finalCenterDepth > shadowUV.z) ? vertexColour : float4(0,0,0,1);
+#endif
+
+#endif
+
+
+	
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapCasterFp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapCasterFp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapCasterFp.glsl	(revision 390)
@@ -0,0 +1,16 @@
+
+varying vec2 depth;
+
+void main()
+{
+#if LINEAR_RANGE
+	float finalDepth = depth.x;
+#else
+	float finalDepth = depth.x / depth.y;
+#endif
+	// just smear across all components 
+	// therefore this one needs high individual channel precision
+	gl_FragColor = vec4(finalDepth, finalDepth, finalDepth, 1);
+
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapCasterVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapCasterVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapCasterVp.glsl	(revision 390)
@@ -0,0 +1,24 @@
+uniform mat4 worldViewProj;
+uniform vec4 texelOffsets;
+uniform vec4 depthRange;
+
+varying vec2 depth;
+
+void main()
+{
+	gl_Position = ftransform();
+
+	// fix pixel / texel alignment
+	gl_Position.xy += texelOffsets.zw * gl_Position.w;
+	// linear depth storage
+	// offset / scale range output
+#if LINEAR_RANGE
+	depth.x = (gl_Position.z - depthRange.x) * depthRange.w;
+#else
+	depth.x = gl_Position.z;
+#endif
+	depth.y = gl_Position.w;
+
+
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl	(revision 390)
@@ -0,0 +1,84 @@
+uniform float inverseShadowmapSize;
+uniform float fixedDepthBias;
+uniform float gradientClamp;
+uniform float gradientScaleBias;
+uniform float shadowFuzzyWidth;
+uniform vec4 lightColour;
+
+uniform sampler2D shadowMap;
+uniform sampler2D normalMap;
+
+varying vec3 tangentLightDir;
+
+
+// Expand a range-compressed vector
+vec3 expand(vec3 v)
+{
+	return (v - 0.5) * 2.0;
+}
+
+void main()
+{
+
+	// get the new normal and diffuse values
+	vec3 normal = normalize(expand(texture2D(normalMap, gl_TexCoord[1].xy).xyz));
+	
+	vec4 vertexColour = clamp(dot(normal, tangentLightDir),0.0,1.0) * lightColour;
+
+
+	vec4 shadowUV = gl_TexCoord[0];
+	// point on shadowmap
+#if LINEAR_RANGE
+	shadowUV.xy = shadowUV.xy / shadowUV.w;
+#else
+	shadowUV = shadowUV / shadowUV.w;
+#endif
+	float centerdepth = texture2D(shadowMap, shadowUV.xy).x;
+    
+    // gradient calculation
+  	float pixeloffset = inverseShadowmapSize;
+    vec4 depths = vec4(
+    	texture2D(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(+pixeloffset, 0)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(0, -pixeloffset)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(0, +pixeloffset)).x);
+
+	vec2 differences = abs( depths.yw - depths.xz );
+	float gradient = min(gradientClamp, max(differences.x, differences.y));
+	float gradientFactor = gradient * gradientScaleBias;
+
+	// visibility function
+	float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth);
+	float finalCenterDepth = centerdepth + depthAdjust;
+
+	// shadowUV.z contains lightspace position of current object
+
+#if FUZZY_TEST
+	// fuzzy test - introduces some ghosting in result and doesn't appear to be needed?
+	//float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth));
+	float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w);
+
+	gl_FragColor = vertexColour * visibility;
+#else
+	// hard test
+#if PCF
+	// use depths from prev, calculate diff
+	depths += depthAdjust;
+	float final = (finalCenterDepth > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.x > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.y > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.z > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.w > shadowUV.z) ? 1.0 : 0.0;
+	
+	final *= 0.2;
+
+	gl_FragColor = vec4(vertexColour.xyz * final, 1);
+	
+#else
+	gl_FragColor = (finalCenterDepth > shadowUV.z) ? vertexColour : vec4(0,0,0,1);
+#endif
+
+#endif
+   
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl	(revision 390)
@@ -0,0 +1,42 @@
+attribute vec3 tangent;
+
+uniform mat4 world;
+uniform mat4 worldViewProj;
+uniform mat4 texViewProj;
+uniform vec4 lightPosition; // object space
+uniform vec4 shadowDepthRange;
+
+varying vec3 tangentLightDir;
+
+
+void main()
+{
+	gl_Position = ftransform();
+	
+	vec4 worldPos = world * gl_Vertex;
+
+	// Get object space light direction 
+    vec3 lightDir = normalize(lightPosition.xyz -  (gl_Vertex.xyz * lightPosition.w));
+
+	// calculate shadow map coords
+	gl_TexCoord[0] = texViewProj * worldPos;
+#if LINEAR_RANGE
+	// adjust by fixed depth bias, rescale into range
+	gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w;
+#endif
+
+	// pass the main uvs straight through unchanged 
+	gl_TexCoord[1] = gl_MultiTexCoord0;
+
+	// Calculate the binormal (NB we assume both normal and tangent are 
+	// already normalised) 
+	vec3 binormal = cross(gl_Normal, tangent); 
+
+	// Form a rotation matrix out of the vectors 
+	mat3 rotation = mat3(tangent, binormal, gl_Normal); 
+    
+	// Transform the light vector according to this matrix 
+	tangentLightDir = normalize(rotation * lightDir); 
+
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverFp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverFp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverFp.glsl	(revision 390)
@@ -0,0 +1,66 @@
+uniform float inverseShadowmapSize;
+uniform float fixedDepthBias;
+uniform float gradientClamp;
+uniform float gradientScaleBias;
+uniform float shadowFuzzyWidth;
+
+uniform sampler2D shadowMap;
+
+void main()
+{
+	vec4 shadowUV = gl_TexCoord[0];
+	// point on shadowmap
+#if LINEAR_RANGE
+	shadowUV.xy = shadowUV.xy / shadowUV.w;
+#else
+	shadowUV = shadowUV / shadowUV.w;
+#endif
+	float centerdepth = texture2D(shadowMap, shadowUV.xy).x;
+    
+    // gradient calculation
+  	float pixeloffset = inverseShadowmapSize;
+    vec4 depths = vec4(
+    	texture2D(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(+pixeloffset, 0)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(0, -pixeloffset)).x,
+    	texture2D(shadowMap, shadowUV.xy + vec2(0, +pixeloffset)).x);
+
+	vec2 differences = abs( depths.yw - depths.xz );
+	float gradient = min(gradientClamp, max(differences.x, differences.y));
+	float gradientFactor = gradient * gradientScaleBias;
+
+	// visibility function
+	float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth);
+	float finalCenterDepth = centerdepth + depthAdjust;
+
+	// shadowUV.z contains lightspace position of current object
+
+#if FUZZY_TEST
+	// fuzzy test - introduces some ghosting in result and doesn't appear to be needed?
+	//float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth));
+	float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w);
+
+	gl_FragColor = vertexColour * visibility;
+#else
+	// hard test
+#if PCF
+	// use depths from prev, calculate diff
+	depths += depthAdjust;
+	float final = (finalCenterDepth > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.x > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.y > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.z > shadowUV.z) ? 1.0 : 0.0;
+	final += (depths.w > shadowUV.z) ? 1.0 : 0.0;
+	
+	final *= 0.2;
+
+	gl_FragColor = vec4(gl_Color.xyz * final, 1);
+	
+#else
+	gl_FragColor = (finalCenterDepth > shadowUV.z) ? gl_Color : vec4(0,0,0,1);
+#endif
+
+#endif
+   
+}
+
Index: code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/DepthShadowmapReceiverVp.glsl	(revision 390)
@@ -0,0 +1,32 @@
+uniform mat4 world;
+uniform mat4 worldIT;
+uniform mat4 worldViewProj;
+uniform mat4 texViewProj;
+uniform vec4 lightPosition;
+uniform vec4 lightColour;
+uniform vec4 shadowDepthRange;
+
+
+void main()
+{
+	gl_Position = ftransform();
+	
+	vec4 worldPos = world * gl_Vertex;
+
+	vec3 worldNorm = (worldIT * vec4(gl_Normal, 1)).xyz;
+
+	// calculate lighting (simple vertex lighting)
+	vec3 lightDir = normalize(
+		lightPosition.xyz -  (worldPos.xyz * lightPosition.w));
+
+	gl_FrontColor = lightColour * max(dot(lightDir, worldNorm), 0.0);
+
+	// calculate shadow map coords
+	gl_TexCoord[0] = texViewProj * worldPos;
+#if LINEAR_RANGE
+	// adjust by fixed depth bias, rescale into range
+	gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w;
+#endif
+
+}
+
Index: code/branches/skybox/Media/materials/programs/Example_Basic.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_Basic.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_Basic.cg	(revision 390)
@@ -0,0 +1,272 @@
+/*
+  Basic ambient lighting vertex program
+*/
+void ambientOneTexture_vp(float4 position : POSITION,
+						  float2 uv		  : TEXCOORD0,
+						  
+						  out float4 oPosition : POSITION,
+						  out float2 oUv	   : TEXCOORD0,
+						  out float4 colour    : COLOR,
+
+						  uniform float4x4 worldViewProj,
+						  uniform float4 ambient)
+{
+	oPosition = mul(worldViewProj, position);
+	oUv = uv;
+	colour = ambient;
+}
+
+/*
+  Single-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningOneWeight_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float  blendIdx : BLENDINDICES,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}	
+
+/*
+  Single-weight-per-vertex hardware skinning, shadow-caster pass
+*/
+void hardwareSkinningOneWeightCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float  blendIdx : BLENDINDICES,
+	
+
+	out float4 oPosition : POSITION,
+	out float4 colour    : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	
+	colour = ambient;
+	
+}	
+
+/*
+  Two-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningTwoWeights_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 2; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = float3(0,0,0);
+	for (i = 0; i < 2; ++i)
+	{
+		norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * 
+		blendWgt[i];
+	}
+	norm = normalize(norm);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	
+	oUv = uv;
+	colour = float4(0.5, 0.5, 0.5, 1) + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}
+
+/*
+  Two-weight-per-vertex hardware skinning, shadow caster pass
+*/
+void hardwareSkinningTwoWeightsCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 2; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	
+
+	colour = ambient;
+		
+	
+}
+
+
+/*
+  Four-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningFourWeights_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 4; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = float3(0,0,0);
+	for (i = 0; i < 4; ++i)
+	{
+		norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * 
+		blendWgt[i];
+	}
+	norm = normalize(norm);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}
+
+void hardwareMorphAnimation(float3 pos1 : POSITION,
+			  float4 normal		: NORMAL,
+			  float2 uv		  : TEXCOORD0,
+			  float3 pos2	  : TEXCOORD1,
+						  
+			  out float4 oPosition : POSITION,
+			  out float2 oUv	   : TEXCOORD0,
+			  out float4 colour    : COLOR,
+
+			  uniform float4x4 worldViewProj, 
+			  uniform float4 anim_t)
+{
+	// interpolate
+	float4 interp = float4(pos1 + anim_t.x*(pos2 - pos1), 1.0f);
+	
+	oPosition = mul(worldViewProj, interp);
+	oUv = uv;
+	colour = float4(1,0,0,1);
+}
+
+void hardwarePoseAnimation(float3 pos : POSITION,
+			  float4 normal		: NORMAL,
+			  float2 uv		  : TEXCOORD0,
+			  float3 pose1	  : TEXCOORD1,
+			  float3 pose2	  : TEXCOORD2,
+						  
+			  out float4 oPosition : POSITION,
+			  out float2 oUv	   : TEXCOORD0,
+			  out float4 colour    : COLOR,
+
+			  uniform float4x4 worldViewProj, 
+			  uniform float4 anim_t)
+{
+	// interpolate
+	float4 interp = float4(pos + anim_t.x*pose1 + anim_t.y*pose2, 1.0f);
+	
+	oPosition = mul(worldViewProj, interp);
+	oUv = uv;
+	colour = float4(1,0,0,1);
+}
Index: code/branches/skybox/Media/materials/programs/Example_Basic.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_Basic.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_Basic.hlsl	(revision 390)
@@ -0,0 +1,273 @@
+/*
+  Basic ambient lighting vertex program
+*/
+void ambientOneTexture_vp(float4 position : POSITION,
+						  float2 uv		  : TEXCOORD0,
+						  
+						  out float4 oPosition : POSITION,
+						  out float2 oUv	   : TEXCOORD0,
+						  out float4 colour    : COLOR,
+
+						  uniform float4x4 worldViewProj,
+						  uniform float4 ambient)
+{
+	oPosition = mul(worldViewProj, position);
+	oUv = uv;
+	colour = ambient;
+}
+
+/*
+  Single-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningOneWeight_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float  blendIdx : BLENDINDICES,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}	
+
+/*
+  Single-weight-per-vertex hardware skinning, shadow-caster pass
+*/
+void hardwareSkinningOneWeightCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float  blendIdx : BLENDINDICES,
+	
+
+	out float4 oPosition : POSITION,
+	out float4 colour    : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0);
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	
+	colour = ambient;
+	
+}	
+
+/*
+  Two-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningTwoWeights_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 2; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = float3(0,0,0);
+	for (i = 0; i < 2; ++i)
+	{
+		norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * 
+		blendWgt[i];
+	}
+	norm = normalize(norm);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}
+
+/*
+  Two-weight-per-vertex hardware skinning, shadow caster pass
+*/
+void hardwareSkinningTwoWeightsCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 2; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	
+
+	colour = ambient;
+		
+	
+}
+
+
+/*
+  Four-weight-per-vertex hardware skinning, 2 lights
+  The trouble with vertex programs is they're not general purpose, but
+  fixed function hardware skinning is very poorly supported
+*/
+void hardwareSkinningFourWeights_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4 blendIdx : BLENDINDICES,
+	float4 blendWgt : BLENDWEIGHT,
+	
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[24],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   lightPos[2],
+	uniform float4   lightDiffuseColour[2],
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 4; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	// transform normal
+	float3 norm = float3(0,0,0);
+	for (i = 0; i < 4; ++i)
+	{
+		norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * 
+		blendWgt[i];
+	}
+	norm = normalize(norm);
+	// Lighting - support point and directional
+	float3 lightDir0 = 	normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	float3 lightDir1 = 	normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+
+	
+	oUv = uv;
+	colour = ambient + 
+		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
+		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
+	
+}
+
+void hardwareMorphAnimation(float3 pos1 : POSITION,
+			  float4 normal		: NORMAL,
+			  float2 uv		  : TEXCOORD0,
+			  float3 pos2	  : TEXCOORD1,
+						  
+			  out float4 oPosition : POSITION,
+			  out float2 oUv	   : TEXCOORD0,
+			  out float4 colour    : COLOR,
+
+			  uniform float4x4 worldViewProj, 
+			  uniform float4 anim_t)
+{
+	// interpolate
+	float4 interp = float4(pos1 + anim_t.x*(pos2 - pos1), 1.0f);
+	
+	oPosition = mul(worldViewProj, interp);
+	oUv = uv;
+	colour = float4(1,0,0,1);
+}
+
+void hardwarePoseAnimation(float3 pos : POSITION,
+			  float4 normal		: NORMAL,
+			  float2 uv		  : TEXCOORD0,
+			  float3 pose1	  : TEXCOORD1,
+			  float3 pose2	  : TEXCOORD2,
+						  
+			  out float4 oPosition : POSITION,
+			  out float2 oUv	   : TEXCOORD0,
+			  out float4 colour    : COLOR,
+
+			  uniform float4x4 worldViewProj, 
+			  uniform float4 anim_t)
+{
+	// interpolate
+	float4 interp = float4(pos + anim_t.x*pose1 + anim_t.y*pose2, 1.0f);
+	
+	oPosition = mul(worldViewProj, interp);
+	oUv = uv;
+	colour = float4(1,0,0,1);
+}
+
Index: code/branches/skybox/Media/materials/programs/Example_BumpMapping.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_BumpMapping.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_BumpMapping.cg	(revision 390)
@@ -0,0 +1,236 @@
+// General functions
+
+// Expand a range-compressed vector
+float3 expand(float3 v)
+{
+	return (v - 0.5) * 2;
+}
+
+
+/* Bump mapping vertex program
+   In this program, we want to calculate the tangent space light vector
+   on a per-vertex level which will get passed to the fragment program,
+   or to the fixed function dot3 operation, to produce the per-pixel
+   lighting effect. 
+*/
+void main_vp(float4 position	: POSITION,
+			 float3 normal		: NORMAL,
+			 float2 uv			: TEXCOORD0,
+			 float3 tangent     : TANGENT0,
+			 // outputs
+			 out float4 oPosition    : POSITION,
+			 out float2 oUv			 : TEXCOORD0,
+			 out float3 oTSLightDir	 : TEXCOORD1,
+			 // parameters
+			 uniform float4 lightPosition, // object space
+			 uniform float4x4 worldViewProj)
+{
+	// calculate output position
+	oPosition = mul(worldViewProj, position);
+
+	// pass the main uvs straight through unchanged
+	oUv = uv;
+
+	// calculate tangent space light vector
+	// Get object space light direction
+	// Non-normalised since we'll do that in the fragment program anyway
+	float3 lightDir = lightPosition.xyz -  (position * lightPosition.w);
+
+	// Calculate the binormal (NB we assume both normal and tangent are
+	// already normalised)
+	// NB looks like nvidia cross params are BACKWARDS to what you'd expect
+	// this equates to NxT, not TxN
+	float3 binormal = cross(tangent, normal);
+	
+	// Form a rotation matrix out of the vectors
+	float3x3 rotation = float3x3(tangent, binormal, normal);
+	
+	// Transform the light vector according to this matrix
+	oTSLightDir = mul(rotation, lightDir);
+	
+	
+}
+
+/* Bump mapping vertex program for shadow receiving
+   In this program, we want to calculate the tangent space light vector
+   on a per-vertex level which will get passed to the fragment program,
+   or to the fixed function dot3 operation, to produce the per-pixel
+   lighting effect. 
+*/
+void main_shadowreceiver_vp(float4 position	: POSITION,
+			 float3 normal		: NORMAL,
+			 float2 uv			: TEXCOORD0,
+			 float3 tangent     : TANGENT0,
+			 
+			 // outputs
+			 out float4 oPosition    : POSITION,
+			 out float4 uvproj		 : TEXCOORD0,
+			 out float2 oUv	 		 : TEXCOORD1,
+			 out float3 oTSLightDir  : TEXCOORD2,
+			 
+			 // parameters
+			 uniform float4 lightPosition, // object space
+			 uniform float4x4 worldViewProj,
+			 uniform float4x4 worldMatrix,
+			 uniform float4x4 texViewProj)
+{
+	// calculate output position
+	oPosition = mul(worldViewProj, position);
+
+	// pass the main uvs straight through unchanged
+	oUv = uv;
+
+	// calculate tangent space light vector
+	// Get object space light direction
+	// Non-normalised since we'll do that in the fragment program anyway
+	float3 lightDir = lightPosition.xyz -  (position * lightPosition.w);
+
+	// Calculate the binormal (NB we assume both normal and tangent are
+	// already normalised)
+	// NB looks like nvidia cross params are BACKWARDS to what you'd expect
+	// this equates to NxT, not TxN
+	float3 binormal = cross(tangent, normal);
+	
+	// Form a rotation matrix out of the vectors
+	float3x3 rotation = float3x3(tangent, binormal, normal);
+	
+	// Transform the light vector according to this matrix
+	oTSLightDir = mul(rotation, lightDir);
+
+	// Projection
+    uvproj = mul(worldMatrix, position);
+	uvproj = mul(texViewProj, uvproj);
+	
+}
+
+
+void main_fp( float2 uv			: TEXCOORD0,
+			  float3 TSlightDir : TEXCOORD1,
+
+			  out float4 colour	: COLOR,
+
+			  uniform float4 lightDiffuse,
+			  uniform sampler2D   normalMap : register(s0),
+			  uniform samplerCUBE normalCubeMap : register(s1) )
+{
+	// retrieve normalised light vector, expand from range-compressed
+	float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz);
+
+	// get bump map vector, again expand from range-compressed
+	float3 bumpVec = expand(tex2D(normalMap, uv).xyz);
+
+	// Calculate dot product
+	colour = lightDiffuse * dot(bumpVec, lightVec);
+	
+}
+
+void main_shadowreceiver_fp(
+			  float4 uvproj		: TEXCOORD0,
+			  float2 uv			: TEXCOORD1,
+			  float3 TSlightDir : TEXCOORD2,
+
+			  out float4 colour	: COLOR,
+
+			  uniform float4 lightDiffuse,
+			  uniform sampler2D   shadowMap : register(s0),
+			  uniform sampler2D   normalMap : register(s1),
+			  uniform samplerCUBE normalCubeMap : register(s2))
+{
+
+
+	// retrieve normalised light vector, expand from range-compressed
+	float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz);
+
+	// get bump map vector, again expand from range-compressed
+	float3 bumpVec = expand(tex2D(normalMap, uv).xyz);
+
+	// get shadow value
+	float3 shadow = tex2Dproj(shadowMap, uvproj).xyz;
+
+	// Calculate dot product
+	colour = float4(shadow * lightDiffuse * dot(bumpVec, lightVec), 1.0f);
+	
+}
+
+/* Vertex program which includes specular component */
+void specular_vp(float4 position	: POSITION,
+			 	 float3 normal		: NORMAL,
+			 	 float2 uv			: TEXCOORD0,
+			 	 float3 tangent     : TANGENT0,
+			 	 // outputs
+			 	 out float4 oPosition    : POSITION,
+			 	 out float2 oUv			 : TEXCOORD0,
+			 	 out float3 oTSLightDir	 : TEXCOORD1,
+				 out float3 oTSHalfAngle : TEXCOORD2,
+			 	 // parameters
+				 uniform float4 lightPosition, // object space
+			 	 uniform float3 eyePosition,   // object space
+			 	 uniform float4x4 worldViewProj)
+{
+	// calculate output position
+	oPosition = mul(worldViewProj, position);
+
+	// pass the main uvs straight through unchanged
+	oUv = uv;
+
+	// calculate tangent space light vector
+	// Get object space light direction
+	float3 lightDir = normalize(lightPosition.xyz -  (position * lightPosition.w));
+
+	// Calculate the binormal (NB we assume both normal and tangent are
+	// already normalised)
+	// NB looks like nvidia cross params are BACKWARDS to what you'd expect
+	// this equates to NxT, not TxN
+	float3 binormal = cross(tangent, normal);
+	
+	// Form a rotation matrix out of the vectors
+	float3x3 rotation = float3x3(tangent, binormal, normal);
+	
+	// Transform the light vector according to this matrix
+	oTSLightDir = mul(rotation, lightDir);
+
+	// Calculate half-angle in tangent space
+	float3 eyeDir = normalize(eyePosition - position.xyz);
+	float3 halfAngle = normalize(eyeDir + lightDir);
+	oTSHalfAngle = mul(rotation, halfAngle);
+	
+	
+}
+
+/* Fragment program which supports specular component */
+void specular_fp( float2 uv			: TEXCOORD0,
+			  float3 TSlightDir : TEXCOORD1,
+			  float3 TShalfAngle: TEXCOORD2,
+
+			  out float4 colour	: COLOR,
+
+			  uniform float4 lightDiffuse,
+			  uniform float4 lightSpecular,
+			  uniform sampler2D   normalMap : register(s0),
+			  uniform samplerCUBE normalCubeMap : register(s1), 
+			  uniform samplerCUBE normalCubeMap2 : register(s2)) // we need this second binding to be compatible with ps_1_1, ps_2_0 could reuse the other
+{
+	// retrieve normalised light vector, expand from range-compressed
+	float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz);
+
+	// retrieve half angle and normalise through cube map
+	float3 halfAngle = expand(texCUBE(normalCubeMap2, TShalfAngle).xyz);
+
+	// get bump map vector, again expand from range-compressed
+	float3 bumpVec = expand(tex2D(normalMap, uv).xyz);
+
+	// Pre-raise the specular exponent to the eight power
+	// Note we have no 'pow' function in basic fragment programs, if we were willing to accept compatibility
+	// with ps_2_0 / arbfp1 and above, we could have a variable shininess parameter
+	// This is equivalent to 
+	float specFactor = dot(bumpVec, halfAngle);
+	for (int i = 0; i < 3; ++i)
+		specFactor *= specFactor;
+	
+
+	// Calculate dot product for diffuse
+	colour = (lightDiffuse * saturate(dot(bumpVec, lightVec))) + 
+			(lightSpecular * specFactor);
+	
+}
+			 
Index: code/branches/skybox/Media/materials/programs/Example_CelShading.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_CelShading.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_CelShading.cg	(revision 390)
@@ -0,0 +1,63 @@
+
+/* Cel shading vertex program for single-pass rendering
+   In this program, we want to calculate the diffuse and specular
+   ramp components, and the edge factor (for doing simple outlining)
+   For the outlining to look good, we need a pretty well curved model.
+*/
+void main_vp(float4 position	: POSITION,
+			 float3 normal		: NORMAL,
+			 // outputs
+			 out float4 oPosition : POSITION,
+			 out float  diffuse		 : TEXCOORD0,
+			 out float  specular	 : TEXCOORD1,
+			 out float  edge		 : TEXCOORD2,
+			 // parameters
+			 uniform float3 lightPosition, // object space
+			 uniform float3 eyePosition,   // object space
+			 uniform float4  shininess,
+			 uniform float4x4 worldViewProj)
+{
+	// calculate output position
+	oPosition = mul(worldViewProj, position);
+
+	// calculate light vector
+	float3 N = normalize(normal);
+	float3 L = normalize(lightPosition - position.xyz);
+	
+	// Calculate diffuse component
+	diffuse = max(dot(N, L) , 0);
+
+	// Calculate specular component
+	float3 E = normalize(eyePosition - position.xyz);
+	float3 H = normalize(L + E);
+	specular = pow(max(dot(N, H), 0), shininess);
+	// Mask off specular if diffuse is 0
+	if (diffuse == 0) specular = 0;
+
+	// Edge detection, dot eye and normal vectors
+	edge = max(dot(N, E), 0);
+}
+
+void main_fp(float diffuseIn 	: TEXCOORD0,
+			 float specularIn	: TEXCOORD1,
+			 float edge		: TEXCOORD2,
+			 
+			 out float4 colour	: COLOR,
+			 
+			 uniform float4 diffuse,
+			 uniform float4 specular,
+			 
+			 uniform sampler1D diffuseRamp,
+			 uniform sampler1D specularRamp,
+			 uniform sampler1D edgeRamp)
+{
+	// Step functions from textures
+	diffuseIn = tex1D(diffuseRamp, diffuseIn).x;
+	specularIn = tex1D(specularRamp, specularIn).x;
+	edge = tex1D(edgeRamp, edge).x;
+
+	colour = edge * ((diffuse * diffuseIn) + 
+					(specular * specularIn));
+}
+			 
+			 
Index: code/branches/skybox/Media/materials/programs/Example_Fresnel.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_Fresnel.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_Fresnel.cg	(revision 390)
@@ -0,0 +1,115 @@
+// Vertex program for fresnel reflections / refractions
+void main_vp(
+		float4 pos			: POSITION,
+		float4 normal		: NORMAL,
+		float2 tex			: TEXCOORD0,
+		
+		out float4 oPos		: POSITION,
+		out float3 noiseCoord : TEXCOORD0,
+		out float4 projectionCoord : TEXCOORD1,
+		out float3 oEyeDir : TEXCOORD2, 
+		out float3 oNormal : TEXCOORD3, 
+
+		uniform float4x4 worldViewProjMatrix,
+		uniform float3 eyePosition, // object space
+		uniform float timeVal,
+		uniform float scale,  // the amount to scale the noise texture by
+		uniform float scroll, // the amount by which to scroll the noise
+		uniform float noise  // the noise perturb as a factor of the  time
+		)
+{
+	oPos = mul(worldViewProjMatrix, pos);
+	// Projective texture coordinates, adjust for mapping
+	float4x4 scalemat = float4x4(0.5,   0,   0, 0.5, 
+	                               0,-0.5,   0, 0.5,
+								   0,   0, 0.5, 0.5,
+								   0,   0,   0,   1);
+	projectionCoord = mul(scalemat, oPos);
+	// Noise map coords
+	noiseCoord.xy = (tex + (timeVal * scroll)) * scale;
+	noiseCoord.z = noise * timeVal;
+
+	oEyeDir = normalize(pos.xyz - eyePosition); 
+	oNormal = normal.rgb; 
+	
+}
+
+// Fragment program for distorting a texture using a 3D noise texture
+void main_fp(
+		float3 noiseCoord			: TEXCOORD0,
+		float4 projectionCoord		: TEXCOORD1,
+		float3 eyeDir				: TEXCOORD2,
+		float3 normal				: TEXCOORD3,
+		
+		out float4 col		: COLOR,
+		
+		uniform float4 tintColour,
+		uniform float noiseScale, 
+		uniform float fresnelBias,
+		uniform float fresnelScale,
+		uniform float fresnelPower,
+		uniform sampler2D noiseMap : register(s0),
+		uniform sampler2D reflectMap : register(s1),
+		uniform sampler2D refractMap : register(s2)
+		)
+{
+	// Do the tex projection manually so we can distort _after_
+	float2 final = projectionCoord.xy / projectionCoord.w;
+
+	// Noise
+	float3 noiseNormal = (tex2D(noiseMap, (noiseCoord.xy / 5)).rgb - 0.5).rbg * noiseScale;
+	final += noiseNormal.xz;
+
+	// Fresnel
+	//normal = normalize(normal + noiseNormal.xz);
+	float fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower);
+
+	// Reflection / refraction
+	float4 reflectionColour = tex2D(reflectMap, final);
+	float4 refractionColour = tex2D(refractMap, final) + tintColour;
+
+	// Final colour
+	col = lerp(refractionColour, reflectionColour, fresnel);
+
+
+}
+
+
+// Old version to match ATI PS 1.3 implementation
+void main_vp_old(
+		float4 pos			: POSITION,
+		float4 normal		: NORMAL,
+		float2 tex			: TEXCOORD0,
+		
+		out float4 oPos		: POSITION,
+		out float fresnel   : COLOR,
+		out float3 noiseCoord : TEXCOORD0,
+		out float4 projectionCoord : TEXCOORD1,
+
+		uniform float4x4 worldViewProjMatrix,
+		uniform float3 eyePosition, // object space
+		uniform float fresnelBias,
+		uniform float fresnelScale,
+		uniform float fresnelPower,
+		uniform float timeVal,
+		uniform float scale,  // the amount to scale the noise texture by
+		uniform float scroll, // the amount by which to scroll the noise
+		uniform float noise  // the noise perturb as a factor of the  time
+		)
+{
+	oPos = mul(worldViewProjMatrix, pos);
+	// Projective texture coordinates, adjust for mapping
+	float4x4 scalemat = float4x4(0.5,   0,   0, 0.5, 
+	                               0,-0.5,   0, 0.5,
+								   0,   0, 0.5, 0.5,
+								   0,   0,   0,   1);
+	projectionCoord = mul(scalemat, oPos);
+	// Noise map coords
+	noiseCoord.xy = (tex + (timeVal * scroll)) * scale;
+	noiseCoord.z = noise * timeVal;
+
+	// calc fresnel factor (reflection coefficient)
+	float3 eyeDir = normalize(pos.xyz - eyePosition);
+	fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower);
+	
+}
Index: code/branches/skybox/Media/materials/programs/Example_FresnelPS.asm
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_FresnelPS.asm	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_FresnelPS.asm	(revision 390)
@@ -0,0 +1,72 @@
+ps.1.4
+  // conversion from Cg generated ARB_fragment_program to ps.1.4 by NFZ
+  // command line args: -profile arbfp1 -entry main_fp
+  // program main_fp
+  // c0 : distortionRange
+  // c1 : tintColour
+  // testure 0 : noiseMap
+  // texture 1 : reflectMap
+  // texture 2 : refractMap
+  // v0.x : fresnel 
+  // t0.xyz : noiseCoord
+  // t1.xyw : projectionCoord 
+
+def c2, 2, 1, 0, 0
+
+  // Cg:	distort.x = tex3D(noiseMap, noiseCoord).x;
+  // arbfp1:	TEX R0.x, fragment.texcoord[0], texture[0], 3D;
+  // sample noise map using noiseCoord in TEX unit 0 
+
+texld r0, t0.xyz
+
+  // get projected texture coordinates from TEX coord 1
+  // will be used in phase 2
+
+texcrd r1.xy, t1_dw.xyw
+mov r1.z, c2.y
+
+  // Cg:	distort.y = tex3D(noiseMap, noiseCoord + yoffset).x;
+  // arbfp1:	ADD R1.xyz, fragment.texcoord[0], c1;
+  // arbfp1:	TEX R1.x, R1, texture[0], 3D;
+  // arbfp1:	MOV R0.y, R1.x;
+
+  // Cg:	distort = (distort * 2 - 1) * distortionRange;
+  // arbfp1:	MAD R0.xy, R0, c0.x, -c0.y;
+  // arbfp1:	MUL R0.xy, R0, u0.x;
+  // (distort * 2 - 1) same as 2*(distort -.5) so use _bx2
+
+
+  // Cg:	final = projectionCoord.xy / projectionCoord.w;
+  // Cg:	final += distort;
+  // arbfp1:	RCP R0.w, fragment.texcoord[1].w;
+  // arbfp1:	MAD R0.xy, fragment.texcoord[1], R0.w, R0;
+  // 	final = (distort *  projectionCoord.w) + projectionCoord.xy
+  // for ps.1.4 have to re-arrange things a bit to perturb projected texture coordinates
+
+mad r0.xyz, r0_bx2, c0.x, r1
+
+phase
+
+  // do dependant texture reads
+  // Cg:	reflectionColour = tex2D(reflectMap, final);
+  // arbfp1:	TEX R0, R0, texture[1], 2D;
+  // sampe reflectMap using dependant read : texunit 1 
+
+texld r1, r0.xyz
+
+  // Cg:	refractionColour = tex2D(refractMap, final) + tintColour;
+  // arbfp1:	TEX R1, R0, texture[2], 2D;
+  // sample refractMap : texunit 2 
+
+texld r2, r0.xyz
+
+  // adding tintColour that is in global c1
+  // arbfp1:	ADD R1, R1, u1;
+
+add r2, r2, c1
+
+  // Cg:	col = lerp(refractionColour, reflectionColour, fresnel);
+  // arbfp1:	ADD R0, R0, -R1;
+  // arbfp1:	MAD result.color, fragment.color.primary.x, R0, R1;
+
+lrp r0, v0.x, r1, r2
Index: code/branches/skybox/Media/materials/programs/Example_Projection.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Example_Projection.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Example_Projection.cg	(revision 390)
@@ -0,0 +1,28 @@
+
+void generalPurposeProjection_vp(
+		float4 pos			: POSITION,
+		
+		out float4 oPos		: POSITION,
+		out float4 texCoord : TEXCOORD0,
+
+		uniform float4x4 worldViewProjMatrix,
+		uniform float4x4 worldMatrix,
+		uniform float4x4 texViewProjMatrix)
+{
+	oPos = mul(worldViewProjMatrix, pos);
+	// multiply position by world matrix, then by projective view/proj
+	float4 newpos = mul(worldMatrix, pos);
+	texCoord = mul(texViewProjMatrix, newpos);
+	
+}
+
+void generalPurposeProjection_fp(
+		float4 texCoord		: TEXCOORD0,
+		out float4 col		: COLOR,
+		uniform sampler2D texMap)
+{
+	col = tex2Dproj(texMap, texCoord);
+
+}
+		
+
Index: code/branches/skybox/Media/materials/programs/GlassFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/GlassFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/GlassFP.cg	(revision 390)
@@ -0,0 +1,9 @@
+sampler RT : register(s0);
+sampler NormalMap : register(s1);
+
+float4 main_ps(float2 iTexCoord : TEXCOORD0) : COLOR
+{
+	float4 normal = 2 * (tex2D(NormalMap, iTexCoord * 2.5) - 0.5);
+
+	return tex2D(RT, iTexCoord + normal.xy * 0.05);
+}
Index: code/branches/skybox/Media/materials/programs/Grass.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/Grass.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Grass.cg	(revision 390)
@@ -0,0 +1,31 @@
+// Vertex program to wave some grass about
+// Simplistic, assumes base of the grass at 0
+void grass_vp(float4 position : POSITION,
+			  float3 normal   : NORMAL,
+			  float2 uv		  : TEXCOORD0,
+			  out float4 oPosition : POSITION,
+			  out float2 oUv	   : TEXCOORD0,
+			  out float4 colour    : COLOR,
+
+			  uniform float4x4 worldViewProj,
+			  uniform float4 ambient,
+			  uniform float4 objSpaceLight,
+			  uniform float4 lightColour,
+			  uniform float4 offset)
+{
+	float4 mypos = position;
+	//offset = float4(0.5, 0, 0, 0);
+	float4 factor = float4(1,1,1,1) - uv.yyyy;
+	mypos = mypos + offset * factor;
+	oPosition = mul(worldViewProj, mypos);
+
+	oUv = uv;
+	// get vertex light direction (support directional and point)
+	float3 light = normalize(
+		objSpaceLight.xyz -  (position.xyz * objSpaceLight.w));
+	float diffuseFactor = max(dot(normal, light), 0);
+	
+	
+	colour = ambient + diffuseFactor * lightColour;
+}
+
Index: code/branches/skybox/Media/materials/programs/GrayScale.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/GrayScale.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/GrayScale.cg	(revision 390)
@@ -0,0 +1,18 @@
+sampler RT : register(s0);
+
+float4 GrayScale_ps(float2 iTexCoord : TEXCOORD0) : COLOR
+{
+    float3 greyscale = dot(tex2D(RT, iTexCoord).rgb, float3(0.3, 0.59, 0.11));
+	return float4(greyscale, 1.0);
+}
+
+float4 Embossed_ps(float2 iTexCoord : TEXCOORD0) : COLOR
+{
+    float4 Color;
+    Color.a = 1.0f;
+    Color.rgb = 0.5f;
+    Color -= tex2D( RT, iTexCoord - 0.001)*2.0f;
+    Color += tex2D( RT, iTexCoord + 0.001)*2.0f;
+    Color.rgb = (Color.r+Color.g+Color.b)/3.0f;
+    return Color;
+}
Index: code/branches/skybox/Media/materials/programs/HeatVision.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/HeatVision.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/HeatVision.cg	(revision 390)
@@ -0,0 +1,230 @@
+//////////////////////////////////////////////
+//				 CASTER PASS				//
+//				    HEAT					//
+//////////////////////////////////////////////
+
+// vs_1_1
+void HeatCaster_vp(
+              // in
+              float4 vPos: POSITION,
+              float4 vNormal: NORMAL,
+              
+              // out
+              out float4 oPos: POSITION,
+              out float2 oNDotV: TEXCOORD0,
+              
+              // parameters
+              uniform float4x4 worldViewProj,
+              uniform float3 eyePosition        // object space
+            )
+{
+   float4 eyeDir = float4(eyePosition - vPos.xyz, 0);
+   eyeDir = normalize(eyeDir);
+   oPos   = mul( worldViewProj, vPos );
+   oNDotV = clamp( dot( vNormal, eyeDir ), 0, 1 );
+}
+
+// ps_2_0
+float4 HeatCaster_fp(
+                        // input from vp
+                        float2 iNDotV: TEXCOORD0
+                     ) : COLOR0
+{
+   return iNDotV.x;
+}
+
+
+//////////////////////////////////////////////
+//				 CASTER PASS				//
+//				    COLD					//
+//////////////////////////////////////////////
+
+// vs_1_1
+void ColdCaster_vp(
+              // in
+              float4 vPos: POSITION,
+              float4 vNormal: NORMAL,
+              
+              // out
+              out float4 oPos: POSITION,
+              out float2 oNDotV: TEXCOORD0,
+              
+              // parameters
+              uniform float4x4 worldViewProj,
+              uniform float3 eyePosition        // object space
+            )
+{
+   float4 eyeDir = float4(eyePosition - vPos.xyz, 0);
+   eyeDir = normalize(eyeDir);
+   oPos   = mul( worldViewProj, vPos );
+   oNDotV = clamp( dot( vNormal, eyeDir ), 0, 1 );
+}
+
+// ps_2_0
+float4 ColdCaster_fp(
+                        // input from vp
+                        float2 iNDotV: TEXCOORD0
+                     ) : COLOR0
+{
+   return iNDotV.x / 2;
+}
+
+
+//////////////////////////////////////////////
+//	   PASS 1 - Light to heat conversion	//
+//////////////////////////////////////////////
+
+// vs_1_1
+void LightToHeat_vp(
+                    // in
+                    float4 inPos: POSITION,
+                    
+                    uniform float flipping,
+
+                    // out
+                    out float4 Pos: POSITION,
+                    out float2 uv0: TEXCOORD0
+                   )
+{
+    Pos = float4(inPos.x, flipping * inPos.y, 0.0f, 1.0f);
+    inPos.xy = sign(inPos.xy);
+    uv0  = (float2(inPos.x, -inPos.y) + 1.0f)/2.0f;
+}
+
+
+// ps_2_0
+void LightToHeat_fp(
+                        // input from vp
+                        float4 inDiffuse: COLOR0,
+                        float2 inUV0: TEXCOORD0,
+                        
+                        // out
+                        out float4 outColor: COLOR0,
+                        
+                        // params
+                        uniform float4 random_fractions,
+                        uniform float4 heatBiasScale,
+                        uniform float4 depth_modulator,
+
+                        uniform sampler2D Input,         // output of HeatVisionCaster_fp (NdotV)
+                        uniform sampler2D NoiseMap,
+                        uniform sampler2D HeatLookup
+                     )
+{
+   float  depth, heat, interference;
+
+   //  Output constant color:
+   depth = tex2D( Input, inUV0 );
+   depth *= (depth * depth_modulator);
+
+   heat  = (depth * heatBiasScale.y);
+
+//   if (depth > 0)
+   {
+		interference = -0.5 + tex2D( NoiseMap, inUV0 + float2( random_fractions.x, random_fractions.y ) );
+		interference *= interference;
+		interference *= 1 - heat;
+		heat += interference;//+ heatBiasScale.x;
+   }
+
+/*
+	heatBias isn't used for now
+   if (heat > 0)
+       heat += heatBiasScale.x;
+*/
+
+   // Clamp UVs
+   heat  = max( 0.005, min( 0.995, heat ) );
+   outColor = tex2D( HeatLookup, float2( heat, 0.f ) );
+}
+
+
+//////////////////////////////////////////////
+// PASS 2 - add simple blur (final pass)	//
+//////////////////////////////////////////////
+
+// vs_1_1
+void Blur_vp(
+                    // in
+                    float4 inPos: POSITION,
+                    
+                    uniform float flipping,
+
+                    // out
+                    out float4 Pos: POSITION,
+                    out float2 uv0: TEXCOORD0
+                   )
+{
+    Pos = float4(inPos.x, flipping * inPos.y, 0.0f, 1.0f);
+    inPos.xy = sign(inPos.xy);
+    uv0  = (float2(inPos.x, -inPos.y) + 1.0f)/2.0f;
+}
+
+// ps_2_0
+void Blur_fp(
+                    // input from vp
+                    float4 inDiffuse: COLOR0,
+                    float2 inUV0: TEXCOORD0,
+                    
+                    // out
+                    out float4 outColor: COLOR0,
+                    
+                    // parameters
+                    uniform sampler2D Input,             // output of HeatVision_fp1 (HeatRenderTexture)
+                    uniform float4 blurAmount
+                    )
+{
+   int i;
+   float4 tmpOutColor;
+   float  diffuseGlowFactor;
+   const float2 offsets[4] = 
+   {
+/*
+		// hazy blur
+		-1.8, -1.8,
+		-1.8, 1.8,
+		1.8, -1.8,
+		1.8, 1.8
+*/
+/*
+		// less-hazy blur
+	  -1.0,  2.0,
+	  -1.0, -1.0,
+	   1.0, -1.0,
+	   1.0,  1.0
+*/
+/*
+      -0.326212, -0.405805,
+      -0.840144, -0.073580,
+      -0.695914,  0.457137,
+      -0.203345,  0.620716
+*/
+
+	  -0.3,  0.4,
+	  -0.3, -0.4,
+	   0.3, -0.4,
+	   0.3,  0.4
+
+   };
+
+   tmpOutColor = tex2D( Input, inUV0 );	// UV coords are in image space
+
+   // calculate glow amount
+   diffuseGlowFactor = 0.0113f * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));
+
+   // basic blur filter
+   for (i = 0; i < 4; i++) {
+      tmpOutColor += tex2D( Input, inUV0 + blurAmount.x * diffuseGlowFactor * offsets[i] );
+   }
+
+   tmpOutColor *= 0.25;
+
+   // TIPS (old-skool strikes again!)
+   // Pay attention here! If you use the "out float4 outColor" directly
+   // in your steps while creating the output color (like you remove
+   // the "tmpOutColor" var and just use the "outColor" directly)
+   // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO!
+   // A temporary variable, instead, acts like a per-pixel double buffer, and
+   // best of all, lead to better performance.
+   outColor = tmpOutColor;
+}
Index: code/branches/skybox/Media/materials/programs/InvertFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/InvertFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/InvertFP.cg	(revision 390)
@@ -0,0 +1,6 @@
+sampler RT : register(s0);
+
+float4 Invert_ps (float2 iTexCoord : TEXCOORD0) : COLOR
+{
+	return 1 - tex2D(RT, iTexCoord);
+}
Index: code/branches/skybox/Media/materials/programs/LaplaceFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/LaplaceFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/LaplaceFP.cg	(revision 390)
@@ -0,0 +1,36 @@
+sampler Image : register(s0);
+
+// The Laplace filter approximates the second order derivate,
+// that is, the rate of change of slope in the image. It can be
+// used for edge detection. The Laplace filter gives negative
+// response on the higher side of the edge and positive response
+// on the lower side.
+
+// This is the filter kernel:
+// 0  1  0
+// 1 -4  1
+// 0  1  0
+
+
+
+float4 Laplace_ps (float2 texCoord: TEXCOORD0,
+			uniform float scale,
+			uniform float pixelSize) : COLOR
+{
+
+    float2 samples[4] = {
+        0, -1,
+       -1,  0,
+        1,  0,
+        0,  1
+    };
+   float4 laplace = -4 * tex2D(Image, texCoord);
+
+   // Sample the neighbor pixels
+   for (int i = 0; i < 4; i++){
+      laplace += tex2D(Image, texCoord + pixelSize * samples[i]);
+   }
+
+   return (0.5 + scale * laplace);
+}
+
Index: code/branches/skybox/Media/materials/programs/Ocean2GLSL.frag
===================================================================
--- code/branches/skybox/Media/materials/programs/Ocean2GLSL.frag	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Ocean2GLSL.frag	(revision 390)
@@ -0,0 +1,71 @@
+/*********************************************************************NVMH3****
+Copyright NVIDIA Corporation 2003
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Comments:
+	Simple ocean shader with animated bump map and geometric waves
+	Based partly on "Effective Water Simulation From Physical Models", GPU Gems
+
+11 Aug 05: converted from HLSL to GLSL by Jeff Doyle (nfz) to work in Ogre
+
+******************************************************************************/
+
+
+uniform sampler2D NormalMap;
+uniform samplerCube EnvironmentMap;
+uniform vec4 deepColor;
+uniform vec4 shallowColor;
+uniform vec4 reflectionColor;
+uniform float reflectionAmount;
+uniform float reflectionBlur;
+uniform float waterAmount;
+uniform float fresnelPower;
+uniform float fresnelBias;
+uniform float hdrMultiplier;
+
+varying mat3 rotMatrix; // first row of the 3x3 transform from tangent to cube space
+varying vec2 bumpCoord0;
+varying vec2 bumpCoord1;
+varying vec2 bumpCoord2;
+varying vec3 eyeVector;
+
+
+void main(void)
+{
+	// sum normal maps
+	// sample from 3 different points so no texture repetition is noticeable
+    vec4 t0 = texture2D(NormalMap, bumpCoord0) * 2.0 - 1.0;
+    vec4 t1 = texture2D(NormalMap, bumpCoord1) * 2.0 - 1.0;
+    vec4 t2 = texture2D(NormalMap, bumpCoord2) * 2.0 - 1.0;
+    vec3 N = t0.xyz + t1.xyz + t2.xyz;
+
+    N = normalize(rotMatrix * N);
+
+	// reflection
+    vec3 E = normalize(eyeVector);
+    vec3 R = reflect(E, N);
+    // Ogre conversion for cube map lookup
+    R.z = -R.z;
+
+    vec4 reflection = textureCube(EnvironmentMap, R, reflectionBlur);
+    // cheap hdr effect
+    reflection.rgb *= (reflection.r + reflection.g + reflection.b) * hdrMultiplier;
+
+	// fresnel
+    float facing = 1.0 - dot(-E, N);
+    float fresnel = clamp(fresnelBias + pow(facing, fresnelPower), 0.0, 1.0);
+
+    vec4 waterColor = mix(shallowColor, deepColor, facing) * waterAmount;
+
+    reflection = mix(waterColor,  reflection * reflectionColor, fresnel) * reflectionAmount;
+    gl_FragColor = waterColor + reflection;
+}
Index: code/branches/skybox/Media/materials/programs/Ocean2GLSL.vert
===================================================================
--- code/branches/skybox/Media/materials/programs/Ocean2GLSL.vert	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Ocean2GLSL.vert	(revision 390)
@@ -0,0 +1,91 @@
+/*********************************************************************NVMH3****
+Copyright NVIDIA Corporation 2003
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Comments:
+	Simple ocean shader with animated bump map and geometric waves
+	Based partly on "Effective Water Simulation From Physical Models", GPU Gems
+
+11 Aug 05: converted from HLSL to GLSL by Jeff Doyle (nfz) to work in Ogre
+
+******************************************************************************/
+
+uniform vec3 eyePosition;
+uniform float BumpScale;
+uniform vec2 textureScale;
+uniform vec2 bumpSpeed;
+uniform float time;
+uniform float waveFreq;
+uniform float waveAmp;
+
+varying mat3 rotMatrix; //  transform from tangent to obj space
+varying vec2 bumpCoord0;
+varying vec2 bumpCoord1;
+varying vec2 bumpCoord2;
+varying vec3 eyeVector;
+
+// wave functions
+struct Wave {
+  float freq;  // 2*PI / wavelength
+  float amp;   // amplitude
+  float phase; // speed * 2*PI / wavelength
+  vec2 dir;
+};
+
+
+void main(void)
+{
+
+	#define NWAVES 2
+
+	Wave wave[NWAVES];
+
+	wave[0] = Wave( waveFreq, waveAmp, 0.5, vec2(-1, 0) );
+	wave[1] = Wave( 3.0 * waveFreq, 0.33 * waveAmp, 1.7, vec2(-0.7, 0.7) );
+
+
+    vec4 P = gl_Vertex;
+
+	// sum waves
+	float ddx = 0.0, ddy = 0.0;
+	float deriv;
+	float angle;
+
+	// wave synthesis using two sine waves at different frequencies and phase shift
+	for(int i = 0; i<NWAVES; ++i)
+	{
+		angle = dot(wave[i].dir, P.xz) * wave[i].freq + time * wave[i].phase;
+		P.y += wave[i].amp * sin( angle );
+		// calculate derivate of wave function
+		deriv = wave[i].freq * wave[i].amp * cos(angle);
+		ddx -= deriv * wave[i].dir.x;
+		ddy -= deriv * wave[i].dir.y;
+	}
+
+	// compute the 3x3 tranform from tangent space to object space
+	// compute tangent basis
+    vec3 T = normalize(vec3(1.0, ddy, 0.0)) * BumpScale;
+    vec3 B = normalize(vec3(0.0, ddx, 1.0)) * BumpScale;
+    vec3 N = normalize(vec3(ddx, 1.0, ddy));
+
+	rotMatrix = mat3(T, B, N);
+
+	gl_Position = gl_ModelViewProjectionMatrix * P;
+
+	// calculate texture coordinates for normal map lookup
+	bumpCoord0.xy = gl_MultiTexCoord0.xy * textureScale + time * bumpSpeed;
+	bumpCoord1.xy = gl_MultiTexCoord0.xy * textureScale * 2.0 + time * bumpSpeed * 4.0;
+	bumpCoord2.xy = gl_MultiTexCoord0.xy * textureScale * 4.0 + time * bumpSpeed * 8.0;
+
+
+	eyeVector = P.xyz - eyePosition; // eye position in vertex space
+}
Index: code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.frag
===================================================================
--- code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.frag	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.frag	(revision 390)
@@ -0,0 +1,85 @@
+/*********************************************************************NVMH3****
+Copyright NVIDIA Corporation 2003
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Comments:
+	Simple ocean shader with animated bump map and geometric waves
+	Based partly on "Effective Water Simulation From Physical Models", GPU Gems
+
+11 Aug 05: heavily modified by Jeff Doyle (nfz) for Ogre
+
+******************************************************************************/
+
+
+
+struct v2f {
+	float4 Position  : POSITION;  // in clip space
+	float3 rotMatrix1 : TEXCOORD0; // first row of the 3x3 transform from tangent to obj space
+	float3 rotMatrix2 : TEXCOORD1; // second row of the 3x3 transform from tangent to obj space
+	float3 rotMatrix3 : TEXCOORD2; // third row of the 3x3 transform from tangent to obj space
+
+	float2 bumpCoord0 : TEXCOORD3;
+	float2 bumpCoord1 : TEXCOORD4;
+	float2 bumpCoord2 : TEXCOORD5;
+
+	float3 eyeVector  : TEXCOORD6;
+};
+
+
+float4 main(v2f IN,
+			uniform sampler2D NormalMap,
+			uniform samplerCUBE EnvironmentMap,
+			uniform float4 deepColor,
+			uniform float4 shallowColor,
+			uniform float4 reflectionColor,
+			uniform float reflectionAmount,
+			uniform float reflectionBlur,
+			uniform float waterAmount,
+			uniform float fresnelPower,
+			uniform float fresnelBias,
+			uniform float hdrMultiplier
+			) : COLOR
+{
+	// sum normal maps
+	// sample from 3 different points so no texture repetition is noticeable
+    float4 t0 = tex2D(NormalMap, IN.bumpCoord0) * 2.0 - 1.0;
+    float4 t1 = tex2D(NormalMap, IN.bumpCoord1) * 2.0 - 1.0;
+    float4 t2 = tex2D(NormalMap, IN.bumpCoord2) * 2.0 - 1.0;
+    float3 N = t0.xyz + t1.xyz + t2.xyz;
+
+    float3x3 m; // tangent to world matrix
+    m[0] = IN.rotMatrix1;
+    m[1] = IN.rotMatrix2;
+    m[2] = IN.rotMatrix3;
+
+    N = normalize( mul( N, m ) );
+
+	// reflection
+    float3 E = normalize(IN.eyeVector);
+    float4 R;
+    R.xyz = reflect(E, N);
+    // Ogre conversion for cube map lookup
+    R.z = -R.z;
+    R.w = reflectionBlur;
+    float4 reflection = texCUBEbias(EnvironmentMap, R);
+    // cheap hdr effect
+    reflection.rgb *= (reflection.r + reflection.g + reflection.b) * hdrMultiplier;
+
+	// fresnel
+    float facing = 1.0 - max(dot(-E, N), 0);
+    float fresnel = saturate(fresnelBias + pow(facing, fresnelPower));
+
+    float4 waterColor = lerp(shallowColor, deepColor, facing) * waterAmount;
+
+    reflection = lerp(waterColor,  reflection * reflectionColor, fresnel) * reflectionAmount;
+    return waterColor + reflection;
+}
Index: code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.vert
===================================================================
--- code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.vert	(revision 390)
+++ code/branches/skybox/Media/materials/programs/Ocean2HLSL_Cg.vert	(revision 390)
@@ -0,0 +1,108 @@
+/*********************************************************************NVMH3****
+Copyright NVIDIA Corporation 2003
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Comments:
+	Simple ocean shader with animated bump map and geometric waves
+	Based partly on "Effective Water Simulation From Physical Models", GPU Gems
+
+11 Aug 05: heavily modified by Jeff Doyle (nfz) for Ogre
+
+******************************************************************************/
+
+struct a2v {
+	float4 Position : POSITION;   // in object space
+	float2 TexCoord : TEXCOORD0;
+};
+
+struct v2f {
+	float4 Position  : POSITION;  // in clip space
+	float3 rotMatrix1 : TEXCOORD0; // first row of the 3x3 transform from tangent to obj space
+	float3 rotMatrix2 : TEXCOORD1; // second row of the 3x3 transform from tangent to obj space
+	float3 rotMatrix3 : TEXCOORD2; // third row of the 3x3 transform from tangent to obj space
+
+	float2 bumpCoord0 : TEXCOORD3;
+	float2 bumpCoord1 : TEXCOORD4;
+	float2 bumpCoord2 : TEXCOORD5;
+
+	float3 eyeVector  : TEXCOORD6;
+};
+
+// wave functions
+
+struct Wave {
+  float freq;  // 2*PI / wavelength
+  float amp;   // amplitude
+  float phase; // speed * 2*PI / wavelength
+  float2 dir;
+};
+
+v2f main(a2v IN,
+		uniform float4x4 WorldViewProj,
+		uniform float3 eyePosition,
+		uniform float BumpScale,
+		uniform float2 textureScale,
+		uniform float2 bumpSpeed,
+		uniform float time,
+		uniform float waveFreq,
+		uniform float waveAmp
+        )
+{
+	v2f OUT;
+
+	#define NWAVES 2
+	Wave wave[NWAVES] = {
+		{ 1.0, 1.0, 0.5, float2(-1, 0) },
+		{ 2.0, 0.5, 1.7, float2(-0.7, 0.7) }
+	};
+
+    wave[0].freq = waveFreq;
+    wave[0].amp = waveAmp;
+
+    wave[1].freq = waveFreq * 3.0;
+    wave[1].amp = waveAmp * 0.33;
+
+    float4 P = IN.Position;
+
+	// sum waves
+	float ddx = 0.0, ddy = 0.0;
+	float deriv;
+	float angle;
+
+	// wave synthesis using two sine waves at different frequencies and phase shift
+	for(int i = 0; i<NWAVES; ++i)
+	{
+		angle = dot(wave[i].dir, P.xz) * wave[i].freq + time * wave[i].phase;
+		P.y += wave[i].amp * sin( angle );
+		// calculate derivate of wave function
+		deriv = wave[i].freq * wave[i].amp * cos(angle);
+		ddx -= deriv * wave[i].dir.x;
+		ddy -= deriv * wave[i].dir.y;
+	}
+
+	// compute the 3x3 tranform from tangent space to object space
+	// first rows are the tangent and binormal scaled by the bump scale
+
+	OUT.rotMatrix1.xyz = BumpScale * normalize(float3(1, ddy, 0)); // Binormal
+	OUT.rotMatrix2.xyz = BumpScale * normalize(float3(0, ddx, 1)); // Tangent
+	OUT.rotMatrix3.xyz = normalize(float3(ddx, 1, ddy)); // Normal
+
+	OUT.Position = mul(WorldViewProj, P);
+
+	// calculate texture coordinates for normal map lookup
+	OUT.bumpCoord0.xy = IN.TexCoord*textureScale + time * bumpSpeed;
+	OUT.bumpCoord1.xy = IN.TexCoord*textureScale * 2.0 + time * bumpSpeed * 4.0;
+	OUT.bumpCoord2.xy = IN.TexCoord*textureScale * 4.0 + time * bumpSpeed * 8.0;
+
+	OUT.eyeVector = P.xyz - eyePosition; // eye position in vertex space
+	return OUT;
+}
Index: code/branches/skybox/Media/materials/programs/OffsetMapping.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/OffsetMapping.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OffsetMapping.cg	(revision 390)
@@ -0,0 +1,97 @@
+/* Bump mapping with Parallax offset vertex program 
+   In this program, we want to calculate the tangent space light end eye vectors 
+   which will get passed to the fragment program to produce the per-pixel bump map 
+   with parallax offset effect. 
+*/ 
+
+/* Vertex program that moves light and eye vectors into texture tangent space at vertex */ 
+
+void main_vp(float4 position   : POSITION, 
+              float3 normal      : NORMAL, 
+              float2 uv         : TEXCOORD0, 
+              float3 tangent     : TANGENT0, 
+              // outputs 
+              out float4 oPosition    : POSITION, 
+              out float2 oUv          : TEXCOORD0, 
+              out float3 oLightDir    : TEXCOORD1, // tangent space 
+             out float3 oEyeDir       : TEXCOORD2, // tangent space 
+             out float3 oHalfAngle    : TEXCOORD3, // 
+              // parameters 
+              uniform float4 lightPosition, // object space 
+              uniform float3 eyePosition,   // object space 
+              uniform float4x4 worldViewProj) 
+{  
+   // calculate output position 
+   oPosition = mul(worldViewProj, position); 
+
+   // pass the main uvs straight through unchanged 
+   oUv = uv; 
+
+   // calculate tangent space light vector 
+   // Get object space light direction 
+   float3 lightDir = normalize(lightPosition.xyz -  (position * lightPosition.w));
+   float3 eyeDir = eyePosition - position.xyz; 
+    
+   // Calculate the binormal (NB we assume both normal and tangent are 
+   // already normalised) 
+   // NB looks like nvidia cross params are BACKWARDS to what you'd expect 
+   // this equates to NxT, not TxN 
+   float3 binormal = cross(tangent, normal); 
+    
+   // Form a rotation matrix out of the vectors 
+   float3x3 rotation = float3x3(tangent, binormal, normal); 
+    
+   // Transform the light vector according to this matrix 
+   lightDir = normalize(mul(rotation, lightDir)); 
+   eyeDir = normalize(mul(rotation, eyeDir)); 
+
+   oLightDir = lightDir; 
+   oEyeDir = eyeDir; 
+   oHalfAngle = normalize(eyeDir + lightDir); 
+}
+
+// General functions
+
+// Expand a range-compressed vector
+float3 expand(float3 v)
+{
+	return (v - 0.5) * 2;
+}
+
+void main_fp(float2 uv : TEXCOORD0,
+	float3 lightDir : TEXCOORD1,
+	float3 eyeDir : TEXCOORD2,
+	float3 halfAngle : TEXCOORD3,
+	uniform float3 lightDiffuse,
+	uniform float3 lightSpecular,
+	uniform float4 scaleBias,
+	uniform sampler2D normalHeightMap,
+	uniform sampler2D diffuseMap,
+	out float4 oColor : COLOR)
+{
+	// get the height using the tex coords
+	float height = tex2D(normalHeightMap, uv).a;
+
+	// scale and bias factors	
+	float scale = scaleBias.x;
+	float bias = scaleBias.y;
+
+	// calculate displacement	
+	float displacement = (height * scale) + bias;
+	
+	float3 uv2 = float3(uv, 1);
+	
+	// calculate the new tex coord to use for normal and diffuse
+	float2 newTexCoord = ((eyeDir * displacement) + uv2).xy;
+	
+	// get the new normal and diffuse values
+	float3 normal = expand(tex2D(normalHeightMap, newTexCoord).xyz);
+	float3 diffuse = tex2D(diffuseMap, newTexCoord).xyz;
+	
+	float3 specular = pow(saturate(dot(normal, halfAngle)), 32) * lightSpecular;
+	float3 col = diffuse * saturate(dot(normal, lightDir)) * lightDiffuse + specular;
+		
+	oColor = float4(col, 1);
+}
+
+
Index: code/branches/skybox/Media/materials/programs/OffsetMapping.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/OffsetMapping.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OffsetMapping.hlsl	(revision 390)
@@ -0,0 +1,135 @@
+/* Offset mapping including a shadow element and multiple lights in one pass */ 
+void integratedshadows_vp(float4 position   : POSITION, 
+              float3 normal      : NORMAL, 
+              float2 uv         : TEXCOORD0, 
+              float3 tangent     : TANGENT0, 
+              // outputs 
+              out float4 oPosition    : POSITION, 
+              out float2 oUv          : TEXCOORD0, 
+              out float3 oLightDir    : TEXCOORD1, // tangent space 
+             out float3 oEyeDir       : TEXCOORD2, // tangent space 
+			 out float3 oSpotDirection : TEXCOORD3, // tangent space
+              out float3 oLightDir1    : TEXCOORD4, // tangent space 
+              out float3 oSpotDirection1    : TEXCOORD5, // tangent space 
+			 out float4 oShadowUV1 : TEXCOORD6,
+			 out float4 oShadowUV2 : TEXCOORD7,
+              // parameters 
+              uniform float4 lightPosition, // object space 
+              uniform float4 lightPosition1, // object space 
+              uniform float3 eyePosition,   // object space 
+ 			  uniform float3 spotDirection, // object space
+ 			  uniform float3 spotDirection1, // object space
+              uniform float4x4 worldViewProj,
+			  uniform float4x4 worldMatrix,
+			  uniform float4x4 texViewProj1,
+			  uniform float4x4 texViewProj2) 
+{  
+   // calculate output position 
+   oPosition = mul(worldViewProj, position); 
+
+   float4 worldPos = mul(worldMatrix, position);
+   oShadowUV1 = mul(texViewProj1, worldPos);
+   oShadowUV2 = mul(texViewProj2, worldPos);
+   
+   
+
+   // pass the main uvs straight through unchanged 
+   oUv = uv; 
+
+   // calculate tangent space light vector 
+   // Get object space light direction 
+   float3 lightDir = normalize(lightPosition.xyz -  (position * lightPosition.w));
+   float3 lightDir1 = normalize(lightPosition1.xyz -  (position * lightPosition1.w));
+   float3 eyeDir = eyePosition - position.xyz; 
+    
+   // Calculate the binormal (NB we assume both normal and tangent are 
+   // already normalised) 
+   // NB looks like nvidia cross params are BACKWARDS to what you'd expect 
+   // this equates to NxT, not TxN 
+   float3 binormal = cross(tangent, normal); 
+    
+   // Form a rotation matrix out of the vectors 
+   float3x3 rotation = float3x3(tangent, binormal, normal); 
+    
+   // Transform the light vector according to this matrix 
+   lightDir = normalize(mul(rotation, lightDir)); 
+   lightDir1 = normalize(mul(rotation, lightDir1)); 
+   eyeDir = normalize(mul(rotation, eyeDir)); 
+
+   oLightDir = lightDir; 
+   oLightDir1 = lightDir1; 
+   oEyeDir = eyeDir; 
+   oSpotDirection = normalize(mul(rotation, -spotDirection));
+   oSpotDirection1 = normalize(mul(rotation, -spotDirection1));
+}
+
+// Expand a range-compressed vector
+float3 expand(float3 v)
+{
+	return (v - 0.5) * 2;
+}
+
+void integratedshadows_fp(
+	float2 uv : TEXCOORD0,
+	float3 lightDir : TEXCOORD1,
+	float3 eyeDir : TEXCOORD2,
+	float3 spotDir : TEXCOORD3,
+	float3 lightDir1 : TEXCOORD4,
+	float3 spotDir1 : TEXCOORD5,
+	float4 shadowUV1 : TEXCOORD6,
+	float4 shadowUV2 : TEXCOORD7,
+	uniform float3 lightDiffuse,
+	uniform float4 scaleBias,
+    uniform float4 spotParams,
+	uniform float3 lightDiffuse1,
+    uniform float4 spotParams1,
+	uniform sampler2D normalHeightMap : register(s0),
+	uniform sampler2D diffuseMap : register(s1),
+	uniform sampler2D shadowMap1 : register(s2),
+	uniform sampler2D shadowMap2 : register(s3),
+	out float4 oColour : COLOR)
+{
+	// get the height using the tex coords
+	float height = tex2D(normalHeightMap, uv).a;
+
+	// scale and bias factors	
+	float scale = scaleBias.x;
+	float bias = scaleBias.y;
+
+	// calculate displacement	
+	float displacement = (height * scale) + bias;
+	
+	float3 uv2 = float3(uv, 1);
+
+	float3 scaledEyeDir = eyeDir * displacement;
+	
+	// calculate the new tex coord to use for normal and diffuse
+	float2 newTexCoord = (scaledEyeDir + uv2).xy;
+	
+	// get the new normal and diffuse values
+	float3 normal = expand(tex2D(normalHeightMap, newTexCoord).xyz);
+	float3 diffuse = tex2D(diffuseMap, newTexCoord).xyz;
+	
+	float3 col1 = diffuse * saturate(dot(normal, lightDir)) * lightDiffuse;
+	// factor in spotlight angle
+	float rho = saturate(dot(spotDir, lightDir));
+	// factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff
+	float spotFactor = pow(
+		saturate(rho - spotParams.y) / (spotParams.x - spotParams.y), spotParams.z);
+	col1 = col1 * spotFactor;
+	float3 col2 = diffuse * saturate(dot(normal, lightDir1)) * lightDiffuse1;
+	// factor in spotlight angle
+	rho = saturate(dot(spotDir1, lightDir1));
+	// factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff
+	spotFactor = pow(
+		saturate(rho - spotParams1.y) / (spotParams1.x - spotParams1.y), spotParams1.z);
+	col2 = col2 * spotFactor;
+
+	// shadow textures
+	col1 = col1 * tex2Dproj(shadowMap1, shadowUV1);
+	col2 = col2 * tex2Dproj(shadowMap2, shadowUV2);
+
+	oColour = float4(col1 + col2, 1);
+
+}
+
Index: code/branches/skybox/Media/materials/programs/OffsetMappingFp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/OffsetMappingFp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OffsetMappingFp.glsl	(revision 390)
@@ -0,0 +1,69 @@
+uniform vec4 lightDiffuse;
+uniform vec4 scaleBias;
+uniform vec4 spotParams;
+uniform vec4 lightDiffuse1;
+uniform vec4 spotParams1;
+
+uniform sampler2D normalHeightMap;
+uniform sampler2D diffuseMap;
+uniform sampler2D shadowMap1;
+uniform sampler2D shadowMap2;
+
+
+
+varying vec3 tangentEyeDir;
+varying vec3 tangentLightDir[2];
+varying vec3 tangentSpotDir[2];
+varying vec4 shadowUV[2];
+
+
+// Expand a range-compressed vector
+vec3 expand(vec3 v)
+{
+	return (v - 0.5) * 2.0;
+}
+
+
+void main()
+{
+	// get the height using the tex coords
+	float height = texture2D(normalHeightMap, gl_TexCoord[0].xy).a;
+	// scale and bias factors	
+	float scale = scaleBias.x;
+	float bias = scaleBias.y;
+
+	// calculate displacement	
+	float displacement = (height * scale) + bias;
+	//float displacement = (height * 0.04) - 0.02;
+	
+	vec3 scaledEyeDir = tangentEyeDir * displacement;
+	
+	// calculate the new tex coord to use for normal and diffuse
+	vec2 newTexCoord = (scaledEyeDir + gl_TexCoord[0].xyz).xy;
+	
+	// get the new normal and diffuse values
+	vec3 normal = expand(texture2D(normalHeightMap, newTexCoord).xyz);
+	vec4 diffuse = texture2D(diffuseMap, newTexCoord);
+	
+	vec4 col1 = diffuse * clamp(dot(normal, tangentLightDir[0]),0.0,1.0) * lightDiffuse;
+	// factor in spotlight angle
+	float rho = clamp(dot(tangentSpotDir[0], tangentLightDir[0]),0.0,1.0);
+	// factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff
+	float spotFactor = pow(
+		clamp(rho - spotParams.y,0.0,1.0) / (spotParams.x - spotParams.y), spotParams.z);
+	col1 = col1 * spotFactor;
+	vec4 col2 = diffuse * clamp(dot(normal, tangentLightDir[1]),0.0,1.0) * lightDiffuse1;
+	// factor in spotlight angle
+	rho = clamp(dot(tangentSpotDir[1], tangentLightDir[1]),0.0,1.0);
+	// factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff
+	spotFactor = pow(
+		clamp(rho - spotParams1.y,0.0,1.0) / (spotParams1.x - spotParams1.y), spotParams1.z);
+	col2 = col2 * spotFactor;
+
+	// shadow textures
+	col1 = col1 * texture2DProj(shadowMap1, shadowUV[0]);
+	col2 = col2 * texture2DProj(shadowMap2, shadowUV[1]);
+
+	gl_FragColor = col1 + col2;
+
+}
Index: code/branches/skybox/Media/materials/programs/OffsetMappingVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/OffsetMappingVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OffsetMappingVp.glsl	(revision 390)
@@ -0,0 +1,54 @@
+attribute vec3 tangent;
+
+uniform vec4 lightPosition; // object space 
+uniform vec4 lightPosition1; // object space 
+uniform vec4 eyePosition;   // object space 
+uniform vec4 spotDirection; // object space
+uniform vec4 spotDirection1; // object space
+uniform mat4 worldViewProj; // not actually used but here for compat with HLSL
+uniform mat4 worldMatrix;
+uniform mat4 texViewProj1;
+uniform mat4 texViewProj2;
+
+
+varying vec3 tangentEyeDir;
+varying vec3 tangentLightDir[2];
+varying vec3 tangentSpotDir[2];
+varying vec4 shadowUV[2];
+
+void main()
+{
+	gl_Position = ftransform();
+
+	vec4 worldPos = worldMatrix * gl_Vertex;
+
+	shadowUV[0] = texViewProj1 * worldPos;
+	shadowUV[1] = texViewProj2 * worldPos;
+
+	// pass the main uvs straight through unchanged 
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+
+	// calculate tangent space light vector 
+	// Get object space light direction 
+    vec3 lightDir = normalize(lightPosition.xyz -  (gl_Vertex.xyz * lightPosition.w));
+	vec3 lightDir1 = normalize(lightPosition1.xyz -  (gl_Vertex.xyz * lightPosition1.w));
+	
+	vec3 eyeDir = (eyePosition - gl_Vertex).xyz; 
+
+	// Calculate the binormal (NB we assume both normal and tangent are 
+	// already normalised) 
+	vec3 binormal = cross(gl_Normal, tangent); 
+
+	// Form a rotation matrix out of the vectors 
+	mat3 rotation = mat3(tangent, binormal, gl_Normal); 
+    
+	// Transform the light vector according to this matrix 
+	tangentLightDir[0] = normalize(rotation * lightDir); 
+	tangentLightDir[1] = normalize(rotation * lightDir1); 
+	// Invert the Y on the eye dir since we'll be using this to alter UVs and
+	// GL has Y inverted
+	tangentEyeDir = normalize(rotation * eyeDir) * vec3(1, -1, 1); 
+
+	tangentSpotDir[0] = normalize(rotation * -spotDirection.xyz);
+	tangentSpotDir[1] = normalize(rotation * -spotDirection1.xyz);	
+}
Index: code/branches/skybox/Media/materials/programs/OffsetMapping_specular.asm
===================================================================
--- code/branches/skybox/Media/materials/programs/OffsetMapping_specular.asm	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OffsetMapping_specular.asm	(revision 390)
@@ -0,0 +1,44 @@
+// Pixel Shader for doing bump mapping with parallax plus diffuse and specular lighting by nfz 
+
+// uv               TEXCOORD0 
+// lightDir            TEXCOORD1 
+// eyeDir            TEXCOORD2 
+// half               TEXCOORD3 
+
+// lightDiffuse         c0 
+// lightSpecular      c1 
+// Parallax scale and bias c2 
+// normal/height map   texunit 0 - height map in alpha channel 
+// diffuse texture      texunit 1 
+
+ps.1.4 
+
+
+texld r0, t0               // get height 
+texcrd r2.xyz, t0            // get uv coordinates 
+texcrd r3.xyz, t2            // get eyedir vector 
+
+
+mad r0.xyz, r0.a, c2.x, c2.y   // displacement = height * scale + bias 
+mad r2.xyz, r3, r0, r2         // newtexcoord = eyedir * displacement + uv 
+
+phase 
+
+texld r0, r2.xyz            // get normal N using newtexcoord 
+texld r1, r2.xyz            // get diffuse texture using newtexcoord 
+texcrd r4.xyz, t1            // get lightdir vector 
+texcrd r5.xyz, t3            // get half angle vector 
+
+dp3_sat r5.rgb, r0_bx2, r5         // N dot H - spec calc 
+dp3_sat r4.rgb, r0_bx2, r4         // N dot L - diffuse calc 
++ mul r5.a, r5.r, r5.r 
+mul r0.rgb, r4, r1            // colour = diffusetex * N dot L 
++ mul r5.a, r5.a, r5.a 
+
+mul r5.rgb, r5.a, r5.a          
+mul r5.rgb, r5, r5          
+mul r5.rgb, r5, r5          
+mul r5.rgb, r5, c1            // specular = (N dot H)^32 * specularlight 
+
+mad r0.rgb, r0, c0, r5         // colour = diffusetex * (N dot L)* diffuselight + specular 
++ mov r0.a, c2.b 
Index: code/branches/skybox/Media/materials/programs/OldMovieFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/OldMovieFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OldMovieFP.cg	(revision 390)
@@ -0,0 +1,54 @@
+sampler RT : register(s0);
+sampler SplotchesTx : register(s1);
+sampler Texture2 : register(s2);
+sampler SepiaTx : register(s3);
+
+float2 calcSpriteAddr(float2 texCoord, float DirtFrequency, float period)
+{
+   return texCoord + tex1D(Texture2, period  * DirtFrequency);
+}
+
+float4 getSplotches(float2 spriteAddr)
+{
+   // get sprite address into paged texture coords space
+   spriteAddr = spriteAddr / 6.3f;
+   //spriteAddr = spriteAddr - frac(spriteAddr);
+   spriteAddr = spriteAddr - (spriteAddr /33.3f);
+
+   return tex2D(SplotchesTx, spriteAddr);
+}
+
+float4 OldMovie_ps (float2 texCoord  : TEXCOORD0,
+				uniform float time_cycle_period,
+				uniform float flicker,
+				uniform float DirtFrequency,
+				uniform float3 luminance,
+				uniform float frameJitter,
+				uniform float lumiShift
+				) : COLOR
+{
+
+   // get sprite address
+   float2 spriteAddr = calcSpriteAddr(texCoord, DirtFrequency, time_cycle_period);
+
+    // add some dark and light splotches to the film
+   float4 splotches = getSplotches(spriteAddr);
+   float4 specs = 1.0f - getSplotches(spriteAddr / 3.0f);
+
+   // convert color to base luminance
+   float4 base = tex2D(RT, texCoord + float2(0, spriteAddr.y * frameJitter));
+   float lumi = dot(base.rgb, luminance);
+   // randomly shift luminance
+   lumi -= spriteAddr.x * lumiShift;
+   // tone map luminance
+   base.rgb = tex1D(SepiaTx, lumi );
+
+   // calc flicker speed
+   float darken = frac(flicker * time_cycle_period);
+
+   // we want darken to cycle between 0.6 and 1.0
+   darken = abs(darken - 0.5f) * 0.4f + 0.6f;
+   // composite dirt onto film
+   return base * splotches * darken + specs;
+}
+
Index: code/branches/skybox/Media/materials/programs/OldTV.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/OldTV.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/OldTV.cg	(revision 390)
@@ -0,0 +1,42 @@
+
+
+sampler Image: register(s0);
+sampler Rand: register(s1);
+sampler Noise: register(s2);
+
+float4 OldTV_ps(float2 pos: TEXCOORD1, float2 img: TEXCOORD0,
+    uniform float distortionFreq: register(c3),
+    uniform float distortionScale: register(c4),
+    uniform float distortionRoll: register(c5),
+    uniform float interference: register(c7),
+    uniform float frameLimit: register(c8),
+    uniform float frameShape: register(c0),
+    uniform float frameSharpness: register(c1),
+    uniform float time_0_X: register(c2),
+    uniform float sin_time_0_X: register(c6)
+
+) : COLOR {
+   // Define a frame shape
+   float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y);
+   float frame = saturate(frameSharpness * (pow(f, frameShape) - frameLimit));
+
+   // Interference ... just a texture filled with rand()
+   float rand = tex3D(Rand, float3(1.5 * pos, time_0_X)) - 0.2;
+
+   // Some signed noise for the distortion effect
+   float noisy = tex3D(Noise, float3(0, 0.5 * pos.y, 0.1 * time_0_X)) - 0.5;
+
+   // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
+   float dst = frac(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
+   dst *= (1 - dst);
+   // Make sure distortion is highest in the center of the image
+   dst /= 1 + distortionScale * abs(pos.y);
+
+   // ... and finally distort
+   img.x += distortionScale * noisy * dst;
+   float4 image = tex2D(Image, img);
+
+   // Combine frame, distorted image and interference
+   return frame * (interference * rand + image);
+}
+
Index: code/branches/skybox/Media/materials/programs/PosterizeFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/PosterizeFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/PosterizeFP.cg	(revision 390)
@@ -0,0 +1,17 @@
+sampler RT : register(s0);
+
+float4 Posterize_ps (float2 iTexCoord : TEXCOORD0) : COLOR
+{
+
+	float nColors = 8;
+	float gamma = 0.6;
+
+	float4 texCol = tex2D(RT, iTexCoord);
+	float3 tc = texCol.xyz;
+	tc = pow(tc, gamma);
+	tc = tc * nColors;
+	tc = floor(tc);
+	tc = tc / nColors;
+	tc = pow(tc,1.0/gamma);
+	return float4(tc,texCol.w);
+}
Index: code/branches/skybox/Media/materials/programs/SharpenEdgesFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/SharpenEdgesFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/SharpenEdgesFP.cg	(revision 390)
@@ -0,0 +1,23 @@
+sampler RT: register(s0);
+
+float4 sharpenEdges_fp(float2 iTexCoord: TEXCOORD0, uniform float2 vTexelSize) : COLOR
+{
+
+	float2 usedTexelED[8] = {
+		-1, -1,
+		 0, -1,
+		 1, -1,
+		-1,  0,
+		 1,  0,
+		-1,  1,
+		 0,  1,
+	     1,  1,
+	};
+
+	float4 cAvgColor= 9 * tex2D (RT, iTexCoord);
+
+	for(int t=0; t<8; t++)
+		cAvgColor -= tex2D(RT, iTexCoord + vTexelSize * usedTexelED[t]);
+
+	return cAvgColor;
+}
Index: code/branches/skybox/Media/materials/programs/StdQuad_vp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/StdQuad_vp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/StdQuad_vp.cg	(revision 390)
@@ -0,0 +1,113 @@
+void StdQuad_vp
+(
+    in float4 inPos : POSITION,
+
+    out float4 pos : POSITION,
+    out float2 uv0 : TEXCOORD0,
+
+    uniform float4x4 worldViewProj
+)
+{
+    // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
+    pos = mul(worldViewProj, inPos);
+
+    // The input positions adjusted by texel offsets, so clean up inaccuracies
+    inPos.xy = sign(inPos.xy);
+
+    // Convert to image-space
+    uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
+}
+
+void StdQuad_Tex2_vp
+(
+    in float4 inPos : POSITION,
+
+    out float4 pos : POSITION,
+    out float2 uv0 : TEXCOORD0,
+    out float2 uv1 : TEXCOORD1,
+
+    uniform float4x4 worldViewProj
+)
+{
+    // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
+    pos = mul(worldViewProj, inPos);
+
+    // The input positions adjusted by texel offsets, so clean up inaccuracies
+    inPos.xy = sign(inPos.xy);
+
+    // Convert to image-space
+    uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
+    uv1 = uv0;
+}
+
+void StdQuad_Tex2a_vp
+(
+    in float4 inPos : POSITION,
+
+    out float4 pos : POSITION,
+    out float2 uv0 : TEXCOORD0,
+    out float2 uv1 : TEXCOORD1,
+
+    uniform float4x4 worldViewProj
+)
+{
+    // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
+    pos = mul(worldViewProj, inPos);
+
+    // The input positions adjusted by texel offsets, so clean up inaccuracies
+    inPos.xy = sign(inPos.xy);
+
+    // Convert to image-space
+    uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
+    uv1 = inPos.xy;
+}
+
+void StdQuad_Tex3_vp
+(
+    in float4 inPos : POSITION,
+
+    out float4 pos : POSITION,
+    out float2 uv0 : TEXCOORD0,
+    out float2 uv1 : TEXCOORD1,
+    out float2 uv2 : TEXCOORD2,
+
+    uniform float4x4 worldViewProj
+)
+{
+    // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
+    pos = mul(worldViewProj, inPos);
+
+    // The input positions adjusted by texel offsets, so clean up inaccuracies
+    inPos.xy = sign(inPos.xy);
+
+    // Convert to image-space
+    uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
+    uv1 = uv0;
+    uv2 = uv0;
+}
+
+void StdQuad_Tex4_vp
+(
+    in float4 inPos : POSITION,
+
+    out float4 pos : POSITION,
+    out float2 uv0 : TEXCOORD0,
+    out float2 uv1 : TEXCOORD1,
+    out float2 uv2 : TEXCOORD2,
+    out float2 uv3 : TEXCOORD3,
+
+    uniform float4x4 worldViewProj
+)
+{
+    // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc)
+    pos = mul(worldViewProj, inPos);
+
+    // The input positions adjusted by texel offsets, so clean up inaccuracies
+    inPos.xy = sign(inPos.xy);
+
+    // Convert to image-space
+    uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
+    uv1 = uv0;
+    uv2 = uv0;
+    uv3 = uv0;
+}
Index: code/branches/skybox/Media/materials/programs/StdQuad_vp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/StdQuad_vp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/StdQuad_vp.glsl	(revision 390)
@@ -0,0 +1,11 @@
+varying vec2 uv;
+
+void main()                    
+{
+	gl_Position = ftransform();
+	
+	vec2 inPos = sign(gl_Vertex.xy);
+	
+	uv = (vec2(inPos.x, -inPos.y) + 1.0)/2.0;
+}
+
Index: code/branches/skybox/Media/materials/programs/TilingFP.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/TilingFP.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/TilingFP.cg	(revision 390)
@@ -0,0 +1,33 @@
+sampler RT : register(s0);
+
+float4 Tiling_ps(float4 inPos : POSITION,
+				float2 iTexCoord : TEXCOORD0,
+				uniform half NumTiles,
+				uniform half Threshhold) : COLOR
+{
+
+
+	half3 EdgeColor = {0.7, 0.7, 0.7};
+
+    half size = 1.0/NumTiles;
+    half2 Pbase = iTexCoord - fmod(iTexCoord, size.xx);
+    half2 PCenter = Pbase + (size/2.0).xx;
+    half2 st = (iTexCoord - Pbase)/size;
+    half4 c1 = (half4)0;
+    half4 c2 = (half4)0;
+    half4 invOff = half4((1-EdgeColor),1);
+    if (st.x > st.y) { c1 = invOff; }
+    half threshholdB =  1.0 - Threshhold;
+    if (st.x > threshholdB) { c2 = c1; }
+    if (st.y > threshholdB) { c2 = c1; }
+    half4 cBottom = c2;
+    c1 = (half4)0;
+    c2 = (half4)0;
+    if (st.x > st.y) { c1 = invOff; }
+    if (st.x < Threshhold) { c2 = c1; }
+    if (st.y < Threshhold) { c2 = c1; }
+    half4 cTop = c2;
+    half4 tileColor = tex2D(RT, PCenter);
+    half4 result = tileColor + cTop - cBottom;
+    return result;
+}
Index: code/branches/skybox/Media/materials/programs/crowdVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/crowdVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/crowdVp.glsl	(revision 390)
@@ -0,0 +1,62 @@
+uniform mat4 viewProjectionMatrix;
+uniform float numBones;
+uniform vec4 worldMatrix3x4Array[240];
+uniform vec4 lightDiffuseColour;
+uniform vec4 ambient;
+uniform vec4 lightPos;
+
+attribute vec4 blendIndices;
+attribute vec4 blendWeights;
+
+
+void main()
+{
+	vec3 blendPos = vec3(0,0,0);
+	vec3 blendNorm = vec3(0,0,0);
+	
+	vec3 tmpPos = vec3(0,0,0);
+	vec3 tmpNorm = vec3(0,0,0);
+
+
+	int instanceOffset = int(gl_MultiTexCoord1.x) * 3 * int(numBones);
+	for (int bone = 0; bone < 2; ++bone)
+	{
+		// perform matrix multiplication manually since no 3x4 matrices
+		for (int row = 0; row < 3; ++row)
+		{
+		    int idx = instanceOffset + int(blendIndices[bone]) * 3 + row;
+			vec4 blendMatrixRow = worldMatrix3x4Array[idx];
+			tmpPos[row] = dot(blendMatrixRow, gl_Vertex);
+#if SHADOW_CASTER
+#else
+			tmpNorm[row] = dot(blendMatrixRow.xyz, gl_Normal);
+#endif
+			
+		}
+		// now weight this into final 
+		blendPos += tmpPos * blendWeights[bone];
+#if SHADOW_CASTER
+#else
+		blendNorm += tmpNorm * blendWeights[bone];
+#endif
+	}
+
+	// apply view / projection to position
+	gl_Position = viewProjectionMatrix * vec4(blendPos, 1);
+
+	
+#if SHADOW_CASTER
+	gl_FrontColor = ambient;
+#else
+	// simple lighting model
+	vec3 lightDir = normalize(
+		lightPos.xyz -  (blendPos.xyz * lightPos.w));
+	gl_FrontColor = ambient 
+		+ clamp(dot(lightDir, blendNorm), 0.0, 1.0) * lightDiffuseColour;
+#endif
+    gl_FrontSecondaryColor = vec4(0);
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+
+	
+}
+
Index: code/branches/skybox/Media/materials/programs/hdr.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr.cg	(revision 390)
@@ -0,0 +1,25 @@
+void morningskybox_fp (
+	float2 uv : TEXCOORD0,
+	out float4 colour : COLOR,
+
+	uniform sampler2D tex : register(s0) )
+{
+	colour = tex2D(tex, uv);
+
+	// blow out the light a bit
+	colour *= 1.7;
+}
+void morningcubemap_fp (
+	float3 uv : TEXCOORD0,
+	out float4 colour : COLOR,
+
+	uniform samplerCUBE tex : register(s0) )
+{
+	colour = texCUBE(tex, uv);
+
+	// blow out the light a bit
+	colour *= 1.7;
+}
+
+
+
Index: code/branches/skybox/Media/materials/programs/hdr.hlsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr.hlsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr.hlsl	(revision 390)
@@ -0,0 +1,228 @@
+// RGBE mode utilities
+// RGB each carry a mantissa, A carries a shared exponent
+// The exponent is calculated based on the largest colour channel
+
+
+float3 decodeRGBE8(in float4 rgbe)
+{
+    // get exponent (-128 since it can be +ve or -ve)
+	float exp = rgbe.a * 255 - 128;
+	
+	// expand out the rgb value
+	return rgbe.rgb * exp2(exp);
+}
+
+float4 encodeRGBE8(in float3 rgb)
+{
+	float4 ret;
+
+    // What is the largest colour channel?
+	float highVal = max(rgb.r, max(rgb.g, rgb.b));
+	
+	// Take the logarithm, clamp it to a whole value
+	float exp = ceil(log2(highVal));
+
+    // Divide the components by the shared exponent
+	ret.rgb = rgb / exp2(exp);
+	
+	// Store the shared exponent in the alpha channel
+	ret.a = (exp + 128) / 255;
+
+	return ret;
+}
+
+
+static const float4 LUMINENCE_FACTOR  = float4(0.27f, 0.67f, 0.06f, 0.0f);
+static const float MIDDLE_GREY = 0.72f;
+static const float FUDGE = 0.001f;
+static const float L_WHITE = 1.5f;
+static const float4 BRIGHT_LIMITER = float4(0.6f, 0.6f, 0.6f, 0.0f);
+
+
+/** Tone mapping function 
+@note Only affects rgb, not a
+@param inColour The HDR colour
+@param lum The scene lumninence 
+@returns Tone mapped colour
+*/
+float4 toneMap(float4 inColour, float lum)
+{
+	// From Reinhard et al
+	// "Photographic Tone Reproduction for Digital Images"
+	
+	// Initial luminence scaling (equation 2)
+    inColour.rgb *= MIDDLE_GREY / (FUDGE + lum);
+
+	// Control white out (equation 4 nom)
+    inColour.rgb *= (1.0f + inColour / L_WHITE);
+
+	// Final mapping (equation 4 denom)
+	inColour.rgb /= (1.0f + inColour);
+	
+	return inColour;
+
+}
+
+/* Downsample a 2x2 area and convert to greyscale
+*/
+float4 downscale2x2Luminence(
+	float2 uv : TEXCOORD0,
+	uniform float2 texelSize, // depends on size of source texture
+	uniform sampler2D inRTT : register(s0)
+    ) : COLOR
+{
+	
+    float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+	float2 texOffset[4] = {
+		-0.5, -0.5,
+		-0.5,  0.5, 
+		 0.5, -0.5,
+		 0.5, 0.5 };
+
+	for( int i = 0; i < 4; i++ )
+    {
+        // Get colour from source
+        accum += tex2D(inRTT, uv + texelSize * texOffset[i]);
+    }
+    
+	// Adjust the accumulated amount by lum factor
+	// Cannot use float3's here because it generates dependent texture errors because of swizzle
+	float lum = dot(accum, LUMINENCE_FACTOR);
+	// take average of 4 samples
+	lum *= 0.25;
+	return lum;
+
+}
+
+/* Downsample a 3x3 area 
+ * This shader is used multiple times on different source sizes, so texel size has to be configurable
+*/
+float4 downscale3x3(
+	float2 uv : TEXCOORD0,
+	uniform float2 texelSize, // depends on size of source texture
+	uniform sampler2D inRTT : register(s0)
+    ) : COLOR
+{
+	
+    float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+	float2 texOffset[9] = {
+		-1.0, -1.0,
+		 0.0, -1.0,
+		 1.0, -1.0,
+		-1.0,  0.0,
+		 0.0,  0.0,
+		 1.0,  0.0,
+		-1.0,  1.0,
+		 0.0,  1.0,
+		 1.0,  1.0
+	};
+
+	for( int i = 0; i < 9; i++ )
+    {
+        // Get colour from source
+        accum += tex2D(inRTT, uv + texelSize * texOffset[i]);
+    }
+    
+	// take average of 9 samples
+	accum *= 0.1111111111111111;
+	return accum;
+
+}
+
+/* Downsample a 3x3 area from main RTT and perform a brightness pass
+*/
+float4 downscale3x3brightpass(
+	float2 uv : TEXCOORD0,
+	uniform float2 texelSize, // depends on size of source texture
+	uniform sampler2D inRTT : register(s0),
+	uniform sampler2D inLum : register(s1)
+    ) : COLOR
+{
+	
+    float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+	float2 texOffset[9] = {
+		-1.0, -1.0,
+		 0.0, -1.0,
+		 1.0, -1.0,
+		-1.0,  0.0,
+		 0.0,  0.0,
+		 1.0,  0.0,
+		-1.0,  1.0,
+		 0.0,  1.0,
+		 1.0,  1.0
+	};
+
+	for( int i = 0; i < 9; i++ )
+    {
+        // Get colour from source
+        accum += tex2D(inRTT, uv + texelSize * texOffset[i]);
+    }
+    
+	// take average of 9 samples
+	accum *= 0.1111111111111111;
+
+    // Reduce bright and clamp
+    accum = max(float4(0.0f, 0.0f, 0.0f, 1.0f), accum - BRIGHT_LIMITER);
+
+	// Sample the luminence texture
+	float4 lum = tex2D(inLum, float2(0.5f, 0.5f));
+	
+	// Tone map result
+	return toneMap(accum, lum.r);
+
+}
+
+/* Gaussian bloom, requires offsets and weights to be provided externally
+*/
+float4 bloom(
+		float2 uv : TEXCOORD0,
+		uniform float2 sampleOffsets[15],
+		uniform float4 sampleWeights[15],	
+		uniform sampler2D inRTT : register(s0)
+		) : COLOR
+{
+    float4 accum = float4(0.0f, 0.0f, 0.0f, 1.0f);
+	float2 sampleUV;
+    
+    for( int i = 0; i < 15; i++ )
+    {
+        // Sample from adjacent points, 7 each side and central
+        sampleUV = uv + sampleOffsets[i];
+        accum += sampleWeights[i] * tex2D(inRTT, sampleUV);
+    }
+    
+    return accum;
+	
+}
+		
+
+/* Final scene composition, with tone mapping
+*/
+float4 finalToneMapping(
+	float2 uv : TEXCOORD0,
+	uniform sampler2D inRTT : register(s0),
+	uniform sampler2D inBloom : register(s1),
+	uniform sampler2D inLum : register(s2)
+    ) : COLOR
+{
+	// Get main scene colour
+    float4 sceneCol = tex2D(inRTT, uv);
+
+	// Get luminence value
+	float4 lum = tex2D(inLum, float2(0.5f, 0.5f));
+
+	// tone map this
+	float4 toneMappedSceneCol = toneMap(sceneCol, lum.r);
+	
+	// Get bloom colour
+    float4 bloom = tex2D(inBloom, uv);
+
+	// Add scene & bloom
+	return float4(toneMappedSceneCol.rgb + bloom.rgb, 1.0f);
+     	
+}
+
+
Index: code/branches/skybox/Media/materials/programs/hdr_bloom.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_bloom.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_bloom.glsl	(revision 390)
@@ -0,0 +1,22 @@
+uniform sampler2D inRTT;
+
+uniform vec4 sampleOffsets[15];
+uniform vec4 sampleWeights[15];
+
+varying vec2 uv;
+
+void main(void)
+{
+    vec4 accum = vec4(0.0, 0.0, 0.0, 1.0);
+	vec2 sampleUV;
+    
+    for( int i = 0; i < 15; i++ )
+    {
+        // Sample from adjacent points, 7 each side and central
+        sampleUV = uv + sampleOffsets[i].xy;
+        accum += sampleWeights[i] * texture2D(inRTT, sampleUV);
+    }
+    
+    gl_FragColor = accum;
+	
+}
Index: code/branches/skybox/Media/materials/programs/hdr_downscale2x2luminence.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_downscale2x2luminence.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_downscale2x2luminence.glsl	(revision 390)
@@ -0,0 +1,24 @@
+uniform sampler2D inRTT;
+uniform vec2 texelSize;
+
+varying vec2 uv;
+
+void main(void)
+{
+	
+    vec4 accum = vec4(0.0, 0.0, 0.0, 0.0);
+	vec4 LUMINENCE_FACTOR  = vec4(0.27, 0.67, 0.06, 0.0);
+
+    // Get colour from source
+    accum += texture2D(inRTT, uv + texelSize * vec2(-0.5, -0.5));
+    accum += texture2D(inRTT, uv + texelSize * vec2(-0.5, 0.5));
+    accum += texture2D(inRTT, uv + texelSize * vec2(0.5, 0.5));
+    accum += texture2D(inRTT, uv + texelSize * vec2(0.5, -0.5));
+    
+	// Adjust the accumulated amount by lum factor
+	float lum = dot(accum, LUMINENCE_FACTOR);
+	// take average of 4 samples
+	lum *= 0.25;
+	gl_FragColor = vec4(lum, lum, lum, 1.0);
+
+}
Index: code/branches/skybox/Media/materials/programs/hdr_downscale3x3.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_downscale3x3.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_downscale3x3.glsl	(revision 390)
@@ -0,0 +1,26 @@
+uniform sampler2D inRTT;
+uniform vec2 texelSize;
+
+varying vec2 uv;
+
+void main(void)
+{
+    vec4 accum = vec4(0.0, 0.0, 0.0, 0.0);
+
+    // Get colour from source
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  1.0));
+    
+	// take average of 9 samples
+	accum *= 0.1111111111111111;
+
+	gl_FragColor = accum;
+
+}
Index: code/branches/skybox/Media/materials/programs/hdr_downscale3x3brightpass.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_downscale3x3brightpass.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_downscale3x3brightpass.glsl	(revision 390)
@@ -0,0 +1,37 @@
+uniform sampler2D inRTT;
+uniform sampler2D inLum;
+uniform vec2 texelSize;
+
+varying vec2 uv;
+const vec4 BRIGHT_LIMITER = vec4(0.6, 0.6, 0.6, 0.0);
+
+// declare external function
+vec4 toneMap(in vec4 inColour, in float lum);
+
+void main(void)
+{
+    vec4 accum = vec4(0.0, 0.0, 0.0, 0.0);
+
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, -1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  0.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  1.0));
+    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  1.0));
+    
+	// take average of 9 samples
+	accum *= 0.1111111111111111;
+
+    // Reduce bright and clamp
+    accum = max(vec4(0.0, 0.0, 0.0, 1.0), accum - BRIGHT_LIMITER);
+
+	// Sample the luminence texture
+	vec4 lum = texture2D(inLum, vec2(0.5, 0.5));
+	
+	// Tone map result
+	gl_FragColor = toneMap(accum, lum.r);
+
+}
Index: code/branches/skybox/Media/materials/programs/hdr_finalToneMapping.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_finalToneMapping.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_finalToneMapping.glsl	(revision 390)
@@ -0,0 +1,28 @@
+uniform sampler2D inRTT;
+uniform sampler2D inBloom;
+uniform sampler2D inLum;
+
+varying vec2 uv;
+
+// declare external function
+vec4 toneMap(in vec4 inColour, in float lum);
+
+void main(void)
+{
+	// Get main scene colour
+    vec4 sceneCol = texture2D(inRTT, uv);
+
+	// Get luminence value
+	vec4 lum = texture2D(inLum, vec2(0.5, 0.5));
+
+	// tone map this
+	vec4 toneMappedSceneCol = toneMap(sceneCol, lum.r);
+	
+	// Get bloom colour
+    vec4 bloom = texture2D(inBloom, uv);
+
+	// Add scene & bloom
+	gl_FragColor = vec4(toneMappedSceneCol.rgb + bloom.rgb, 1.0);
+    
+}
+
Index: code/branches/skybox/Media/materials/programs/hdr_tonemap_util.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/hdr_tonemap_util.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/hdr_tonemap_util.glsl	(revision 390)
@@ -0,0 +1,29 @@
+const float MIDDLE_GREY = 0.72;
+const float FUDGE = 0.001;
+const float L_WHITE = 1.5;
+
+/** Tone mapping function 
+@note Only affects rgb, not a
+@param inColour The HDR colour
+@param lum The scene lumninence 
+@returns Tone mapped colour
+*/
+vec4 toneMap(in vec4 inColour, in float lum)
+{
+	// From Reinhard et al
+	// "Photographic Tone Reproduction for Digital Images"
+	
+	// Initial luminence scaling (equation 2)
+    inColour.rgb *= MIDDLE_GREY / (FUDGE + lum);
+
+	// Control white out (equation 4 nom)
+    inColour.rgb *= (1.0 + inColour.rgb / L_WHITE);
+
+	// Final mapping (equation 4 denom)
+	inColour.rgb /= (1.0 + inColour.rgb);
+	
+	return inColour;
+
+}
+
+
Index: code/branches/skybox/Media/materials/programs/instancing.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/instancing.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/instancing.cg	(revision 390)
@@ -0,0 +1,125 @@
+
+
+void instancing_vp(uniform float3x4   worldMatrix3x4Array[80], float4 position : POSITION,
+						float3 normal : NORMAL,
+						float2 uv : TEXCOORD0,
+						float index : TEXCOORD1,
+						uniform float4x4 viewProjectionMatrix,
+						uniform float4 lightPos,
+						uniform float4 ambient,
+						uniform float4 lightDiffuseColour,
+						out float4 oPosition : POSITION,
+						out float2 oUv : TEXCOORD0,
+						out float4 Color : COLOR )
+{
+	// transform by indexed matrix
+	float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0);
+	
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, transformedPos);
+	oUv = uv;
+
+	float3 norm = mul((float3x3)worldMatrix3x4Array[index], normal);
+	
+	float3 lightDir = 	normalize(
+		lightPos.xyz -  (transformedPos.xyz * lightPos.w));
+
+	Color = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour;
+	
+	
+}
+
+/*
+  Instancing shadow-caster pass
+*/
+void instancingCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float index     : TEXCOORD1,
+
+	out float4 oPosition : POSITION,
+	out float4 colour    : COLOR,
+	// Support up to 80 bones of float3x4
+	uniform float3x4   worldMatrix3x4Array[80],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0);
+
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, transformedPos);
+	
+	colour = ambient;
+	
+}
+void crowd_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float2 uv       : TEXCOORD0,
+	float4  blendIdx : BLENDINDICES,
+	float4	blendWgt : BLENDWEIGHT,
+	float   index : TEXCOORD1,
+
+	out float4 oPosition : POSITION,
+	out float2 oUv       : TEXCOORD0,
+	out float4 colour           : COLOR,
+	// Support up to 20 bones of float3x4
+	// vs_2_0 only supports 256 params so more than this is not feasible
+	uniform float4x4 viewProjectionMatrix,
+	uniform float numBones,
+	uniform float3x4   worldMatrix3x4Array[80],
+	uniform float4 lightDiffuseColour,
+	uniform float4 ambient,
+	uniform float4 lightPos)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(0,0,0,0);
+	int i;
+	for (i = 0; i < 4; ++i)
+	{
+		blendPos += float4(mul(worldMatrix3x4Array[index*numBones+blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
+	}
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	oUv = uv;
+	float3 norm = float3(0,0,0);
+	for (i = 0; i < 4; ++i)
+	{
+		norm += mul((float3x3)worldMatrix3x4Array[index*numBones+blendIdx[i]], normal)* blendWgt[i];
+	}
+	float3 lightDir = 	normalize(
+		lightPos.xyz -  (blendPos.xyz * lightPos.w));
+
+	colour = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour;
+
+	
+}
+
+/*
+  Single-weight-per-vertex hardware skinning, shadow-caster pass
+*/
+void crowdCaster_vp(
+	float4 position : POSITION,
+	float3 normal   : NORMAL,
+	float  blendIdx : BLENDINDICES,
+	float index     : TEXCOORD1,
+
+	out float4 oPosition : POSITION,
+	out float4 colour    : COLOR,
+	// Support up to 24 bones of float3x4
+	// vs_1_1 only supports 96 params so more than this is not feasible
+	uniform float3x4   worldMatrix3x4Array[80],
+	uniform float4x4 viewProjectionMatrix,
+	uniform float numBones,
+	uniform float4   ambient)
+{
+	// transform by indexed matrix
+	float4 blendPos = float4(mul(worldMatrix3x4Array[index*numBones+blendIdx], position).xyz, 1.0);
+
+	// view / projection
+	oPosition = mul(viewProjectionMatrix, blendPos);
+	
+	colour = ambient;
+	
+}	
Index: code/branches/skybox/Media/materials/programs/instancingVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/instancingVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/instancingVp.glsl	(revision 390)
@@ -0,0 +1,39 @@
+uniform vec4 worldMatrix3x4Array[240];
+uniform mat4 viewProjectionMatrix;
+uniform vec4 lightPos;
+uniform vec4 ambient;
+uniform vec4 lightDiffuseColour;
+
+void main()
+{
+
+	// transform by indexed matrix
+	// perform matrix multiplication manually since no 3x4 matrices
+	vec3 transformedPos;
+	vec3 transformedNorm;
+	int instanceOffset = int(gl_MultiTexCoord1.x) * 3;
+	for (int row = 0; row < 3; ++row)
+	{
+		vec4 matrixRow = worldMatrix3x4Array[instanceOffset + row];
+		transformedPos[row] = dot(matrixRow, gl_Vertex);
+#if SHADOW_CASTER
+#else
+		transformedNorm[row] = dot(matrixRow.xyz, gl_Normal);
+#endif
+		
+	}
+	
+	// view / projection
+	gl_Position = viewProjectionMatrix * vec4(transformedPos,1);
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+    gl_FrontSecondaryColor = vec4(0);
+	
+#if SHADOW_CASTER
+	gl_FrontColor = ambient;
+#else
+	vec3 lightDir = normalize(
+		lightPos.xyz -  (transformedPos.xyz * lightPos.w));
+	gl_FrontColor = ambient + clamp(dot(lightDir, transformedNorm),0.0,1.0) * lightDiffuseColour;
+#endif
+	
+}
Index: code/branches/skybox/Media/materials/programs/oceanGLSL.frag
===================================================================
--- code/branches/skybox/Media/materials/programs/oceanGLSL.frag	(revision 390)
+++ code/branches/skybox/Media/materials/programs/oceanGLSL.frag	(revision 390)
@@ -0,0 +1,45 @@
+// oceanGLSL.frag
+// fragment program for Ocean water simulation
+// 05 Aug 2005
+// adapted for Ogre by nfz
+// converted from HLSL to GLSL
+// original shader source from Render Monkey 1.6 Reflections Refractions.rfx
+
+// 06 Aug 2005: moved uvw calculation from fragment program into vertex program 
+
+uniform float fadeBias;
+uniform float fadeExp;
+uniform vec4 waterColor;
+uniform sampler3D Noise;
+uniform samplerCube skyBox;
+
+varying vec3 uvw;
+varying vec3 normal;
+varying vec3 vVec;
+
+void main(void)
+{
+   vec3 noisy = texture3D(Noise, uvw).xyz;
+   
+   // convert to signed noise
+   vec3 bump = 2.0 * noisy - 1.0;
+   bump.xz *= 0.15;
+   // Make sure the normal always points upwards
+   // note that Ogres y axis is vertical (RM Z axis is vertical)
+   bump.y = 0.8 * abs(bump.y) + 0.2;
+   // Offset the surface normal with the bump
+   bump = normalize(normal + bump);
+
+   // Find the reflection vector
+   vec3 normView = normalize(vVec);
+   vec3 reflVec = reflect(normView, bump);
+   // Ogre has z flipped for cubemaps
+   reflVec.z = -reflVec.z;
+   vec4 refl = textureCube(skyBox, reflVec);
+
+   // set up for fresnel calc
+   float lrp = 1.0 - dot(-normView, bump);
+   
+   // Interpolate between the water color and reflection for fresnel effect
+   gl_FragColor = mix(waterColor, refl, clamp(fadeBias + pow(lrp, fadeExp), 0.0, 1.0) );
+}
Index: code/branches/skybox/Media/materials/programs/oceanGLSL.vert
===================================================================
--- code/branches/skybox/Media/materials/programs/oceanGLSL.vert	(revision 390)
+++ code/branches/skybox/Media/materials/programs/oceanGLSL.vert	(revision 390)
@@ -0,0 +1,32 @@
+// oceanGLSL.vert
+// vertex program for Ocean water simulation
+// 05 Aug 2005
+// adapted for Ogre by nfz
+// converted from HLSL to GLSL
+// original shader source from Render Monkey 1.6 Reflections Refractions.rfx
+
+// 06 Aug 2005: moved uvw calculation from fragment program into vertex program 
+
+uniform vec3 scale;
+uniform vec3 eyePosition;
+uniform vec2 waveSpeed;
+uniform float noiseSpeed;
+uniform float time_0_X;
+
+varying vec3 uvw;
+varying vec3 normal;
+varying vec3 vVec;
+
+void main(void)
+{
+   gl_Position = ftransform();
+   
+   //  the view vector needs to be in vertex space
+   vVec = gl_Vertex.xyz - eyePosition;
+   normal = gl_Normal;
+   // uvw is the calculated uvw coordinates based on vertex position
+   uvw = gl_Vertex.xyz * scale.xyz;
+   uvw.xz += waveSpeed * time_0_X;
+   uvw.y += uvw.z + noiseSpeed * time_0_X;
+   
+}
Index: code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.frag
===================================================================
--- code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.frag	(revision 390)
+++ code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.frag	(revision 390)
@@ -0,0 +1,44 @@
+// oceanHLSL_Cg.frag
+// fragment program for Ocean water simulation
+// 04 Aug 2005
+// adapted for Ogre by nfz
+// original shader source from Render Monkey 1.6 Reflections Refractions.rfx
+// can be used in both Cg and HLSL compilers
+
+// 06 Aug 2005: moved uvw calculation from fragment program into vertex program 
+
+float4 main(float3 uvw: TEXCOORD0, float3 normal: TEXCOORD1, float3 vVec: TEXCOORD2,
+	uniform float fadeBias,
+	uniform float fadeExp,
+	uniform float4 waterColor,
+	uniform sampler Noise,
+	uniform sampler skyBox
+
+) : COLOR
+{
+
+   float3 noisy = tex3D(Noise, uvw).xyz;
+
+   // convert to Signed noise 
+   float3 bump = 2 * noisy - 1;
+   bump.xz *= 0.15;
+   // Make sure the normal always points upwards
+   // note that Ogres y axis is vertical (RM Z axis is vertical)
+   bump.y = 0.8 * abs(bump.y) + 0.2;
+   // Offset the surface normal with the bump
+   bump = normalize(normal + bump);
+
+   // Find the reflection vector
+   float3 normView = normalize(vVec);
+   float3 reflVec = reflect(normView, bump);
+   // Ogre has z flipped for cubemaps
+   reflVec.z = -reflVec.z;
+   float4 refl = texCUBE(skyBox, reflVec);
+
+   // set up for fresnel calc
+   float lrp = 1 - dot(-normView, bump);
+   
+   // Interpolate between the water color and reflection for fresnel effect
+   return lerp(waterColor, refl, saturate(fadeBias + pow(lrp, fadeExp)));
+
+}
Index: code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.vert
===================================================================
--- code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.vert	(revision 390)
+++ code/branches/skybox/Media/materials/programs/oceanHLSL_Cg.vert	(revision 390)
@@ -0,0 +1,41 @@
+// oceanHLSL_Cg.vert
+// vertex program for Ocean water simulation
+// 04 Aug 2005
+// adapted for Ogre by nfz
+// original shader source from Render Monkey 1.6 Reflections Refractions.rfx
+// can be used in both Cg and HLSL compilers
+
+// 06 Aug 2005: moved uvw calculation from fragment program into vertex program 
+
+struct VS_OUTPUT {
+   float4 Pos:    POSITION;
+   float3 uvw:    TEXCOORD0;
+   float3 normal: TEXCOORD1;
+   float3 vVec:   TEXCOORD2;
+};
+
+VS_OUTPUT main(float4 Pos: POSITION, float3 normal: NORMAL,
+	uniform float4x4 worldViewProj_matrix,
+	uniform float3 scale,
+	uniform float2 waveSpeed,
+	uniform float noiseSpeed,
+	uniform float time_0_X,
+	uniform float3 eyePosition
+
+)
+{
+   VS_OUTPUT Out;
+
+   Out.Pos = mul(worldViewProj_matrix, Pos);
+   
+   // uvw is the calculated uvw coordinates based on vertex position
+   Out.uvw = Pos.xyz * scale;
+   Out.uvw.xz += waveSpeed * time_0_X;
+   Out.uvw.y += Out.uvw.z + noiseSpeed * time_0_X;
+   
+   //  the view vector needs to be in vertex space
+   Out.vVec = Pos.xyz - eyePosition;
+   Out.normal = normal;
+
+   return Out;
+}
Index: code/branches/skybox/Media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl	(revision 390)
@@ -0,0 +1,40 @@
+// Example GLSL program for skinning with two bone weights per vertex
+
+attribute vec4 blendIndices;
+attribute vec4 blendWeights;
+
+// 3x4 matrix, passed as vec4's for compatibility with GL 2.0
+// GL 2.0 supports 3x4 matrices
+// Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing
+uniform vec4 worldMatrix3x4Array[72];
+uniform mat4 viewProjectionMatrix;
+uniform vec4 ambient;
+
+void main()
+{
+	vec3 blendPos = vec3(0,0,0);
+
+	for (int bone = 0; bone < 2; ++bone)
+	{
+		// perform matrix multiplication manually since no 3x4 matrices
+        // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first
+	    int idx = int(blendIndices[bone]) * 3;
+        // ATI GLSL compiler can't handle unrolling the loop so do it manually
+        // ATI GLSL has better performance when mat4 is used rather than using individual dot product
+        // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign
+		mat4 worldMatrix;
+		worldMatrix[0] = worldMatrix3x4Array[idx];
+		worldMatrix[1] = worldMatrix3x4Array[idx + 1];
+		worldMatrix[2] = worldMatrix3x4Array[idx + 2];
+		worldMatrix[3] = vec4(0);
+		// now weight this into final 
+		blendPos += (gl_Vertex * worldMatrix).xyz * blendWeights[bone];
+	}
+
+	// apply view / projection to position
+	gl_Position = viewProjectionMatrix * vec4(blendPos, 1);
+	
+	gl_FrontSecondaryColor = vec4(0,0,0,0);
+	gl_FrontColor = ambient;
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Index: code/branches/skybox/Media/materials/programs/skinningTwoWeightsVp.glsl
===================================================================
--- code/branches/skybox/Media/materials/programs/skinningTwoWeightsVp.glsl	(revision 390)
+++ code/branches/skybox/Media/materials/programs/skinningTwoWeightsVp.glsl	(revision 390)
@@ -0,0 +1,57 @@
+// Example GLSL program for skinning with two bone weights per vertex
+
+attribute vec4 blendIndices;
+attribute vec4 blendWeights;
+
+// 3x4 matrix, passed as vec4's for compatibility with GL 2.0
+// GL 2.0 supports 3x4 matrices
+// Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing
+uniform vec4 worldMatrix3x4Array[72];
+uniform mat4 viewProjectionMatrix;
+uniform vec4 lightPos[2];
+uniform vec4 lightDiffuseColour[2];
+
+void main()
+{
+	vec3 blendPos = vec3(0,0,0);
+	vec3 blendNorm = vec3(0,0,0);
+	
+	for (int bone = 0; bone < 2; ++bone)
+	{
+		// perform matrix multiplication manually since no 3x4 matrices
+        // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first
+	    int idx = int(blendIndices[bone]) * 3;
+        // ATI GLSL compiler can't handle unrolling the loop so do it manually
+        // ATI GLSL has better performance when mat4 is used rather than using individual dot product
+        // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign
+		mat4 worldMatrix;
+		worldMatrix[0] = worldMatrix3x4Array[idx];
+		worldMatrix[1] = worldMatrix3x4Array[idx + 1];
+		worldMatrix[2] = worldMatrix3x4Array[idx + 2];
+		worldMatrix[3] = vec4(0);
+		// now weight this into final 
+	    float weight = blendWeights[bone];
+		blendPos += (gl_Vertex * worldMatrix).xyz * weight;
+		
+		mat3 worldRotMatrix = mat3(worldMatrix[0].xyz, worldMatrix[1].xyz, worldMatrix[2].xyz);
+		blendNorm += (gl_Normal * worldRotMatrix) * weight;
+
+	}
+
+	// apply view / projection to position
+	gl_Position = viewProjectionMatrix * vec4(blendPos, 1);
+
+	// simple vertex lighting model
+	vec3 lightDir0 = normalize(
+		lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
+	vec3 lightDir1 = normalize(
+		lightPos[1].xyz -  (blendPos.xyz * lightPos[1].w));
+		
+	gl_FrontSecondaryColor = vec4(0);
+	gl_FrontColor = vec4(0.5, 0.5, 0.5, 1.0) 
+		+ clamp(dot(lightDir0, blendNorm), 0.0, 1.0) * lightDiffuseColour[0]
+		+ clamp(dot(lightDir1, blendNorm), 0.0, 1.0) * lightDiffuseColour[1];
+
+	gl_TexCoord[0] = gl_MultiTexCoord0;
+	
+}
Index: code/branches/skybox/Media/materials/programs/varianceshadowcasterfp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/varianceshadowcasterfp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/varianceshadowcasterfp.cg	(revision 390)
@@ -0,0 +1,65 @@
+/////////////////////////////////////////////////////////////////////////////////
+//
+// shadowcasterfp.cg
+//
+// Hamilton Chong
+// (c) 2006
+//
+// This is an example fragment shader for shadow caster objects.  
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+
+// Define outputs from vertex shader.
+struct VertexOut
+{
+  float4 position   : POSITION;     // can't rely on access to this
+  float4 pos  	    : TEXCOORD0;    // position of fragment (in homogeneous coordinates)
+  float4 normal     : TEXCOORD1;    // un-normalized normal in object space
+  float4 modelPos   : TEXCOORD2;    // coordinates of model in object space at this point
+};
+
+struct FragmentOut
+{
+    float4 color  : COLOR0;
+};
+
+FragmentOut main( VertexOut        In,                     // fragment to process
+                  uniform float    uDepthOffset,           // offset amount (constant in eye space)
+                  uniform float4x4 uProjection             // projection matrix
+              )
+{
+    FragmentOut Out;
+
+    // compute the "normalized device coordinates" (no viewport applied yet)
+    float4 postproj = In.pos / In.pos.w;
+
+    // get the normalized normal of the geometry seen at this point
+    float4 normal = normalize(In.normal);
+
+
+    // -- Computing Depth Bias Quantities -----------------------------
+
+    // We now compute the change in z that would signify a push in the z direction
+    // by 1 unit in eye space.  Note that eye space z is related in a nonlinear way to
+    // screen space z, so this is not just a constant.  
+    // ddepth below is how much screen space z at this point would change for that push.
+    // NOTE: computation of ddepth likely differs from OpenGL's glPolygonOffset "unit"
+    //  computation, which is allowed to be vendor specific.
+    float4 dpwdz = mul(uProjection, float4(0.0, 0.0, 1.0, 0.0));
+    float4 dpdz = (dpwdz - (postproj * dpwdz.w)) / In.pos.w;
+    float  ddepth = abs(dpdz.z);
+
+    // -- End depth bias helper section --------------------------------   
+
+    // We now compute the depth of the fragment.  This is the actual depth value plus
+    // our depth bias.  The depth bias depends on how uncertain we are about the z value
+    // plus some constant push in the z direction.  The exact coefficients to use are
+    // up to you, but at least it should be somewhat intuitive now what the tradeoffs are.
+    float depthval = postproj.z /* + (0.5 * dzlen)*/ + (uDepthOffset * ddepth);
+    depthval = (0.5 * depthval) + 0.5; // put into [0,1] range instead of [-1,1] 
+
+    
+    Out.color = float4(depthval, depthval * depthval, depthval, 0.0);
+    return Out;
+}
Index: code/branches/skybox/Media/materials/programs/varianceshadowcastervp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/varianceshadowcastervp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/varianceshadowcastervp.cg	(revision 390)
@@ -0,0 +1,44 @@
+/////////////////////////////////////////////////////////////////////////////////
+//
+// shadowcastervp.cg
+//
+// Hamilton Chong
+// (c) 2006
+//
+// This is an example vertex shader for shadow caster objects.  
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+
+// Define inputs from application.
+struct VertexIn
+{
+  float4 position : POSITION;       // vertex position in object space
+  float4 normal   : NORMAL;         // vertex normal in object space
+};
+
+// Define outputs from vertex shader.
+struct VertexOut
+{
+  float4 position   : POSITION;     // post projection position coordinates
+  float4 pos  	    : TEXCOORD0;    // ditto. Not all hardware allows access values bound to POSITION in fp.
+  float4 normal     : TEXCOORD1;    // normal in object space (to be interpolated)
+  float4 modelPos   : TEXCOORD2;    // position in object space (to be interpolated) 
+};
+
+VertexOut main( VertexIn         In,                   // vertex to process
+                uniform float4x4 uModelViewProjection  // model-view-projection matrix
+              )
+{
+    VertexOut Out;   // output data
+    
+    // Transform vertex position into post projective (homogenous screen) space.
+    Out.position = mul(uModelViewProjection, In.position);
+    Out.pos      = mul(uModelViewProjection, In.position);
+
+    // copy over data to interpolate using perspective correct interpolation
+    Out.normal = float4(In.normal.x, In.normal.y, In.normal.z, 0.0);
+    Out.modelPos = In.position;
+
+    return Out;
+}
Index: code/branches/skybox/Media/materials/programs/varianceshadowreceiverfp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/varianceshadowreceiverfp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/varianceshadowreceiverfp.cg	(revision 390)
@@ -0,0 +1,107 @@
+/////////////////////////////////////////////////////////////////////////////////
+//
+// shadowreceiverfp.cg
+//
+// Hamilton Chong
+// (c) 2006
+//
+// This is an example fragment shader for shadow receiver objects.  
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+
+sampler2D ShadowMap : TEXUNIT0;
+
+// Define outputs from vertex shader.
+struct Vertex
+{
+  float4 position       : POSITION;     // fragment position in post projective space
+  float4 shadowCoord    : TEXCOORD0;    // fragment position in shadow map coordinates
+  float  diffuse        : TEXCOORD1;    // diffuse shading value
+};
+
+struct Fragment
+{
+    float4 color  : COLOR0;
+};
+
+Fragment main(Vertex        In, 
+              uniform float uSTexWidth,
+              uniform float uSTexHeight)
+{
+    Fragment Out;
+
+    // compute the shadow coordinates for texture lookup
+    // NOTE: texture_viewproj_matrix maps z into [0,1] range, not [-1,1], so
+    //  have to make sure shadow caster stores depth values with same convention.
+    float4 scoord = In.shadowCoord / In.shadowCoord.w;
+
+
+    // -- Bilinear Filtering of Sample -------------------------------------------- 
+
+    // One could use scoord.xy to look up the shadow map for depth testing, but
+    // we'll be implementing a simple "percentage closest filtering" algorithm instead.
+    // This mimics the behavior of turning on bilinear filtering on NVIDIA hardware
+    // when also performing shadow comparisons.  This causes bilinear filtering of
+    // depth tests.  Note that this is NOT the same as bilinear filtering the depth
+    // values and then doing the depth comparison.  The two operations are not 
+    // commutative.  PCF is explicitly about filtering the test values since
+    // testing filtered z values is often meaningless.  
+
+    // Real percentage closest filtering should sample from the entire footprint
+    // on the shadow map, not just seek the closest four sample points.  Such 
+    // an improvement is for future work.
+
+    
+    // NOTE: Assuming OpenGL convention for texture lookups with integers in centers.
+    //  DX convention is to have integers mark sample corners
+    float2 tcoord;
+    tcoord.x = (scoord.x * uSTexWidth) - 0.5;
+    tcoord.y = (scoord.y * uSTexHeight) - 0.5;
+    float x0 = floor(tcoord.x);
+    float x1 = ceil(tcoord.x);
+    float fracx = frac(tcoord.x);
+    float y0 = floor(tcoord.y);
+    float y1 = ceil(tcoord.y);
+    float fracy = frac(tcoord.y);
+    
+    // sample coordinates in [0,1]^2 domain
+    float2 t00, t01, t10, t11;
+    float invWidth  = 1.0 / uSTexWidth;
+    float invHeight = 1.0 / uSTexHeight;
+    t00 = float2((x0+0.5) * invWidth, (y0+0.5) * invHeight);
+    t10 = float2((x1+0.5) * invWidth, (y0+0.5) * invHeight);
+    t01 = float2((x0+0.5) * invWidth, (y1+0.5) * invHeight);
+    t11 = float2((x1+0.5) * invWidth, (y1+0.5) * invHeight);
+    
+    // grab the samples
+    float2 z00 = tex2D(ShadowMap, t00).xy;
+    float2 z01 = tex2D(ShadowMap, t01).xy;
+    float2 z10 = tex2D(ShadowMap, t10).xy;
+    float2 z11 = tex2D(ShadowMap, t11).xy;
+
+    // bilinear filter the sample data
+    float2 d0 = ((1.0 - fracx) * z00) + (fracx * z10);
+    float2 d1 = ((1.0 - fracx) * z01) + (fracx * z11);
+    float2 datum = ((1.0 - fracy) * d0) + (fracy * d1);
+
+    // -- Variance Shadow Mapping ---------------------------------------------------
+
+    float zVariance = datum.y - (datum.x * datum.x);
+    float zDeviation = scoord.z - datum.x;
+    zDeviation = (zDeviation < 0.0) ? 0.0 : zDeviation;
+    float visibility = zVariance / (zVariance + (zDeviation * zDeviation));
+    float ztest = (scoord.z < datum.x) ? 1.0:0.0;  // filtering depth ok, because used only for small variance
+    visibility = (zVariance > 0.0) ? visibility : ztest; // if variance too small, we get garbage
+    //0.0000001
+
+    // determine that all geometry within pixel border of shadow map (and outside) is lit
+    float filterBorder = max(invWidth, invHeight);
+    visibility = (all(abs(scoord.xy-0.5)<=0.5-filterBorder)) ? visibility : 1.0;
+
+    // ------------------------------------------------------------------------------
+
+    visibility *= In.diffuse;
+    Out.color = float4(visibility, visibility, visibility, 0.0);
+    return Out;
+}
Index: code/branches/skybox/Media/materials/programs/varianceshadowreceivervp.cg
===================================================================
--- code/branches/skybox/Media/materials/programs/varianceshadowreceivervp.cg	(revision 390)
+++ code/branches/skybox/Media/materials/programs/varianceshadowreceivervp.cg	(revision 390)
@@ -0,0 +1,47 @@
+/////////////////////////////////////////////////////////////////////////////////
+//
+// shadowreceivervp.cg
+//
+// Hamilton Chong
+// (c) 2006
+//
+// This is an example vertex shader for shadow receiver objects.  
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+// Define inputs from application.
+struct VertexIn
+{
+  float4 position       : POSITION;     // vertex position in object space
+  float4 normal         : NORMAL;       // vertex normal in object space
+};
+
+// Define outputs from vertex shader.
+struct Vertex
+{
+  float4 position       : POSITION;     // vertex position in post projective space
+  float4 shadowCoord    : TEXCOORD0;    // vertex position in shadow map coordinates
+  float  diffuse        : TEXCOORD1;    // diffuse shading value
+};
+
+Vertex main(VertexIn         In,
+            uniform float4x4 uModelViewProjection,   // model-view-projection matrix
+            uniform float4   uLightPosition,         // light position in object space
+            uniform float4x4 uModel,                 // model matrix
+            uniform float4x4 uTextureViewProjection  // shadow map's view projection matrix
+            )
+{
+    Vertex Out;
+
+    // compute diffuse shading
+    float3 lightDirection = normalize(uLightPosition.xyz - In.position.xyz);
+    Out.diffuse = dot(In.normal.xyz, lightDirection);
+
+    // compute shadow map lookup coordinates
+    Out.shadowCoord = mul(uTextureViewProjection, mul(uModel, In.position));
+
+    // compute vertex's homogenous screen-space coordinates
+    Out.position = mul(uModelViewProjection, In.position);
+
+    return Out;
+}
Index: code/branches/skybox/Media/materials/scripts/BlackAndWhite.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/BlackAndWhite.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/BlackAndWhite.material	(revision 390)
@@ -0,0 +1,34 @@
+fragment_program Ogre/Compositor/B&W_FP cg
+{
+	source GrayScale.cg
+	entry_point GrayScale_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/BlackAndWhite
+{
+	technique
+	{
+
+		pass
+		{
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/B&W_FP
+			{
+			}
+
+			texture_unit
+			{
+				texture RT
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Bloom.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Bloom.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Bloom.material	(revision 390)
@@ -0,0 +1,178 @@
+//DirectX 9.0 HLSL Vertex Shader vs_1_1
+vertex_program Blur0_vs11 hlsl
+{
+	source Blur0_vs11.hlsl
+	target vs_1_1
+	entry_point main
+}
+
+//DirectX 9.0 HLSL Pixel Shader ps_2_0
+fragment_program Blur0_ps20 hlsl
+{
+	source Blur0_ps20.hlsl
+	target ps_2_0
+	entry_point main
+}
+
+//DirectX 9.0 HLSL Vertex Shader vs_1_1
+vertex_program Blur1_vs11 hlsl
+{
+	source Blur1_vs11.hlsl
+	target vs_1_1
+	entry_point main
+}
+
+//DirectX 9.0 HLSL Pixel Shader ps_2_0
+fragment_program Blur1_ps20 hlsl
+{
+	source Blur1_ps20.hlsl
+	target ps_2_0
+	entry_point main
+}
+
+vertex_program Blur0_vs_glsl glsl
+{
+	source Blur0_vs.glsl
+}
+vertex_program Blur1_vs_glsl glsl
+{
+	source Blur1_vs.glsl
+}
+fragment_program Blur_ps_glsl glsl
+{
+	source Blur_ps.glsl
+	default_params
+	{
+		param_named tex0 int 0
+	}
+}
+
+//Effect: Bloom
+material Ogre/Compositor/Blur0
+{
+	technique
+	{
+		//Rendering Pass: Blur0 (pass index: #1 )
+		pass
+		{
+			//State: D3DRS_CULLMODE, Value : D3DCULL_NONE
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			fragment_program_ref Blur0_ps20
+			{
+			}
+			vertex_program_ref Blur0_vs11
+			{
+			}
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+	technique
+	{
+		//Rendering Pass: Blur0 (pass index: #1 )
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			fragment_program_ref Blur_ps_glsl
+			{
+			}
+			vertex_program_ref Blur0_vs_glsl
+			{
+			}
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+}
+
+material Ogre/Compositor/Blur1
+{
+	technique
+	{
+
+		//Rendering Pass: Blur1 (pass index: #2 )
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			fragment_program_ref Blur1_ps20
+			{
+			}
+			vertex_program_ref Blur1_vs11
+			{
+			}
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+	technique
+	{
+
+		//Rendering Pass: Blur1 (pass index: #2 )
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			fragment_program_ref Blur_ps_glsl
+			{
+			}
+			vertex_program_ref Blur1_vs_glsl
+			{
+			}
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+}
+
+/// Overlay quad
+material Ogre/Compositor/BloomBlend
+{
+    technique
+    {
+        pass
+        {
+            lighting on
+            diffuse 0.0 0.0 0.0 0.6
+            specular 0.0 0.0 0.0 0.0
+            ambient 0.0 0.0 0.0
+            emissive 1.0 1.0 1.0
+            cull_hardware none
+            depth_check off
+            scene_blend alpha_blend
+
+            texture_unit
+            {
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+            }
+        }
+    }
+}
Index: code/branches/skybox/Media/materials/scripts/DOF.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/DOF.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/DOF.material	(revision 390)
@@ -0,0 +1,94 @@
+fragment_program DOF_Blur_ps cg
+{
+	source DOF_ps.cg
+	entry_point blur
+	profiles ps_2_0 arbfp1
+}
+
+fragment_program DOF_Blend_ps cg
+{
+	source DOF_ps.cg
+	entry_point blend
+	profiles ps_2_0 arbfp1
+}
+
+//Effect: Depth of Field
+material Ogre/Compositor/DOF_Blur0
+{
+	technique
+	{
+		//Rendering Pass: Blur0 (pass index: #1 )
+		pass
+		{
+			//State: D3DRS_CULLMODE, Value : D3DCULL_NONE
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			fragment_program_ref DOF_Blur_ps
+			{
+			    param_named sampleDistance float 0.1
+			}
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+			texture_unit
+			{
+			    // texture will get added at runtime
+                tex_coord_set 0
+				tex_address_mode wrap
+				filtering trilinear
+			}
+		}
+	}
+}
+
+// cheat here by copying from DOF_Blur0
+material Ogre/Compositor/DOF_Blur1 : Ogre/Compositor/DOF_Blur0
+{
+	technique
+	{
+		//Rendering Pass: Blur0 (pass index: #1 )
+		pass
+		{
+		    // use the same pixel shader as DOF_Blur0
+			fragment_program_ref
+			{
+			    // override value from copied DOF_Blur0 material
+			    param_named sampleDistance float 0.1
+			}
+		}
+	}
+}
+
+material Ogre/Compositor/DOF_Blend
+{
+    technique
+    {
+        pass
+        {
+			fragment_program_ref DOF_Blend_ps
+			{
+			    param_named focus float 0.66
+			    param_named range float 1.0
+			}
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+            texture_unit Blur0
+            {
+			    // texture will get added at runtime
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+            }
+            texture_unit Blur1
+            {
+			    // texture will get added at runtime
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+            }
+        }
+    }
+}
Index: code/branches/skybox/Media/materials/scripts/DepthShadowmap.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/DepthShadowmap.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/DepthShadowmap.material	(revision 390)
@@ -0,0 +1,595 @@
+
+// ***-- Begin HLSL section --**
+
+vertex_program Ogre/DepthShadowmap/CasterVP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point casterVP
+    target vs_2_0
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texelOffsets texel_offsets
+		//param_named_auto depthRange scene_depth_range
+    }
+}
+
+
+fragment_program Ogre/DepthShadowmap/CasterFP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point casterFP
+    target ps_2_0
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+    }
+}
+
+
+vertex_program Ogre/DepthShadowmap/ReceiverVP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point receiverVP
+    target vs_2_0
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto world world_matrix
+        param_named_auto worldIT inverse_transpose_world_matrix
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texViewProj texture_viewproj_matrix
+		param_named_auto lightPosition light_position 0
+		param_named_auto lightColour light_diffuse_colour 0
+		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
+    }
+}
+
+
+fragment_program Ogre/DepthShadowmap/ReceiverFP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point receiverFP
+	target ps_2_0
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0
+
+	default_params
+    {
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+
+fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point receiverFP
+	target ps_2_0
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1
+
+	default_params
+    {
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point normalMapShadowReceiverVp
+    target vs_2_0
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto world world_matrix
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texViewProj texture_viewproj_matrix
+		param_named_auto lightPosition light_position_object_space 0
+		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
+    }
+}
+
+fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point normalMapShadowReceiverFp
+	target ps_2_0
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0
+
+	default_params
+    {
+		param_named_auto lightColour light_diffuse_colour 0
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL hlsl
+{
+    source DepthShadowmap.hlsl
+    entry_point normalMapShadowReceiverFp
+	target ps_2_0
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1
+
+	default_params
+    {
+		param_named_auto lightColour light_diffuse_colour 0
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+
+
+
+// **-- End HLSL Section --**
+
+// **-- Begin GLSL Section --**
+vertex_program Ogre/DepthShadowmap/CasterVP_GLSL glsl
+{
+    source DepthShadowmapCasterVp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texelOffsets texel_offsets
+		//param_named_auto depthRange scene_depth_range
+    }
+}
+
+
+fragment_program Ogre/DepthShadowmap/CasterFP_GLSL glsl
+{
+    source DepthShadowmapCasterFp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+    }
+}
+
+
+vertex_program Ogre/DepthShadowmap/ReceiverVP_GLSL glsl
+{
+    source DepthShadowmapReceiverVp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto world world_matrix
+        param_named_auto worldIT inverse_transpose_world_matrix
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texViewProj texture_viewproj_matrix
+		param_named_auto lightPosition light_position 0
+		param_named_auto lightColour light_diffuse_colour 0
+		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
+    }
+}
+
+
+fragment_program Ogre/DepthShadowmap/ReceiverFP_GLSL glsl
+{
+    source DepthShadowmapReceiverFp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0
+
+	default_params
+    {
+		param_named shadowMap int 0
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+
+fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_GLSL glsl
+{
+    source DepthShadowmapReceiverFp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1
+
+	default_params
+    {
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+    }
+}
+vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL glsl
+{
+    source DepthShadowmapNormalMapReceiverVp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0
+
+    default_params
+    {
+        param_named_auto world world_matrix
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto texViewProj texture_viewproj_matrix
+		param_named_auto lightPosition light_position_object_space 0
+		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
+    }
+}
+
+fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL glsl
+{
+    source DepthShadowmapNormalMapReceiverFp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0
+
+	default_params
+    {
+		param_named_auto lightColour light_diffuse_colour 0
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+
+		param_named shadowMap int 0
+		param_named normalMap int 1
+    }
+}
+fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL glsl
+{
+    source DepthShadowmapNormalMapReceiverFp.glsl
+
+	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1
+
+	default_params
+    {
+		param_named_auto lightColour light_diffuse_colour 0
+        param_named inverseShadowmapSize float 0.0009765625
+		param_named fixedDepthBias float 0.0005
+		param_named gradientClamp float 0.0098
+		param_named gradientScaleBias float 0
+		//param_named shadowFuzzyWidth float 1
+
+		param_named shadowMap int 0
+		param_named normalMap int 1
+    }
+}
+
+// **-- End GLSL Section --**
+
+// **-- Begin Unified Section --**
+vertex_program Ogre/DepthShadowmap/CasterVP unified
+{
+	delegate Ogre/DepthShadowmap/CasterVP_GLSL
+	delegate Ogre/DepthShadowmap/CasterVP_HLSL
+}
+fragment_program Ogre/DepthShadowmap/CasterFP unified
+{
+	delegate Ogre/DepthShadowmap/CasterFP_GLSL
+	delegate Ogre/DepthShadowmap/CasterFP_HLSL
+}
+vertex_program Ogre/DepthShadowmap/ReceiverVP unified
+{
+	delegate Ogre/DepthShadowmap/ReceiverVP_GLSL
+	delegate Ogre/DepthShadowmap/ReceiverVP_HLSL
+}
+fragment_program Ogre/DepthShadowmap/ReceiverFP unified
+{
+	delegate Ogre/DepthShadowmap/ReceiverFP_GLSL
+	delegate Ogre/DepthShadowmap/ReceiverFP_HLSL
+}
+fragment_program Ogre/DepthShadowmap/ReceiverFPPCF unified
+{
+	delegate Ogre/DepthShadowmap/ReceiverFPPCF_GLSL
+	delegate Ogre/DepthShadowmap/ReceiverFPPCF_HLSL
+}
+vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP unified
+{
+	delegate Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL
+	delegate Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL
+}
+vertex_program Ogre/DepthShadowmap/NormalMapReceiverFP unified
+{
+	delegate Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL
+	delegate Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL
+}
+vertex_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF unified
+{
+	delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL
+	delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL
+}
+
+// **-- End Unified Section --**
+
+
+
+// Generic Shadow caster material (floating point shadowmap)
+material Ogre/DepthShadowmap/Caster/Float
+{
+	technique
+    {
+        pass 
+        {
+            vertex_program_ref Ogre/DepthShadowmap/CasterVP
+            {
+            }
+            fragment_program_ref Ogre/DepthShadowmap/CasterFP
+            {
+            }
+        }
+    }
+}
+
+// Generic Shadow receiver material (floating point shadowmap)
+material Ogre/DepthShadowmap/Receiver/Float
+{
+	technique
+    {
+        pass 
+        {
+            vertex_program_ref Ogre/DepthShadowmap/ReceiverVP
+            {
+            }
+            fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
+            {
+            }
+            texture_unit ShadowMap
+            {
+                tex_address_mode clamp
+                filtering none
+            }
+        }
+    }
+}
+
+
+// Specific receiver material for rockwall
+material Ogre/DepthShadowmap/Receiver/RockWall
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
+			{
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass lighting
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Ogre/DepthShadowmap/ReceiverVP
+			{
+			}
+			shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/ReceiverVP
+			{
+			}
+
+			// Fragment program
+			fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
+			{
+			}
+			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
+			{
+			}
+
+			// shadowmap texture will be bound by code
+
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
+			{
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+
+
+			texture_unit
+			{
+				texture rockwall.tga
+			}
+			
+		}
+	}
+
+
+}
+
+// Specific receiver material for Athene
+material Ogre/DepthShadowmap/Receiver/Athene
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
+			{
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass lighting
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Ogre/DepthShadowmap/NormalMapReceiverVP
+			{
+			}
+			shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/NormalMapReceiverVP
+			{
+			}
+
+			// Fragment program
+			fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP
+			{
+			}
+			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP
+			{
+			}
+
+			// shadowmap texture will be bound by code
+
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
+			{
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+
+
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+
+
+}
+
+
+
+// Specialisation to use PCF
+material Ogre/DepthShadowmap/Receiver/Float/PCF : Ogre/DepthShadowmap/Receiver/Float
+{
+	technique
+	{
+		pass
+		{
+			// override just receiver program 
+			fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF
+			{
+			}
+			
+		}
+	}
+}
+
+// Specialisation to use PCF
+material Ogre/DepthShadowmap/Receiver/RockWall/PCF : Ogre/DepthShadowmap/Receiver/RockWall
+{
+	technique
+	{
+		pass lighting
+		{
+			// override just receiver program 
+			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF
+			{
+			}
+			
+		}
+	}
+}
+// Specialisation to use PCF
+material Ogre/DepthShadowmap/Receiver/Athene/PCF : Ogre/DepthShadowmap/Receiver/Athene
+{
+	technique
+	{
+		pass lighting
+		{
+			// override just receiver program 
+			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFPPCF
+			{
+			}
+			
+		}
+	}
+}
+
+
Index: code/branches/skybox/Media/materials/scripts/Embossed.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Embossed.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Embossed.material	(revision 390)
@@ -0,0 +1,33 @@
+fragment_program Ogre/Compositor/Embossed_FP cg
+{
+	source GrayScale.cg
+	entry_point Embossed_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/Embossed
+{
+	technique
+	{
+
+		pass
+		{
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/Embossed_FP
+			{
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Example-DynTex.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Example-DynTex.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Example-DynTex.material	(revision 390)
@@ -0,0 +1,86 @@
+
+material Examples/DynaTest
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			depth_write off
+			scene_blend alpha_blend
+			lighting off
+		}
+	}
+}
+
+
+material Examples/DynaTest2
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.8 0.8 0.8
+			specular 0.7 0.7 0.7 40.0
+			ambient 0.5 0.5 0.5
+		}
+	}
+}
+
+material Examples/DynaTest3
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.2 0.8 0.8
+			specular 0.4 0.7 0.7 30.0
+			ambient 0.2 0.5 1.0
+			depth_write off
+			scene_blend alpha_blend
+		}
+	}
+}
+
+material Examples/DynaTest4
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.8 0.8 0.8
+			specular 0.7 0.7 0.4 20.0
+			ambient 1.0 0.5 0.2
+		}
+	}
+}
+
+material Examples/VTDarkStuff
+{
+	technique
+	{
+		pass
+		{
+			diffuse 0.0 0.0 0.0
+			ambient 0.1 0.1 0.15
+			cull_hardware none
+			lighting on
+		}
+		
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Example-Water.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Example-Water.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Example-Water.material	(revision 390)
@@ -0,0 +1,183 @@
+
+material Examples/Water0
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water1
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water2
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water3
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture Water02.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+				rotate_anim 0.03
+			}
+		}
+	}
+}
+material Examples/Water4
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water02.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water5
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water6
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/Water7
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/Water8
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Example.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Example.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Example.material	(revision 390)
@@ -0,0 +1,1044 @@
+
+material Examples/EnvMappedRustySteel
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+
+			texture_unit
+			{
+				texture spheremap.png
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				env_map spherical
+			}
+		}
+	}
+}
+material Examples/OgreLogo
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.8 0.8 0.8
+
+			texture_unit
+			{
+				texture ogrelogo.png
+			}
+		}
+	}
+}
+material Examples/DarkMaterial
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.1 0.1 0.1
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+			}
+		}
+	}
+}
+material Examples/SpaceSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture stevecube.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneSkyBox1
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cubemap_fr.jpg cubemap_bk.jpg cubemap_lf.jpg cubemap_rt.jpg cubemap_up.jpg cubemap_dn.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneCubeMap1
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubemap.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/SceneSkyBox2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cubescene_fr.jpg cubescene_bk.jpg cubescene_lf.jpg cubescene_rt.jpg cubescene_up.jpg cubescene_dn.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneCubeMap2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+
+material Examples/CloudyNoonSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cloudy_noon.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/StormySkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture stormy.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+
+fragment_program Examples/MorningSkyBoxHDRfp cg
+{
+	source hdr.cg
+	entry_point morningskybox_fp
+	profiles ps_2_0 arbfp1
+
+}
+material Examples/MorningSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture morning.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+
+	// HDR technique (fake)
+	technique
+	{
+		scheme HDR
+
+		pass
+		{
+			lighting off
+			depth_write off
+
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			fragment_program_ref Examples/MorningSkyBoxHDRfp
+			{
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+fragment_program Examples/MorningCubeMapHDRfp cg
+{
+	source hdr.cg
+	entry_point morningcubemap_fp
+	profiles ps_2_0 arbfp1
+
+}
+material Examples/MorningCubeMap
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+	// HDR technique (fake)
+	technique
+	{
+		scheme HDR
+
+		pass
+		{
+			lighting off
+
+			fragment_program_ref Examples/MorningCubeMapHDRfp
+			{
+			}
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+
+
+material Examples/EveningSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture evening.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/CloudySky
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				texture clouds.jpg
+				scroll_anim 0.15 0
+			}
+		}
+	}
+}
+material Examples/RustySteel
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+}
+material Examples/Chrome
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture Chrome.jpg
+				env_map spherical
+			}
+		}
+	}
+}
+material Examples/SpaceSkyPlane
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+			fog_override true none
+
+			texture_unit
+			{
+				texture spacesky.jpg
+			}
+		}
+	}
+}
+material Examples/TextureEffect1
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.75 0.75 0.75
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BumpyMetal.jpg
+				rotate_anim 0.2
+				wave_xform scale_x sine 1 0.1 0 5
+				wave_xform scale_y sine 0.5 0.2 0.5 3
+			}
+		}
+	}
+}
+material Examples/TextureEffect2
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture Water02.jpg
+				scroll_anim 0.5 0
+			}
+		}
+	}
+}
+material Examples/TextureEffect3
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.7 0.7 0.7
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim -0.25 0.1
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				scroll_anim -0.1 0.25
+			}
+		}
+	}
+}
+material Examples/TextureEffect4
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.3 0.3 0.3
+			scene_blend colour_blend
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water02.jpg
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/BumpyMetal
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.75 0.75 0.75
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BumpyMetal.jpg
+			}
+		}
+	}
+}
+material Examples/TransparentTest
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim 0.25 0
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				wave_xform scroll_y sine 0 0.1 0 0.5
+			}
+		}
+	}
+}
+material Examples/Flare
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture flare.png
+			}
+		}
+	}
+}
+material Examples/Flare2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture flaretrail.png
+			}
+		}
+	}
+}
+material Examples/FlarePointSprite
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			point_sprites on
+			point_size 2
+			point_size_attenuation on
+
+			texture_unit
+			{
+				texture flare.png
+			}
+		}
+	}
+}
+
+material Examples/Droplet
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture basic_droplet.png
+			}
+		}
+	}
+}
+material Examples/Hilite/Yellow
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture dkyellow.png
+			}
+		}
+	}
+}
+material Examples/Rocky
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2
+
+			texture_unit
+			{
+				texture egyptrockyfull.jpg
+			}
+		}
+	}
+}
+material Examples/10PointBlock
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture 10points.png
+			}
+		}
+	}
+}
+material Material__25
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture texmap2.jpg
+			}
+		}
+	}
+}
+material 2 - Default
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture MtlPlat2.jpg
+			}
+		}
+	}
+}
+material Material #8
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture BODY.jpg
+			}
+		}
+	}
+}
+material Material #3
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture HEAD4.jpg
+			}
+		}
+	}
+}
+material Material #9
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture LEGS.jpg
+			}
+		}
+	}
+}
+
+material Examples/Fish
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture steelhead.png
+			}
+		}
+	}
+}
+material Examples/Ninja
+{
+	technique
+	{
+		pass
+		{
+		
+			texture_unit
+			{
+				texture nskingr.jpg
+			}
+		}
+	}
+}
+
+material Examples/Robot
+{
+	// Hardware skinning techniique
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Ogre/HardwareSkinningOneWeight
+			{
+				param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto lightPos[0] light_position 0
+				param_named_auto lightPos[1] light_position 1
+				param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
+				param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
+				param_named_auto ambient ambient_light_colour
+			
+			}
+			// alternate shadow caster program
+			shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
+			{
+				param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			
+			}
+
+			texture_unit
+			{
+				texture r2skin.jpg
+			}
+		}
+	}
+
+	// Software blending technique
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture r2skin.jpg
+			}
+		}
+	}
+}
+
+material Examples/GrassFloor
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture grass_1024.jpg
+			}
+		}
+	}
+}
+
+vertex_program Examples/GrassWaverVp cg
+{
+	source Grass.cg
+	entry_point grass_vp
+	profiles vs_1_1 arbvp1
+}
+
+material Examples/GrassBlades
+{
+	// Vertex program waving grass
+    technique
+    {
+        pass
+        {
+			vertex_program_ref Examples/GrassWaverVp
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+				param_named_auto objSpaceLight light_position_object_space 0
+				param_named_auto lightColour light_diffuse_colour 0
+				param_named_auto offset custom 999
+			}
+			alpha_rejection greater 150 
+			scene_blend alpha_blend
+		    cull_hardware none
+            cull_software none
+            texture_unit
+            {
+                texture gras_02.png 
+            }
+        }
+    }
+
+	// Non-vertex program technique (no waving)
+	technique
+    {
+        pass
+        {
+			alpha_rejection greater 150 
+			scene_blend alpha_blend
+		    cull_hardware none
+            cull_software none
+            texture_unit
+            {
+                texture gras_02.png 
+            }
+        }
+    }
+}
+
+material Examples/Rockwall
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture rockwall.tga
+			}
+		}
+	}
+}
+
+material Examples/Aureola
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_write off
+			cull_hardware none
+
+			texture_unit
+			{
+				texture aureola.png PF_BYTE_LA
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+// Test hardware morph animation
+material Examples/HardwareMorphAnimation
+{
+	technique
+	{
+		pass
+		{
+			
+			vertex_program_ref Ogre/HardwareMorphAnimation
+			{
+				// all default
+			}
+
+			texture_unit
+			{
+				tex_coord_set 0
+				colour_op_ex source1 src_current src_current
+			}
+			// need to define these texture units otherwise GL won't use the uv sets			
+			texture_unit
+			{
+				tex_coord_set 1
+				// also need to set blending to ignore texture which is GL warning texture
+				colour_op_ex source1 src_current src_current
+			}
+			texture_unit
+			{
+				tex_coord_set 2
+				colour_op_ex source1 src_current src_current
+			}
+		
+		}
+	}
+}
+
+// Test hardware pose animation
+material Examples/HardwarePoseAnimation
+{
+	technique
+	{
+		pass
+		{
+			
+			vertex_program_ref Ogre/HardwarePoseAnimation
+			{
+				// all default
+			}
+			texture_unit
+			{
+				tex_coord_set 0
+				colour_op_ex source1 src_current src_current
+			}
+			// need to define these texture units otherwise GL won't use the uv sets			
+			texture_unit
+			{
+				tex_coord_set 1
+				// also need to set blending to ignore texture which is GL warning texture
+				colour_op_ex source1 src_current src_current
+			}
+			texture_unit
+			{
+				tex_coord_set 2
+				colour_op_ex source1 src_current src_current
+			}
+
+		
+		}
+	}
+}
+
+material RustyBarrel
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0.5 1.0
+			diffuse 1.0 1.0 1.0 1.0
+			specular 0.0 0.0 0.0 1.0 12.5
+			emissive 0.0 0.0 0.0 1.0
+			texture_unit
+			{
+				texture RustyBarrel.png
+				filtering trilinear
+			}
+		}
+	}
+}
+
+material WoodPallet
+{
+	receive_shadows on
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0.5 1.0
+			diffuse 1.0 1.0 1.0 1.0
+			specular 0.0 0.0 0.0 1.0 12.5
+
+			texture_unit
+			{
+				texture WoodPallet.png
+				filtering trilinear
+			}
+		}
+	}
+}
+
+material Examples/LightRibbonTrail
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture ribbonband.png 1d
+				tex_address_mode clamp
+				filtering none
+			}
+		}
+	}
+}
+
+material Examples/TudorHouse
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture fw12b.jpg
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material jaiqua
+{
+	// Hardware skinning techniique
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Ogre/HardwareSkinningTwoWeights
+			{
+			
+			}
+			// alternate shadow caster program
+			shadow_caster_vertex_program_ref Ogre/HardwareSkinningTwoWeightsShadowCaster
+			{
+				param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			
+			}
+
+			texture_unit
+			{
+				texture blue_jaiqua.jpg
+				tex_address_mode clamp
+			}
+		}
+	}
+
+	// Software blending technique
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture blue_jaiqua.jpg
+				tex_address_mode clamp
+			}
+		}
+	}
+	
+}
+
+
+material Examples/Plane/IntegratedShadows
+{
+	technique
+	{
+		pass
+		{
+			// Single-pass shadowing
+			texture_unit
+			{
+				texture MtlPlat2.jpg
+			}
+			texture_unit
+			{
+				// standard modulation blend
+				content_type shadow
+				tex_address_mode clamp
+			}
+		}
+	}
+	
+}
Index: code/branches/skybox/Media/materials/scripts/Examples-Advanced.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Examples-Advanced.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Examples-Advanced.material	(revision 390)
@@ -0,0 +1,1167 @@
+// -------------------------------
+// Cel Shading Section
+// -------------------------------
+vertex_program Ogre/CelShadingVP cg
+{
+	source Example_CelShading.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto lightPosition light_position_object_space 0
+		param_named_auto eyePosition camera_position_object_space
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named shininess float 10 
+	}
+}
+
+fragment_program Ogre/CelShadingFP cg
+{
+	source Example_CelShading.cg
+	entry_point main_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+
+material Examples/CelShading
+{
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Ogre/CelShadingVP
+			{
+				// map shininess from custom renderable param 1
+				param_named_auto shininess custom 1
+			}
+			fragment_program_ref Ogre/CelShadingFP
+			{
+				// map diffuse from custom renderable param 2
+				param_named_auto diffuse custom 2
+				// map specular from custom renderable param 2
+				param_named_auto specular custom 3
+			}
+			texture_unit
+			{
+				texture cel_shading_diffuse.png 1d
+				tex_address_mode clamp
+				filtering none
+			}
+			texture_unit
+			{
+				texture cel_shading_specular.png 1d
+				tex_address_mode clamp
+				filtering none
+				tex_coord_set 1
+			}
+			texture_unit
+			{
+				texture cel_shading_edge.png 1d
+				tex_address_mode clamp
+				filtering none
+				tex_coord_set 2
+			}
+		}
+	}
+	
+}
+
+
+
+//------------------------
+// Bump mapping section
+//------------------------
+
+// Bump map vertex program, support for this is required
+vertex_program Examples/BumpMapVP cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program Examples/BumpMapFP cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+// Bump map vertex program shadow receiver
+vertex_program Examples/BumpMapVPShadowRcv cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_shadowreceiver_vp
+	profiles vs_1_1 arbvp1
+}
+// Bump map fragment program shadow receiver, support for this is optional
+fragment_program Examples/BumpMapFPShadowRcv cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_shadowreceiver_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+
+// Bump map with specular vertex program, support for this is required
+vertex_program Examples/BumpMapVPSpecular cg
+{
+	source Example_BumpMapping.cg
+	entry_point specular_vp
+	profiles vs_1_1 arbvp1
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program Examples/BumpMapFPSpecular cg
+{
+	source Example_BumpMapping.cg
+	entry_point specular_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+// Single light material, less passes (one pass on a 4-unit card)
+material Examples/BumpMapping/SingleLight
+{
+	// Preferred technique, uses vertex and fragment programs
+	// to support a single coloured light
+	technique
+	{
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Decal
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+	// Fallback technique, uses vertex program but only fixed-function
+	// fragment shading, which does not support coloured light
+	technique
+	{
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+			// Decal
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+}
+
+// Any number of lights, diffuse
+material Examples/BumpMapping/MultiLight
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+
+	}
+}
+
+// Any number of lights, diffuse and specular
+material Examples/BumpMapping/MultiLightSpecular
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVPSpecular
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFPSpecular
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+				param_named_auto lightSpecular light_specular_colour 0
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Normalisation cube map #2
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 2
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use, NB does not support specular colour
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+
+	}
+}
+
+//---------------------------
+// Projective texture section
+//---------------------------
+
+
+vertex_program Examples/TexProjectionVP cg
+{
+	source Example_Projection.cg
+	entry_point generalPurposeProjection_vp
+	profiles vs_1_1 arbvp1
+}
+
+fragment_program Examples/TexProjectionFP cg
+{
+	source Example_Projection.cg
+	entry_point generalPurposeProjection_fp
+	// sorry, ps_1_1 can't do this, fp20 can though
+	profiles ps_2_0 arbfp1 fp20
+}
+
+material Examples/GeneralTexProjection
+{
+	technique
+	{
+		pass 
+		{
+			
+			vertex_program_ref Examples/TexProjectionVP
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto worldMatrix world_matrix
+				// You'll need to update the tex projection, I suggest using
+				// the Frustum class
+				//param_named_auto texWorldViewProj worldviewproj_matrix
+			}
+			fragment_program_ref Examples/TexProjectionFP
+			{
+				// no params
+			}
+			texture_unit
+			{
+				// Project the OGRE logo
+				texture ogrelogo.png
+				tex_address_mode clamp
+			}
+		}
+		
+			
+	}
+    
+}
+
+//----------------------------
+// Distortion effects
+//----------------------------
+
+vertex_program Examples/FresnelRefractReflectVP cg
+{
+	source Example_Fresnel.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+}
+vertex_program Examples/FresnelRefractReflectVPold cg
+{
+	source Example_Fresnel.cg
+	entry_point main_vp_old
+	profiles vs_1_1 arbvp1
+}
+
+fragment_program Examples/FresnelRefractReflectFP cg
+{
+	source Example_Fresnel.cg
+	entry_point main_fp
+	// sorry, ps_1_1 and fp20 can't do this
+	profiles ps_2_0 arbfp1
+}
+
+fragment_program Examples/FresnelRefractReflectPS asm
+{
+	source Example_FresnelPS.asm
+	// sorry, only for ps_1_4 :)
+	syntax ps_1_4
+
+}
+
+material Examples/FresnelReflectionRefraction
+{
+	// ps_2_0 / arbfp1
+	technique
+	{
+		pass 
+		{
+			
+			vertex_program_ref Examples/FresnelRefractReflectVP
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto timeVal time 0.05
+				param_named scroll float 1  
+				param_named scale float 1 
+				param_named noise float 1 
+				// scroll and noisePos will need updating per frame
+			}
+			fragment_program_ref Examples/FresnelRefractReflectFP
+			{
+				param_named fresnelBias float -0.1 
+				param_named fresnelScale float 1.8 
+				param_named fresnelPower float 8  
+				param_named tintColour float4 0 0.0.05 0.05 1
+				param_named noiseScale float 0.05 
+			}
+			// Noise
+			texture_unit
+			{
+				// Perlin noise volume
+				texture waves2.dds
+				// min / mag filtering, no mip
+				filtering linear linear none
+			}
+			// Reflection
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Reflection
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 1
+			}
+			// Refraction
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Refraction
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 2
+			}
+		}
+		
+			
+	}
+
+	// ATI 8500 +
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Examples/FresnelRefractReflectVPold
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto eyePosition camera_position_object_space
+				param_named fresnelBias float -0.3
+				param_named fresnelScale float 1.4
+				param_named fresnelPower float 8
+				param_named_auto timeVal time_0_1 20
+				param_named scroll float 1 
+				param_named scale float 4 
+				param_named noise float 1
+				// scroll and noisePos will need updating per frame
+			}
+
+			// for ATI RADEON 8500 - 9200
+			fragment_program_ref Examples/FresnelRefractReflectPS
+			{
+				// distortionRange
+				param_indexed 0  float 0.025  
+				// tintColour
+				param_indexed 1  float4 0.05 0.12 0.15 1
+			}
+
+			// Noise
+			texture_unit
+			{
+				// Perlin noise volume
+				texture perlinvolume.dds 3d
+				// min / mag filtering, no mip
+				filtering linear linear none
+			}
+			// Reflection
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Reflection
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 1
+			}
+			// Refraction
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Refraction
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 2
+			}
+		}
+	}    
+}
+
+// Normal-mapped Athene statue
+material Examples/Athene/NormalMapped
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+
+			// texture shadow receiver program
+			shadow_receiver_vertex_program_ref Examples/BumpMapVPShadowRcv
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto worldMatrix world_matrix
+				param_named_auto texViewProj texture_viewproj_matrix
+			}
+			// Additive texture shadow receiver program
+			shadow_receiver_fragment_program_ref Examples/BumpMapFPShadowRcv
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg
+			}
+			
+		}
+
+	}
+}
+
+// Basic Athene statue
+material Examples/Athene/Basic
+{
+
+	technique
+	{
+		pass
+		{
+			ambient 0.3 0.3 0.3
+			diffuse 1.0 1.0 0.9
+
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+}
+
+
+// Any number of lights, diffuse and specular
+material Examples/Athene/NormalMappedSpecular
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVPSpecular
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFPSpecular
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+				param_named_auto lightSpecular light_specular_colour 0
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Normalisation cube map #2
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 2
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use, NB does not support specular colour
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+
+	}
+}
+
Index: code/branches/skybox/Media/materials/scripts/Examples.compositor
===================================================================
--- code/branches/skybox/Media/materials/scripts/Examples.compositor	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Examples.compositor	(revision 390)
@@ -0,0 +1,592 @@
+// Manuel's bloom
+// Needs a scene-sized rtt, but does only one render of the scene
+compositor Bloom
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 128 128 PF_A8R8G8B8
+        texture rt1 128 128 PF_A8R8G8B8
+
+        target rt1
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target rt0
+        {
+            // Start with clear texture
+            input none
+            // Vertical blur pass
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Blur0
+                input 0 rt1
+            }
+        }
+
+        target rt1
+        {
+            // Start with clear texture
+            input none
+            // Horizontal blur pass
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Blur1
+                input 0 rt0
+            }
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input previous
+            // Draw a fullscreen quad
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/BloomBlend
+                input 0 rt1
+            }
+        }
+    }
+}
+
+compositor Glass
+{
+    technique
+    {
+        texture rt0 target_width target_height PF_R8G8B8
+
+        target rt0 { input previous }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+
+            pass render_quad
+            {
+                material Ogre/Compositor/GlassPass
+                input 0 rt0
+            }
+        }
+    }
+}
+
+compositor "Old TV"
+{
+    technique
+    {
+        texture rt0 target_width target_height PF_R8G8B8
+
+        // render scene to a texture
+        target rt0 { input previous }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+
+            pass render_quad
+            {
+                // convert the previous render target to a black and white image, add some noise, distort it,
+                // then render to scene aligned quad
+                material Ogre/Compositor/OldTV
+                input 0 rt0
+            }
+        }
+    }
+}
+
+
+// Black and white effect
+compositor B&W
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/BlackAndWhite
+                input 0 rt0
+            }
+        }
+    }
+}
+
+//compositor DOF // based on Blur but final pass does depth of field
+//{
+//    technique
+//    {
+//        // Temporary textures
+//        texture rt0 target_width target_height PF_A8R8G8B8
+//        texture rt1 target_width target_height PF_A8R8G8B8
+//
+//        target rt1
+//        {
+//            // Render output from previous compositor (or original scene)
+//            input previous
+//        }
+//
+//        target rt0
+//        {
+//            // Start with clear texture
+//            input none
+//            // Vertical blur pass
+//            pass render_quad
+//            {
+//                // Renders a fullscreen quad with a material
+//                material Ogre/Compositor/DOF_Blur0
+//                input 0 rt1
+//            }
+//        }
+//
+//        target rt1
+//        {
+//            // Start with clear texture
+//            input none
+//            // Horizontal blur pass
+//            pass render_quad
+//            {
+//                // Renders a fullscreen quad with a material
+//                material Ogre/Compositor/DOF_Blur1
+//                input 0 rt0
+//            }
+//        }
+//
+//        target_output
+//        {
+//            // Start with clear output
+//            input none
+//            // Draw a fullscreen quad
+//            pass render_quad
+//            {
+//                // Renders a fullscreen quad with a material
+//                material Ogre/Compositor/DOF_Blend
+//                input 0 rt0
+//                input 1 rt1
+//            }
+//        }
+//    }
+//}
+
+// Embossed (fake bump) effect
+compositor Embossed
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Embossed
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// SharpenEdges
+compositor Sharpen Edges
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/SharpenEdges
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// Invert
+compositor Invert
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Invert
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// Posterize
+compositor Posterize
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Posterize
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// Laplace
+compositor Laplace
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Laplace
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// Tiling
+compositor Tiling
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Tiling
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// Old Movie
+compositor Old Movie
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target_output
+        {
+            // Start with clear output
+            input none
+            // Draw a fullscreen quad with the black and white image
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/OldMovie
+                input 0 rt0
+            }
+        }
+    }
+}
+
+// HDR
+compositor HDR
+{
+	// floating point only for now
+	technique
+	{
+        // Temporary textures
+		// Fullsize HDR render target, used as tone mapping source
+        texture rt_full target_width target_height PF_FLOAT16_RGB
+		// Targets used for luminance evaluation (3x3 downsample, point filtering)
+		texture rt_lum0 1 1 PF_FLOAT16_RGB
+		texture rt_lum1 4 4 PF_FLOAT16_RGB
+		texture rt_lum2 16 16 PF_FLOAT16_RGB
+		texture rt_lum3 64 64 PF_FLOAT16_RGB
+		texture rt_lum4 128 128 PF_FLOAT16_RGB
+		// Bright-pass filtered target (tone mapped)
+		texture rt_brightpass 128 128 PF_R8G8B8
+		// Bloom filter targets
+		texture rt_bloom0 128 128 PF_R8G8B8
+		texture rt_bloom1 128 128 PF_R8G8B8
+
+
+		target rt_full
+		{
+			// No input, render differently
+			input none
+
+			// Use float target HDR material scheme (unclamped shaders)
+			material_scheme HDR
+
+			pass clear
+			{
+			}
+
+			pass render_scene
+			{
+			}
+
+		}
+
+		// Downsample the original HDR scene to extract luminence value
+		target rt_lum4
+		{
+            input none
+            pass render_quad
+            {
+                // Downsample using a 2x2 filter and convert to greyscale
+                material Ogre/Compositor/HDR/Downsample2x2Luminence
+                input 0 rt_full
+                identifier 994
+            }
+		}
+		target rt_lum3
+		{
+            input none
+            pass render_quad
+            {
+				// Downsample using a 3x3 filter
+                material Ogre/Compositor/HDR/Downsample3x3
+                input 0 rt_lum4
+                identifier 993
+            }
+		}
+		target rt_lum2
+		{
+            input none
+            pass render_quad
+            {
+                // Downsample using a 3x3 filter
+                material Ogre/Compositor/HDR/Downsample3x3
+                input 0 rt_lum3
+                identifier 992
+            }
+		}
+		target rt_lum1
+		{
+            input none
+            pass render_quad
+            {
+                // Downsample using a 3x3 filter
+                material Ogre/Compositor/HDR/Downsample3x3
+                input 0 rt_lum2
+                identifier 991
+            }
+		}
+		target rt_lum0
+		{
+            input none
+            pass render_quad
+            {
+                // Downsample using a 3x3 filter
+                material Ogre/Compositor/HDR/Downsample3x3
+                input 0 rt_lum1
+                identifier 990
+            }
+		}
+
+
+		target rt_brightpass
+		{
+            input none
+            pass render_quad
+            {
+                // Downsample using a 3x3 filter, hi-pass and tone map
+                material Ogre/Compositor/HDR/Downsample3x3Brightpass
+                input 0 rt_full
+		        input 1 rt_lum0
+				identifier 800
+            }
+		}
+
+		target rt_bloom1
+		{
+			input none
+			pass render_quad
+			{
+				// Blur horizontally
+				material Ogre/Compositor/HDR/GaussianBloom
+				input 0 rt_brightpass
+				identifier 701
+			}
+		}
+		target rt_bloom0
+		{
+			input none
+			pass render_quad
+			{
+				// Blur horizontally
+				material Ogre/Compositor/HDR/GaussianBloom
+				input 0 rt_bloom1
+				identifier 700
+			}
+		}
+
+
+		// Final output combines tone mapping of the original scene, with an
+		// exposure setting passed in as a GPU parameter, and an additive bloom
+		// effect
+		target_output
+		{
+			input none
+			pass render_quad
+			{
+				material Ogre/Compositor/HDR/ToneMapping
+				input 0 rt_full
+				input 1 rt_bloom0
+				input 2 rt_lum0
+			}
+		}
+
+
+	}
+
+}
+
+
+// Gaussian blur effect
+compositor Gaussian Blur
+{
+    technique
+    {
+        // Temporary textures
+        texture rt0 target_width target_height PF_A8R8G8B8
+        texture rt1 target_width target_height PF_A8R8G8B8
+
+        target rt0
+        {
+            // Render output from previous compositor (or original scene)
+            input previous
+        }
+
+        target rt1
+        {
+            // Blur horizontally
+            input none
+			pass render_quad
+			{
+				material Ogre/Compositor/HDR/GaussianBloom
+				input 0 rt0
+				identifier 700
+			}
+        }
+
+		target_output
+        {
+            // Start with clear output
+            input none
+            // Blur vertically
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+				material Ogre/Compositor/HDR/GaussianBloom
+                input 0 rt1
+				identifier 701
+            }
+        }
+    }
+}
+
Index: code/branches/skybox/Media/materials/scripts/Examples.program
===================================================================
--- code/branches/skybox/Media/materials/scripts/Examples.program	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Examples.program	(revision 390)
@@ -0,0 +1,158 @@
+//---------------------------------------------------
+// This file includes a number of basic GPU programs
+// for use in many materials. 
+//---------------------------------------------------
+
+
+// A really basic ambient pass program, support for one texture coodinate set
+vertex_program Ogre/BasicVertexPrograms/AmbientOneTexture cg
+{
+	source Example_Basic.cg
+	entry_point ambientOneTexture_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto ambient ambient_light_colour
+	}
+	
+}
+// A really basic ambient pass program, support for one texture coodinate set
+vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureHLSL hlsl
+{
+	source Example_Basic.hlsl
+	entry_point ambientOneTexture_vp
+	target vs_1_1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto ambient ambient_light_colour
+	}
+}
+// A really basic ambient pass program, support for one texture coodinate set
+vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureGLSL glsl
+{
+	source AmbientOneTexture.glsl
+
+	default_params
+	{
+		param_named_auto ambient ambient_light_colour
+	}
+}
+
+vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureUnified unified
+{
+	delegate Ogre/BasicVertexPrograms/AmbientOneTextureGLSL
+	delegate Ogre/BasicVertexPrograms/AmbientOneTextureHLSL
+}
+
+
+// Same as below, but for use when rendering texture shadows
+vertex_program Ogre/HardwareSkinningOneWeightShadowCaster cg
+{
+	source Example_Basic.cg
+	entry_point hardwareSkinningOneWeightCaster_vp
+	profiles vs_1_1 arbvp1
+	includes_skeletal_animation true
+}
+// Basic hardware skinning using one indexed weight per vertex
+vertex_program Ogre/HardwareSkinningOneWeight cg
+{
+   source Example_Basic.cg
+   entry_point hardwareSkinningOneWeight_vp
+   profiles vs_1_1 arbvp1
+   includes_skeletal_animation true   
+}
+// Same as below, but for use when rendering texture shadows
+vertex_program Ogre/HardwareSkinningTwoWeightsShadowCasterCg cg
+{
+	source Example_Basic.cg
+	entry_point hardwareSkinningTwoWeightsCaster_vp
+	profiles vs_1_1 arbvp1
+	includes_skeletal_animation true
+}
+
+vertex_program Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL glsl
+{
+	source skinningTwoWeightsShadowCasterVp.glsl
+	includes_skeletal_animation true
+}
+
+vertex_program Ogre/HardwareSkinningTwoWeightsShadowCaster unified
+{
+	delegate Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL
+	delegate Ogre/HardwareSkinningTwoWeightsShadowCasterCg
+}
+
+// Basic hardware skinning using two indexed weights per vertex
+vertex_program Ogre/HardwareSkinningTwoWeightsCg cg
+{
+   source Example_Basic.cg
+   entry_point hardwareSkinningTwoWeights_vp
+   profiles vs_1_1 arbvp1
+   includes_skeletal_animation true
+}
+
+vertex_program Ogre/HardwareSkinningTwoWeightsGLSL glsl
+{
+   source skinningTwoWeightsVp.glsl
+   includes_skeletal_animation true
+}
+
+vertex_program Ogre/HardwareSkinningTwoWeights unified
+{
+	delegate Ogre/HardwareSkinningTwoWeightsGLSL
+	delegate Ogre/HardwareSkinningTwoWeightsCg
+	
+   default_params
+   {
+   		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto lightPos[0] light_position 0
+		param_named_auto lightPos[1] light_position 1
+		param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
+		param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
+   }
+}
+
+// Basic hardware skinning using four indexed weights per vertex
+vertex_program Ogre/HardwareSkinningFourWeights cg
+{
+   source Example_Basic.cg
+   entry_point hardwareSkinningFourWeights_vp
+   profiles vs_1_1 arbvp1
+   includes_skeletal_animation true
+
+}
+// Basic hardware morph animation 
+vertex_program Ogre/HardwareMorphAnimation cg
+{
+	source Example_Basic.cg
+	entry_point hardwareMorphAnimation
+	profiles vs_1_1 arbvp1
+
+	includes_morph_animation true
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto anim_t animation_parametric
+	}
+}
+// Basic hardware pose animation supporting 2 active poses
+vertex_program Ogre/HardwarePoseAnimation cg
+{
+	source Example_Basic.cg
+	entry_point hardwarePoseAnimation
+	profiles vs_1_1 arbvp1
+
+	includes_pose_animation 2
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named_auto anim_t animation_parametric
+	}
+}
+
+
Index: code/branches/skybox/Media/materials/scripts/Glass.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Glass.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Glass.material	(revision 390)
@@ -0,0 +1,40 @@
+fragment_program Ogre/Compositor/GlassFP cg
+{
+	source GlassFP.cg
+	entry_point main_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/GlassPass
+{
+	technique
+	{
+		pass
+		{
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/GlassFP
+			{
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+
+			texture_unit
+			{
+				texture WaterNormal1.tga 2d
+                tex_coord_set 1
+				//tex_address_mode clamp
+				filtering linear linear linear
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/HeatVision.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/HeatVision.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/HeatVision.material	(revision 390)
@@ -0,0 +1,209 @@
+///////////////////////////////////
+//			 PASS 0
+//		HEAT CASTERS PASS
+///////////////////////////////////
+
+vertex_program Fury/HeatVision/HeatCaster_vp cg
+{
+   source HeatVision.cg
+   entry_point HeatCaster_vp
+   profiles vs_1_1 arbvp1
+}
+
+fragment_program Fury/HeatVision/HeatCaster_fp cg
+{
+   source HeatVision.cg
+   entry_point HeatCaster_fp
+   profiles ps_2_0 arbfp1
+}
+
+material Fury/HeatVision/HeatCaster
+{
+    technique
+    {
+        pass
+        {
+            vertex_program_ref Fury/HeatVision/HeatCaster_vp
+            {
+                param_named_auto eyePosition camera_position_object_space
+                param_named_auto worldViewProj worldviewproj_matrix
+            }
+
+            fragment_program_ref Fury/HeatVision/HeatCaster_fp
+            {
+            }
+        }
+    }
+}
+
+///////////////////////////////////
+//			 PASS 0
+//		HEAT CASTERS PASS
+///////////////////////////////////
+
+vertex_program Fury/HeatVision/ColdCaster_vp cg
+{
+   source HeatVision.cg
+   entry_point ColdCaster_vp
+   profiles vs_1_1 arbvp1
+}
+
+fragment_program Fury/HeatVision/ColdCaster_fp cg
+{
+   source HeatVision.cg
+   entry_point ColdCaster_fp
+   profiles ps_2_0 arbfp1
+}
+
+material Fury/HeatVision/ColdCaster
+{
+    technique
+    {
+        pass
+        {
+            vertex_program_ref Fury/HeatVision/ColdCaster_vp
+            {
+                param_named_auto eyePosition camera_position_object_space
+                param_named_auto worldViewProj worldviewproj_matrix
+            }
+
+            fragment_program_ref Fury/HeatVision/ColdCaster_fp
+            {
+            }
+        }
+    }
+}
+
+///////////////////////////////////
+//			  PASS 1
+//  LIGHT TO HEAT CONVERSION PASS
+///////////////////////////////////
+
+vertex_program Fury/HeatVision/LightToHeat_vp cg
+{
+   source HeatVision.cg
+   entry_point LightToHeat_vp
+   profiles vs_1_1 arbvp1
+
+    default_params
+    {
+        param_named_auto flipping render_target_flipping
+    }
+}
+
+fragment_program Fury/HeatVision/LightToHeat_fp cg
+{
+   source HeatVision.cg
+   entry_point LightToHeat_fp
+   profiles ps_2_0 arbfp1
+}
+
+material Fury/HeatVision/LightToHeat
+{
+    technique
+    {
+        // pass 1
+        pass
+        {
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+            vertex_program_ref Fury/HeatVision/LightToHeat_vp
+            {
+            }
+
+            fragment_program_ref Fury/HeatVision/LightToHeat_fp
+            {
+                // these should be *really* random!
+                param_named random_fractions float4 0.3 0.7 0 0
+
+                param_named depth_modulator float4 0.6 0 0 0
+
+                // this one can be fixed
+                param_named heatBiasScale float4 0.0 1.0 0 0
+            }
+
+            // INPUT (from scene, where entities has "Fury/HeatVision/Caster" material for heat emanation)
+            texture_unit
+            {
+                tex_coord_set 0
+                filtering linear linear none
+                tex_address_mode clamp
+            }
+
+            // Noise map
+            texture_unit
+            {
+                texture HeatNoise.tga
+                tex_coord_set 0
+            }
+
+            // heat conversion texture
+            texture_unit
+            {
+                texture HeatLookup.tga
+                tex_coord_set 0
+                filtering point point none
+            }
+        }
+    }
+
+}
+
+
+///////////////////////////////////
+//			  PASS 2
+//			 BLUR PASS
+///////////////////////////////////
+
+vertex_program Fury/HeatVision/Blur_vp cg
+{
+   source HeatVision.cg
+   entry_point Blur_vp
+   profiles vs_1_1 arbvp1
+
+    default_params
+    {
+        param_named_auto flipping render_target_flipping
+    }
+}
+
+fragment_program Fury/HeatVision/Blur_fp cg
+{
+   source HeatVision.cg
+   entry_point Blur_fp
+   profiles ps_2_0 arbfp1
+}
+
+material Fury/HeatVision/Blur
+{
+    technique
+    {
+        // pass 1
+        pass
+        {
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+            vertex_program_ref Fury/HeatVision/Blur_vp
+            {
+            }
+
+            fragment_program_ref Fury/HeatVision/Blur_fp
+            {
+                param_named blurAmount float4 0.5 0 0 0
+            }
+
+            // INPUT (from previous)
+            texture_unit
+            {
+                texture Input
+                tex_coord_set 0
+                filtering linear linear none
+                tex_address_mode clamp
+            }
+        }
+    }
+}
Index: code/branches/skybox/Media/materials/scripts/Hurt.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Hurt.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Hurt.material	(revision 390)
@@ -0,0 +1,18 @@
+/// Just a simple red quad blended over the scene
+material RedQuad
+{
+    technique
+    {
+        pass
+        {
+            lighting on
+            diffuse 0.0 0.0 0.0 0.5
+            specular 0.0 0.0 0.0 1.0 
+            ambient 0.0 0.0 0.0
+            emissive 1.0 0.0 0.0
+            cull_hardware none
+            depth_check off
+            scene_blend alpha_blend
+        }
+    }
+}
Index: code/branches/skybox/Media/materials/scripts/Invert.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Invert.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Invert.material	(revision 390)
@@ -0,0 +1,36 @@
+fragment_program Ogre/Compositor/InvertFP cg
+{
+	source InvertFP.cg
+	entry_point Invert_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/Invert
+{
+	technique
+	{
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/InvertFP
+			{
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Laplace.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Laplace.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Laplace.material	(revision 390)
@@ -0,0 +1,39 @@
+fragment_program Ogre/Compositor/LaplaceFP cg
+{
+	source LaplaceFP.cg
+	entry_point Laplace_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/Laplace
+{
+    technique
+    {
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/LaplaceFP
+			{
+				param_named pixelSize float 0.0031
+				param_named scale float 1.0
+			}
+
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/MotionBlur.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/MotionBlur.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/MotionBlur.material	(revision 390)
@@ -0,0 +1,84 @@
+fragment_program Ogre/Compositor/Combine_fp cg
+{
+	source Combine_fp.cg
+	profiles ps_2_0 arbfp1
+	entry_point Combine_fp
+
+	default_params
+	{
+		param_named blur float 0.8
+	}
+}
+
+material Ogre/Compositor/Combine
+{
+	technique
+	{
+		pass
+		{
+			depth_check off
+
+			fragment_program_ref Ogre/Compositor/Combine_fp
+			{
+			}
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp
+			{
+			}
+
+			texture_unit RT
+			{
+				tex_address_mode clamp
+				filtering linear linear none
+                tex_coord_set 0
+			}
+
+			texture_unit SUM
+			{
+				tex_address_mode clamp
+				filtering linear linear none
+                tex_coord_set 0
+			}
+		}
+	}
+}
+
+material Ogre/Compositor/Copyback
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_check off
+
+			texture_unit Temp
+			{
+				tex_address_mode clamp
+				filtering linear linear none
+				colour_op replace
+                tex_coord_set 0
+			}
+		}
+	}
+}
+
+material Ogre/Compositor/MotionBlur
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_check off
+
+			texture_unit Sum
+			{
+				tex_address_mode clamp
+				filtering linear linear none
+				colour_op replace
+                tex_coord_set 0
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Ocean.controls
===================================================================
--- code/branches/skybox/Media/materials/scripts/Ocean.controls	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Ocean.controls	(revision 390)
@@ -0,0 +1,90 @@
+[1. Ocean2 Cg]
+material = Ocean2_Cg
+control = Wavelet Scale, BumpScale, GPU_VERTEX, 0, 2, 0
+control = Texture Scale X, textureScale, GPU_VERTEX, 0, 40, 0
+control = Texture Scale Y, textureScale, GPU_VERTEX, 0, 40, 1
+control = Wavelet Speed X, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 0
+control = Wavelet Speed Y, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 1
+control = Wave Frequency, waveFreq, GPU_VERTEX, 0, 0.05, 0
+control = Wave Amplitude, waveAmp, GPU_VERTEX, 0, 25, 0
+
+control = Deep Color [Red], deepColor, GPU_FRAGMENT, 0, 1, 0
+control = Deep Color [Green], deepColor, GPU_FRAGMENT, 0, 1, 1
+control = Deep Color [Blue], deepColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Shallow Color [Red], shallowColor, GPU_FRAGMENT, 0, 1, 0
+control = Shallow Color [Green], shallowColor, GPU_FRAGMENT, 0, 1, 1
+control = Shallow Color [Blue], shallowColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Reflection Color [Red], reflectionColor, GPU_FRAGMENT, 0, 1, 0
+control = Reflection Color [Green], reflectionColor, GPU_FRAGMENT, 0, 1, 1
+control = Reflection Color [Blue], reflectionColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Reflection Amount, reflectionAmount, GPU_FRAGMENT, 0, 1, 0
+control = Reflection Blur, reflectionBlur, GPU_FRAGMENT, 0, 8, 0
+control = Water Amount, waterAmount, GPU_FRAGMENT, 0, 1, 0
+control = Fresnel Power, fresnelPower, GPU_FRAGMENT, 0, 10, 0
+control = Fresnel Bias, fresnelBias, GPU_FRAGMENT, 0, 1, 0
+control = HDR Mulitplier, hdrMultiplier, GPU_FRAGMENT, 0, 2, 0
+
+[1a. Ocean2 HLSL/GLSL]
+material = Ocean2_HLSL_GLSL
+control = Wavelet Scale, BumpScale, GPU_VERTEX, 0, 2, 0
+control = Texture Scale X, textureScale, GPU_VERTEX, 0, 40, 0
+control = Texture Scale Y, textureScale, GPU_VERTEX, 0, 40, 1
+control = Wavelet Speed X, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 0
+control = Wavelet Speed Y, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 1
+control = Wave Frequency, waveFreq, GPU_VERTEX, 0, 0.05, 0
+control = Wave Amplitude, waveAmp, GPU_VERTEX, 0, 25, 0
+
+control = Deep Color [Red], deepColor, GPU_FRAGMENT, 0, 1, 0
+control = Deep Color [Green], deepColor, GPU_FRAGMENT, 0, 1, 1
+control = Deep Color [Blue], deepColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Shallow Color [Red], shallowColor, GPU_FRAGMENT, 0, 1, 0
+control = Shallow Color [Green], shallowColor, GPU_FRAGMENT, 0, 1, 1
+control = Shallow Color [Blue], shallowColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Reflection Color [Red], reflectionColor, GPU_FRAGMENT, 0, 1, 0
+control = Reflection Color [Green], reflectionColor, GPU_FRAGMENT, 0, 1, 1
+control = Reflection Color [Blue], reflectionColor, GPU_FRAGMENT, 0, 1, 2
+
+control = Reflection Amount, reflectionAmount, GPU_FRAGMENT, 0, 1, 0
+control = Reflection Blur, reflectionBlur, GPU_FRAGMENT, 0, 8, 0
+control = Water Amount, waterAmount, GPU_FRAGMENT, 0, 1, 0
+control = Fresnel Power, fresnelPower, GPU_FRAGMENT, 0, 10, 0
+control = Fresnel Bias, fresnelBias, GPU_FRAGMENT, 0, 1, 0
+control = HDR Mulitplier, hdrMultiplier, GPU_FRAGMENT, 0, 2, 0
+
+[2. Ocean1 HLSL/GLSL]
+material = OceanHLSL_GLSL
+control = scale x, scale, GPU_VERTEX, 0, 0.1, 0
+control = scale y, scale, GPU_VERTEX, 0, 0.1, 1
+control = scale z, scale, GPU_VERTEX, 0, 0.1, 2
+control = Wave Speed X, waveSpeed, GPU_VERTEX, 0, 1, 0
+control = Wave Speed Y, waveSpeed, GPU_VERTEX, 0, 1, 1
+control = Noise Speed, noiseSpeed, GPU_VERTEX, 0, 1, 0
+
+control = Fade Bias, fadeBias, GPU_FRAGMENT, 0, 1, 0
+control = Fade Exponent, fadeExp, GPU_FRAGMENT, 0, 20, 0
+control = Water Color (r), waterColor, GPU_FRAGMENT, 0, 1, 0
+control = Water Color (g), waterColor, GPU_FRAGMENT, 0, 1, 1
+control = Water Color (b), waterColor, GPU_FRAGMENT, 0, 1, 2
+
+[3. Ocean1 Cg]
+material = OceanCg
+control = scale x, scale, GPU_VERTEX, 0, 0.1, 0
+control = scale y, scale, GPU_VERTEX, 0, 0.1, 1
+control = scale z, scale, GPU_VERTEX, 0, 0.1, 2
+control = Wave Speed X, waveSpeed, GPU_VERTEX, 0, 1, 0
+control = Wave Speed Y, waveSpeed, GPU_VERTEX, 0, 1, 1
+control = Noise Speed, noiseSpeed, GPU_VERTEX, 0, 1, 0
+
+control = Fade Bias, fadeBias, GPU_FRAGMENT, 0, 1, 0
+control = Fade Exponent, fadeExp, GPU_FRAGMENT, 0, 20, 0
+control = Water Color (r), waterColor, GPU_FRAGMENT, 0, 1, 0
+control = Water Color (g), waterColor, GPU_FRAGMENT, 0, 1, 1
+control = Water Color (b), waterColor, GPU_FRAGMENT, 0, 1, 2
+
+
+
Index: code/branches/skybox/Media/materials/scripts/Ocean.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Ocean.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Ocean.material	(revision 390)
@@ -0,0 +1,427 @@
+vertex_program HLSL/OceanVS hlsl
+{
+	source oceanHLSL_Cg.vert
+	entry_point main
+	target vs_1_1
+
+
+	default_params
+	{
+		param_named_auto worldViewProj_matrix worldviewproj_matrix
+		param_named_auto eyePosition camera_position_object_space
+		param_named scale float3 0.012 0.005 0.03
+		param_named_auto time_0_X time_0_x 100.0
+	}
+}
+
+fragment_program HLSL/OceanFS hlsl
+{
+	source oceanHLSL_Cg.frag
+	entry_point main
+	target ps_2_0
+
+}
+
+vertex_program GLSL/OceanVS glsl
+{
+	source oceanGLSL.vert
+
+	default_params
+	{
+		param_named_auto eyePosition camera_position_object_space
+		param_named scale float3 0.012 0.005 0.03
+		param_named_auto time_0_X time_0_x 100.0
+	}
+}
+
+fragment_program GLSL/OceanFS glsl
+{
+	source oceanGLSL.frag
+
+	default_params
+	{
+		param_named Noise int 0
+		param_named skyBox int 1
+	}
+}
+
+material OceanHLSL_GLSL
+{
+	technique
+	{
+		pass
+		{
+			vertex_program_ref HLSL/OceanVS
+			{
+				param_named waveSpeed float2 0.0 0.168
+				param_named noiseSpeed float 0.155
+			}
+
+			fragment_program_ref HLSL/OceanFS
+			{
+				param_named fadeBias float 0.336
+				param_named fadeExp float 5.546
+				param_named waterColor float4 0.0 0.244 0.395 1.0
+			}
+
+			texture_unit
+			{
+				texture NoiseVolume.dds 3d
+				tex_coord_set 0
+				filtering linear linear none
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				tex_coord_set 1
+			}
+
+		}
+
+	}
+
+	technique
+	{
+		pass
+		{
+			vertex_program_ref GLSL/OceanVS
+			{
+				param_named waveSpeed float2 0.0 0.168
+				param_named noiseSpeed float 0.155
+			}
+
+			fragment_program_ref GLSL/OceanFS
+			{
+				param_named fadeBias float 0.336
+				param_named fadeExp float 5.546
+				param_named waterColor float4 0.0 0.244 0.395 1.0
+			}
+
+			texture_unit
+			{
+				texture NoiseVolume.dds 3d
+				tex_coord_set 0
+				filtering linear linear none
+				tex_address_mode wrap
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				tex_coord_set 1
+			}
+
+		}
+
+	}
+
+}
+
+
+vertex_program Cg/OceanVS cg
+{
+	source oceanHLSL_Cg.vert
+	entry_point main
+	profiles vs_1_1 arbvp1
+
+
+	default_params
+	{
+		param_named_auto worldViewProj_matrix worldviewproj_matrix
+		param_named_auto eyePosition camera_position_object_space
+		param_named scale float3 0.012 0.005 0.03
+		param_named_auto time_0_X time_0_x 100.0
+	}
+}
+
+fragment_program Cg/OceanFS cg
+{
+	source oceanHLSL_Cg.frag
+	entry_point main
+	profiles ps_2_0 arbfp1
+
+}
+
+material OceanCg
+{
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Cg/OceanVS
+			{
+				param_named waveSpeed float2 0.0 0.168
+				param_named noiseSpeed float 0.155
+			}
+
+			fragment_program_ref Cg/OceanFS
+			{
+				param_named fadeBias float 0.336
+				param_named fadeExp float 5.546
+				param_named waterColor float4 0.0 0.244 0.395 1.0
+			}
+
+			texture_unit
+			{
+				texture NoiseVolume.dds 3d
+				tex_coord_set 0
+				filtering linear linear none
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				tex_coord_set 1
+			}
+
+		}
+
+	}
+}
+
+
+vertex_program Cg/Ocean2VS cg
+{
+	source Ocean2HLSL_Cg.vert
+	entry_point main
+	profiles vs_1_1 arbvp1
+
+
+	default_params
+	{
+		param_named_auto WorldViewProj worldviewproj_matrix
+		param_named_auto eyePosition camera_position_object_space
+	}
+}
+
+fragment_program Cg/Ocean2FS cg
+{
+	source Ocean2HLSL_Cg.frag
+	entry_point main
+	profiles ps_2_0 arbfp1
+
+}
+
+material Ocean2_Cg
+{
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Cg/Ocean2VS
+			{
+				param_named BumpScale float 0.2
+				param_named textureScale float2 25 26
+				param_named bumpSpeed float2 0.015 0.005
+				param_named_auto time time_0_x 100.0
+				param_named waveFreq float 0.028
+				param_named waveAmp float 1.8
+			}
+
+			fragment_program_ref Cg/Ocean2FS
+			{
+				param_named deepColor float4 0 0.3 0.5 1.0
+				param_named shallowColor float4 0 1 1 1.0
+				param_named reflectionColor float4 0.95 1 1 1.0
+				param_named reflectionAmount float 1.0
+				param_named reflectionBlur float 0.0
+				param_named waterAmount float 0.3
+				param_named fresnelPower float 5.0
+				param_named fresnelBias float 0.328
+				param_named hdrMultiplier float 0.471
+			}
+
+			texture_unit
+			{
+				texture waves2.dds
+				tex_coord_set 0
+				filtering linear linear linear
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				tex_coord_set 1
+				filtering linear linear linear
+			}
+
+		}
+
+	}
+}
+
+
+vertex_program HLSL/Ocean2VS hlsl
+{
+	source Ocean2HLSL_Cg.vert
+	entry_point main
+	target vs_1_1
+
+
+	default_params
+	{
+		param_named_auto WorldViewProj worldviewproj_matrix
+		param_named_auto eyePosition camera_position_object_space
+	}
+}
+
+fragment_program HLSL/Ocean2FS hlsl
+{
+	source Ocean2HLSL_Cg.frag
+	entry_point main
+	target ps_2_0
+
+}
+
+vertex_program GLSL/Ocean2VS glsl
+{
+	source Ocean2GLSL.vert
+
+}
+
+fragment_program GLSL/Ocean2FS glsl
+{
+	source Ocean2GLSL.frag
+}
+
+material Ocean2_HLSL_GLSL
+{
+	technique HLSL
+	{
+		pass
+		{
+			vertex_program_ref HLSL/Ocean2VS
+			{
+				param_named BumpScale float 0.2
+				param_named textureScale float2 25 26
+				param_named bumpSpeed float2 0.015 0.005
+				param_named_auto time time_0_x 100.0
+				param_named waveFreq float 0.028
+				param_named waveAmp float 1.8
+			}
+
+			fragment_program_ref HLSL/Ocean2FS
+			{
+				param_named deepColor float4 0 0.3 0.5 1.0
+				param_named shallowColor float4 0 1 1 1.0
+				param_named reflectionColor float4 0.95 1 1 1.0
+				param_named reflectionAmount float 1.0
+				param_named reflectionBlur float 0.0
+				param_named waterAmount float 0.3
+				param_named fresnelPower float 5.0
+				param_named fresnelBias float 0.328
+				param_named hdrMultiplier float 0.471
+			}
+
+			texture_unit
+			{
+				texture waves2.dds
+				tex_coord_set 0
+				filtering linear linear linear
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				filtering linear linear linear
+				tex_coord_set 1
+			}
+
+		}
+
+	}
+
+	technique GLSL
+	{
+		pass
+		{
+			vertex_program_ref GLSL/Ocean2VS
+			{
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto time time_0_x 100.0
+				param_named BumpScale float 0.2
+				param_named textureScale float2 25 26
+				param_named bumpSpeed float2 0.015 0.005
+				param_named waveFreq float 0.028
+				param_named waveAmp float 1.8
+			}
+
+			fragment_program_ref GLSL/Ocean2FS
+			{
+				param_named deepColor float4 0 0.3 0.5 1.0
+				param_named shallowColor float4 0 1 1 1.0
+				param_named reflectionColor float4 0.95 1 1 1.0
+				param_named reflectionAmount float 1.0
+				param_named reflectionBlur float 0.0
+				param_named waterAmount float 0.3
+				param_named fresnelPower float 5.0
+				param_named fresnelBias float 0.328
+				param_named hdrMultiplier float 0.471
+				param_named NormalMap int 0
+				param_named EnvironmentMap int 1
+			}
+
+			texture_unit
+			{
+				texture waves2.dds
+				tex_coord_set 0
+				filtering linear linear linear
+			}
+
+			texture_unit
+			{
+				cubic_texture morning.jpg combinedUVW
+				tex_address_mode clamp
+				tex_coord_set 1
+				filtering linear linear linear
+			}
+
+		}
+
+	}
+}
+
+material SkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+			depth_check off
+
+			texture_unit
+			{
+				cubic_texture morning.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material LightFlare
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture flare.png
+			}
+		}
+	}
+}
+
+
Index: code/branches/skybox/Media/materials/scripts/OffsetMapping.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/OffsetMapping.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/OffsetMapping.material	(revision 390)
@@ -0,0 +1,242 @@
+// Bump map with Parallax offset vertex program, support for this is required 
+vertex_program Examples/OffsetMappingVP cg 
+{ 
+   source OffsetMapping.cg 
+   entry_point main_vp 
+   profiles vs_1_1 arbvp1 
+} 
+
+// Bump map with parallax fragment program 
+fragment_program Examples/OffsetMappingFP cg
+{ 
+   source OffsetMapping.cg
+   entry_point main_fp
+   profiles ps_2_0 arbfp1
+} 
+
+// Bump map with parallax fragment program 
+fragment_program Examples/OffsetMappingPS asm 
+{ 
+   source OffsetMapping_specular.asm 
+   // sorry, only for ps_1_4 and above:) 
+   syntax ps_1_4 
+} 
+
+
+material Examples/OffsetMapping/Specular 
+{ 
+
+  // This is the preferred technique which uses both vertex and 
+   // fragment programs, supports coloured lights 
+   technique 
+   { 
+      // do the lighting  and bump mapping with parallax pass 
+      pass 
+      { 
+       
+         // Vertex program reference 
+         vertex_program_ref Examples/OffsetMappingVP 
+         { 
+            param_named_auto lightPosition light_position_object_space 0 
+            param_named_auto eyePosition camera_position_object_space 
+            param_named_auto worldViewProj worldviewproj_matrix 
+         } 
+
+         // Fragment program 
+         fragment_program_ref Examples/OffsetMappingFP
+         { 
+            param_named_auto lightDiffuse light_diffuse_colour 0 
+            param_named_auto lightSpecular light_specular_colour 0 
+            // Parallax Height scale and bias 
+            param_named scaleBias float4 0.04 -0.02 1 0 
+         } 
+          
+         // Normal + height(alpha) map 
+         texture_unit 
+         { 
+            texture rockwall_NH.tga
+            tex_coord_set 0 
+         } 
+
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+            tex_coord_set 1 
+         } 
+      } 
+   } 
+
+
+   // This is the preferred technique which uses both vertex and 
+   // fragment programs, supports coloured lights 
+   technique 
+   { 
+      // do the lighting  and bump mapping with parallax pass 
+      pass 
+      { 
+       
+         // Vertex program reference 
+         vertex_program_ref Examples/OffsetMappingVP 
+         { 
+            param_named_auto lightPosition light_position_object_space 0 
+            param_named_auto eyePosition camera_position_object_space 
+            param_named_auto worldViewProj worldviewproj_matrix 
+         } 
+
+         // Fragment program 
+         fragment_program_ref Examples/OffsetMappingPS 
+         { 
+            param_indexed_auto 0 light_diffuse_colour 0 
+            param_indexed_auto 1 light_specular_colour 0 
+            // Parallax Height scale and bias 
+            param_indexed 2 float4 0.04 -0.02 1 0 
+         } 
+          
+         // Normal + height(alpha) map 
+         texture_unit 
+         { 
+            texture rockwall_NH.tga
+            tex_coord_set 0 
+         } 
+
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+            tex_coord_set 1 
+         } 
+      } 
+   } 
+   
+   // Simple no-shader fallback
+   technique 
+   { 
+      pass 
+      { 
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+         } 
+	  }
+   }
+
+}
+
+
+
+// Single-pass offset mapping with shadows
+vertex_program Examples/OffsetMappingIntegratedShadowsVPhlsl hlsl 
+{ 
+   source OffsetMapping.hlsl
+   entry_point integratedshadows_vp 
+   target vs_2_0
+} 
+vertex_program Examples/OffsetMappingIntegratedShadowsVPglsl glsl 
+{ 
+   source OffsetMappingVp.glsl
+} 
+
+// Single-pass offset mapping with shadows
+fragment_program Examples/OffsetMappingIntegratedShadowsFPhlsl hlsl
+{ 
+   source OffsetMapping.hlsl
+   entry_point integratedshadows_fp
+   target ps_2_0
+} 
+fragment_program Examples/OffsetMappingIntegratedShadowsFPglsl glsl
+{
+	source OffsetMappingFp.glsl
+	default_params
+	{
+		// assign samplers as required by GLSL
+		param_named normalHeightMap int 0
+		param_named diffuseMap int 1
+		param_named shadowMap1 int 2
+		param_named shadowMap2 int 3
+	}
+}
+// Single-pass offset mapping with shadows
+vertex_program Examples/OffsetMappingIntegratedShadowsVP unified
+{
+	delegate Examples/OffsetMappingIntegratedShadowsVPhlsl
+	delegate Examples/OffsetMappingIntegratedShadowsVPglsl
+}
+// Single-pass offset mapping with shadows
+fragment_program Examples/OffsetMappingIntegratedShadowsFP unified
+{
+	delegate Examples/OffsetMappingIntegratedShadowsFPhlsl
+	delegate Examples/OffsetMappingIntegratedShadowsFPglsl
+}
+
+
+
+material Examples/OffsetMapping/IntegratedShadows 
+{ 
+
+   technique 
+   { 
+      // do the lighting  and bump mapping with parallax pass 
+      pass 
+      { 
+       
+         // Vertex program reference 
+         vertex_program_ref Examples/OffsetMappingIntegratedShadowsVP
+         { 
+            param_named_auto lightPosition light_position_object_space 0
+            param_named_auto eyePosition camera_position_object_space 
+            param_named_auto worldViewProj worldviewproj_matrix 
+			param_named_auto spotDirection light_direction_object_space 0
+
+            param_named_auto lightPosition1 light_position_object_space 1
+			param_named_auto spotDirection1 light_direction_object_space 1
+			// shadow texture projections
+			param_named_auto worldMatrix world_matrix
+			param_named_auto texViewProj1 texture_viewproj_matrix 0
+			param_named_auto texViewProj2 texture_viewproj_matrix 1
+         } 
+
+         // Fragment program 
+         fragment_program_ref Examples/OffsetMappingIntegratedShadowsFP
+         { 
+            param_named_auto lightDiffuse light_diffuse_colour 0 
+			param_named_auto spotParams spotlight_params 0
+
+			param_named_auto lightDiffuse1 light_diffuse_colour 1
+			param_named_auto spotParams1 spotlight_params 1
+            // Parallax Height scale and bias 
+            param_named scaleBias float4 0.04 -0.02 1 0 
+         } 
+          
+         // Normal + height(alpha) map 
+         texture_unit 
+         { 
+            texture rockwall_NH.tga
+            tex_coord_set 0 
+         } 
+
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+            tex_coord_set 1 
+         } 
+
+		 // shadowmap 1
+		 texture_unit
+		 {
+		 	content_type shadow
+		 }
+		 // shadowmap 2
+		 texture_unit
+		 {
+		 	content_type shadow
+		 }
+      } 
+   } 
+
+
+
+}
+
Index: code/branches/skybox/Media/materials/scripts/Ogre.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Ogre.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Ogre.material	(revision 390)
@@ -0,0 +1,119 @@
+
+material Ogre/Earring
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0
+			diffuse 1 1 0
+
+			texture_unit
+			{
+				texture spheremap.png
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				env_map spherical
+			}
+		}
+	}
+}
+material Ogre/Skin
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.7 0.7 0.7
+			cull_hardware none
+
+			texture_unit
+			{
+				texture GreenSkin.jpg
+				tex_address_mode mirror
+			}
+		}
+	}
+}
+material Ogre/Tusks
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0.4
+			diffuse 1 1 0.8
+
+			texture_unit
+			{
+				texture dirt01.jpg
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+			}
+		}
+	}
+}
+material Ogre/Eyes
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture WeirdEye.png
+			}
+		}
+	}
+}
+material Cursor/default
+{
+	technique
+	{
+		pass
+		{
+			scene_blend alpha_blend
+
+			texture_unit
+			{
+				texture cursor.png
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Core/StatsBlockBorder/Down
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_check off
+
+			texture_unit
+			{
+				texture ogreborder.png
+			}
+		}
+	}
+}
+material Core/StatsBlockBorder/Up
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_check off
+
+			texture_unit
+			{
+				texture ogreborderUp.png
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/OldMovie.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/OldMovie.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/OldMovie.material	(revision 390)
@@ -0,0 +1,67 @@
+fragment_program Ogre/Compositor/OldMovieFP cg
+{
+	source OldMovieFP.cg
+	entry_point OldMovie_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/OldMovie
+{
+    technique
+    {
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/OldMovieFP
+			{
+				param_named_auto time_cycle_period time 20
+				param_named flicker float 0.4
+				param_named DirtFrequency float 0.0005
+				param_named luminance float3 0.30 0.59 0.11
+				param_named frameJitter float 0.004
+				param_named lumiShift float 0.03
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+			texture_unit SplotchesTx
+			{
+				texture 8x8PagesSplotches2.png 2d
+                tex_coord_set 1
+				tex_address_mode wrap
+				filtering trilinear
+			}
+
+			texture_unit
+			{
+				texture 1D_Noise.png 1d
+                tex_coord_set 2
+				tex_address_mode wrap
+				filtering point point none
+			}
+
+
+			texture_unit SepiaTx
+			{
+				texture Sepia1D.tga 1d
+                tex_coord_set 3
+				tex_address_mode mirror
+				filtering point point none
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/OldTV.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/OldTV.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/OldTV.material	(revision 390)
@@ -0,0 +1,59 @@
+fragment_program Ogre/Compositor/OldTV_FP cg
+{
+	source OldTV.cg
+	entry_point OldTV_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/OldTV
+{
+	technique
+	{
+
+		pass
+		{
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/OldTV_FP
+			{
+                param_named_auto time_0_X time_0_x 120
+                param_named_auto sin_time_0_X sintime_0_x 120
+
+                param_named distortionFreq float 2.7
+                param_named distortionScale float 2.5
+                param_named distortionRoll float 0.93
+                param_named interference float 0.5
+                param_named frameLimit float 0.40
+                param_named frameShape float 0.26
+                param_named frameSharpness float 6.0
+			}
+
+			texture_unit 0
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering linear linear linear
+			}
+
+			texture_unit 1
+			{
+				texture Random3D.dds 3d
+                tex_coord_set 1
+				tex_address_mode wrap
+				filtering linear linear linear
+			}
+
+			texture_unit 2
+			{
+				texture NoiseVolume.dds 3d
+                tex_coord_set 2
+				tex_address_mode wrap
+				filtering linear linear linear
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/Posterize.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Posterize.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Posterize.material	(revision 390)
@@ -0,0 +1,36 @@
+fragment_program Ogre/Compositor/PosterizeFP cg
+{
+	source PosterizeFP.cg
+	entry_point Posterize_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/Posterize
+{
+    technique
+    {
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			fragment_program_ref Ogre/Compositor/PosterizeFP
+			{
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/RZR-002.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/RZR-002.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/RZR-002.material	(revision 390)
@@ -0,0 +1,15 @@
+
+material RZR-002
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture RZR-002.png
+			}
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/SharpenEdges.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/SharpenEdges.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/SharpenEdges.material	(revision 390)
@@ -0,0 +1,60 @@
+fragment_program Ogre/Compositor/SharpenEdgesFP_cg cg
+{
+	source SharpenEdgesFP.cg
+    entry_point sharpenEdges_fp
+	profiles ps_2_0 arbfp1
+}
+
+fragment_program Ogre/Compositor/SharpenEdgesFP_ps_2_a hlsl
+{
+	source SharpenEdgesFP.cg
+    entry_point sharpenEdges_fp
+	target ps_2_a
+}
+
+fragment_program Ogre/Compositor/SharpenEdgesFP unified
+{
+	delegate Ogre/Compositor/SharpenEdgesFP_ps_2_a
+	delegate Ogre/Compositor/SharpenEdgesFP_cg
+
+	default_params
+	{
+		param_named_auto vTexelSize inverse_texture_size 0
+	}
+}
+
+material Ogre/Compositor/SharpenEdges
+{
+    technique
+    {
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			//DirectX 9.0 HLSL Vertex Shader vs_1_1
+			//vertex_program_ref PostFilters/SharpenEdgesVP
+			//{
+			//}
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			//DirectX 9.0 HLSL Pixel Shader ps_2_0
+			fragment_program_ref Ogre/Compositor/SharpenEdgesFP
+			{
+			}
+
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/StdQuad_vp.program
===================================================================
--- code/branches/skybox/Media/materials/scripts/StdQuad_vp.program	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/StdQuad_vp.program	(revision 390)
@@ -0,0 +1,71 @@
+vertex_program Ogre/Compositor/StdQuad_Cg_vp cg
+{
+	source StdQuad_vp.cg
+	entry_point StdQuad_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+	}
+}
+
+vertex_program Ogre/Compositor/StdQuad_Tex2_vp cg
+{
+	source StdQuad_vp.cg
+	entry_point StdQuad_Tex2_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+	}
+}
+
+vertex_program Ogre/Compositor/StdQuad_Tex2a_vp cg
+{
+	source StdQuad_vp.cg
+	entry_point StdQuad_Tex2a_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+	}
+}
+
+vertex_program Ogre/Compositor/StdQuad_Tex3_vp cg
+{
+	source StdQuad_vp.cg
+	entry_point StdQuad_Tex3_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+	}
+}
+
+vertex_program Ogre/Compositor/StdQuad_Tex4_vp cg
+{
+	source StdQuad_vp.cg
+	entry_point StdQuad_Tex4_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto worldViewProj worldviewproj_matrix
+	}
+}
+
+vertex_program Ogre/Compositor/StdQuad_GLSL_vp glsl
+{
+	source StdQuad_vp.glsl
+}
+
+
+vertex_program Ogre/Compositor/StdQuad_vp unified
+{
+	delegate Ogre/Compositor/StdQuad_GLSL_vp
+	delegate Ogre/Compositor/StdQuad_Cg_vp
+}
Index: code/branches/skybox/Media/materials/scripts/Tiling.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/Tiling.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/Tiling.material	(revision 390)
@@ -0,0 +1,39 @@
+fragment_program Ogre/Compositor/TilingFP cg
+{
+	source TilingFP.cg
+	entry_point Tiling_ps
+	profiles ps_2_0 arbfp1
+}
+
+material Ogre/Compositor/Tiling
+{
+    technique
+    {
+
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_func always_pass
+
+			vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp
+			{
+			}
+
+			//DirectX 9.0 HLSL Pixel Shader ps_2_0
+			fragment_program_ref Ogre/Compositor/TilingFP
+			{
+				param_named NumTiles float 75.0
+				param_named Threshhold float 0.15
+			}
+
+			texture_unit RT
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+
+		}
+	}
+}
Index: code/branches/skybox/Media/materials/scripts/VarianceShadowmap.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/VarianceShadowmap.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/VarianceShadowmap.material	(revision 390)
@@ -0,0 +1,103 @@
+
+// Shadow Caster __________________________________________________
+
+
+vertex_program VarianceShadowMapping/ShadowCasterVP cg
+{
+    source varianceshadowcastervp.cg
+    entry_point main
+    profiles arbvp1 vs_2_x
+
+    default_params
+    {
+        param_named_auto uModelViewProjection worldviewproj_matrix
+    }
+}
+
+fragment_program VarianceShadowMapping/ShadowCasterFP cg
+{
+    source varianceshadowcasterfp.cg
+    entry_point main
+    profiles arbfp1 ps_2_x
+
+    default_params
+    {
+        param_named      uDepthOffset float       1.0
+        param_named_auto uProjection              projection_matrix
+    }
+}
+
+material VarianceShadowMapping/ShadowCaster
+{
+    technique default
+    {
+        // Z-write only pass
+        pass Z-write
+        {
+            //Instead of using depth_bias, we'll be implementing it manually
+
+            vertex_program_ref VarianceShadowMapping/ShadowCasterVP
+            {
+            }
+            fragment_program_ref VarianceShadowMapping/ShadowCasterFP
+            {
+            }
+        }
+    }
+}
+
+
+
+// Shadow Receiver ________________________________________________
+
+vertex_program VarianceShadowMapping/ShadowReceiverVP cg
+{
+    source varianceshadowreceivervp.cg
+    entry_point main
+    profiles arbvp1 vs_2_x
+
+    default_params
+    {
+        param_named_auto uModelViewProjection   worldviewproj_matrix
+        param_named_auto uLightPosition         light_position_object_space 0
+        param_named_auto uModel                 world_matrix
+        param_named_auto uTextureViewProjection texture_viewproj_matrix
+    }
+}
+
+fragment_program VarianceShadowMapping/ShadowReceiverFP cg
+{
+    source varianceshadowreceiverfp.cg
+    entry_point main
+    profiles arbfp1 ps_2_x
+
+    default_params
+    {
+        param_named uSTexWidth  float 512.0
+        param_named uSTexHeight float 512.0
+    }
+}
+
+material VarianceShadowMapping/ShadowReceiver
+{
+    technique default
+    {
+        pass lighting
+        {
+            vertex_program_ref VarianceShadowMapping/ShadowReceiverVP
+            {
+            }
+
+            fragment_program_ref VarianceShadowMapping/ShadowReceiverFP
+            {
+            }
+
+            // we won't rely on hardware specific filtering of z-tests
+            texture_unit ShadowMap
+            {
+                tex_address_mode clamp
+                filtering none
+            }
+        }
+    }
+}
Index: code/branches/skybox/Media/materials/scripts/facial.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/facial.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/facial.material	(revision 390)
@@ -0,0 +1,85 @@
+
+material drbunsen_head
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.25 0.25
+			diffuse 1.0 1.0 1.0
+
+			texture_unit
+			{
+				texture Dr_Bunsen_Head.jpg
+			}
+		}
+	}
+}
+
+material drbunsen_teeth
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.25 0.25
+			diffuse 1.0 1.0 1.0
+
+		}
+	}
+}
+
+material drbunsen_tongue
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.25 0.25
+			diffuse 1.0 0.1 0.1
+
+		}
+	}
+}
+
+material drbunsen_gums
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.25 0.25
+			diffuse 1.0 0.1 0.1
+
+		}
+	}
+}
+
+material drbunsen_glasses
+{
+	technique
+	{
+		pass
+		{
+			depth_write off
+			scene_blend modulate
+			ambient 0.25 0.25 0.25
+			diffuse 0.75 0.75 0.75
+
+		}
+	}
+}
+
+material drbunsen_glasses_frame
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.25 0.25
+			diffuse 0.35 0.18 0 1
+
+		}
+	}
+}
+
Index: code/branches/skybox/Media/materials/scripts/hdr.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/hdr.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/hdr.material	(revision 390)
@@ -0,0 +1,286 @@
+// Downsample a 2x2 area & turn into luminence (unclamped)
+fragment_program Ogre/Compositor/HDR/downscale2x2LuminenceHLSL_fp hlsl
+{
+	source hdr.hlsl
+	entry_point downscale2x2Luminence
+	target ps_2_0
+}
+fragment_program Ogre/Compositor/HDR/downscale2x2LuminenceGLSL_fp glsl
+{
+	source hdr_downscale2x2luminence.glsl
+	default_params
+	{
+		param_named inRTT int 0
+	}
+}
+fragment_program Ogre/Compositor/HDR/downscale2x2Luminence_fp unified
+{
+	delegate Ogre/Compositor/HDR/downscale2x2LuminenceGLSL_fp
+	delegate Ogre/Compositor/HDR/downscale2x2LuminenceHLSL_fp
+	default_params
+	{
+	    param_named_auto texelSize inverse_texture_size 0
+	}
+}
+
+material Ogre/Compositor/HDR/Downsample2x2Luminence
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp
+			{
+			}
+			fragment_program_ref Ogre/Compositor/HDR/downscale2x2Luminence_fp
+			{
+			}
+
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering none 
+			}
+		}
+	}
+}
+
+// Downsample a 3x3 area
+fragment_program Ogre/Compositor/HDR/downscale3x3HLSL_fp hlsl
+{
+	source hdr.hlsl
+	entry_point downscale3x3
+	target ps_2_0
+}
+fragment_program Ogre/Compositor/HDR/downscale3x3GLSL_fp glsl
+{
+	source hdr_downscale3x3.glsl
+	default_params
+	{
+		param_named inRTT int 0
+	}
+}
+fragment_program Ogre/Compositor/HDR/downscale3x3_fp unified
+{
+	delegate Ogre/Compositor/HDR/downscale3x3GLSL_fp
+	delegate Ogre/Compositor/HDR/downscale3x3HLSL_fp
+	default_params
+	{
+	    param_named_auto texelSize inverse_texture_size 0
+	}
+}
+
+
+material Ogre/Compositor/HDR/Downsample3x3
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp
+			{
+			}
+			fragment_program_ref Ogre/Compositor/HDR/downscale3x3_fp
+			{
+			}
+
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering none 
+			}
+		}
+	}
+}
+
+// Downsample a 3x3 area and perform a brightness filter pass
+fragment_program Ogre/Compositor/HDR/downscale3x3brightpassHLSL_fp hlsl
+{
+	source hdr.hlsl
+	entry_point downscale3x3brightpass
+	target ps_2_0
+}
+fragment_program Ogre/Compositor/HDR/utils_fp glsl
+{
+	source hdr_tonemap_util.glsl
+}
+fragment_program Ogre/Compositor/HDR/downscale3x3brightpassGLSL_fp glsl
+{
+	source hdr_downscale3x3brightpass.glsl
+	// re-use common functions
+	attach Ogre/Compositor/HDR/utils_fp
+	default_params
+	{
+		param_named inRTT int 0
+		param_named inLum int 1
+	}
+}
+fragment_program Ogre/Compositor/HDR/downscale3x3brightpass_fp unified
+{
+	delegate Ogre/Compositor/HDR/downscale3x3brightpassGLSL_fp
+	delegate Ogre/Compositor/HDR/downscale3x3brightpassHLSL_fp
+	default_params
+	{
+	    param_named_auto texelSize inverse_texture_size 0
+	}
+}
+
+
+material Ogre/Compositor/HDR/Downsample3x3Brightpass
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp
+			{
+			}
+			fragment_program_ref Ogre/Compositor/HDR/downscale3x3brightpass_fp
+			{
+			}
+
+			// Scene 
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering none 
+			}
+			// Luminence 
+			texture_unit
+			{
+				tex_address_mode clamp
+				filtering none 
+			}
+		}
+	}
+}
+
+// Bloom an area using gaussian distribution
+fragment_program Ogre/Compositor/HDR/bloomHLSL_fp hlsl
+{
+	source hdr.hlsl
+	entry_point bloom
+	target ps_2_0
+}
+fragment_program Ogre/Compositor/HDR/bloomGLSL_fp glsl
+{
+	source hdr_bloom.glsl
+	default_params
+	{
+		param_named inRTT int 0
+	}
+}
+fragment_program Ogre/Compositor/HDR/bloom_fp unified
+{
+	delegate Ogre/Compositor/HDR/bloomGLSL_fp
+	delegate Ogre/Compositor/HDR/bloomHLSL_fp
+}
+
+
+material Ogre/Compositor/HDR/GaussianBloom
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp
+			{
+			}
+			fragment_program_ref Ogre/Compositor/HDR/bloom_fp
+			{
+			}
+
+			// Input 
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+				filtering none 
+			}
+		}
+	}
+}
+
+
+// Perform final tone mapping
+fragment_program Ogre/Compositor/HDR/finaltonemappingHLSL_fp hlsl
+{
+	source hdr.hlsl
+	entry_point finalToneMapping
+	target ps_2_0
+}
+fragment_program Ogre/Compositor/HDR/finaltonemappingGLSL_fp glsl
+{
+	source hdr_finalToneMapping.glsl
+	// re-use common functions
+	attach Ogre/Compositor/HDR/utils_fp
+	default_params
+	{
+		param_named inRTT int 0
+		param_named inBloom int 1
+		param_named inLum int 2
+	}
+}
+fragment_program Ogre/Compositor/HDR/finaltonemapping_fp unified
+{
+	delegate Ogre/Compositor/HDR/finaltonemappingHLSL_fp
+	delegate Ogre/Compositor/HDR/finaltonemappingGLSL_fp
+}
+
+material Ogre/Compositor/HDR/ToneMapping
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp
+			{
+			}
+			fragment_program_ref Ogre/Compositor/HDR/finaltonemapping_fp
+			{
+			}
+
+			// Scene 
+			texture_unit
+			{
+                tex_coord_set 0
+				tex_address_mode clamp
+			}
+			// Bloom
+			texture_unit
+			{
+				tex_address_mode clamp
+			}
+			// Luminence 
+			texture_unit
+			{
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+
Index: code/branches/skybox/Media/materials/scripts/instancing.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/instancing.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/instancing.material	(revision 390)
@@ -0,0 +1,131 @@
+
+vertex_program InstancingCg cg
+{
+	source instancing.cg
+	profiles vs_2_0
+	entry_point instancing_vp
+
+	default_params
+	{
+		param_named_auto ambient ambient_light_colour
+		param_named_auto lightDiffuseColour light_diffuse_colour 0
+		param_named_auto lightPos light_position 0
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+	}
+}
+vertex_program InstancingShadowCasterCg cg
+{
+   	source instancing.cg
+	profiles vs_2_0
+	entry_point instancingCaster_vp
+	default_params
+	{
+		param_named_auto ambient ambient_light_colour
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+	}
+}
+vertex_program CrowdCg cg
+{
+	source instancing.cg
+	profiles vs_2_0
+	entry_point crowd_vp
+	default_params
+	{
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto numBones custom 0
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+		param_named_auto lightPos light_position 0
+		param_named_auto lightDiffuseColour light_diffuse_colour 0
+		param_named_auto ambient ambient_light_colour
+	}
+}
+vertex_program CrowdShadowCasterCg cg
+{
+	source instancing.cg
+	profiles vs_2_0
+	entry_point crowdCaster_vp
+	default_params
+	{
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto numBones custom 0
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+		param_named_auto ambient ambient_light_colour
+	}
+}
+
+
+vertex_program InstancingGLSL glsl
+{
+	source instancingVp.glsl
+	preprocessor_defines SHADOW_CASTER=0
+	default_params
+	{
+		param_named_auto ambient ambient_light_colour
+		param_named_auto lightDiffuseColour light_diffuse_colour 0
+		param_named_auto lightPos light_position 0
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+	}
+}
+vertex_program InstancingShadowCasterGLSL glsl
+{
+   	source instancingVp.glsl
+	preprocessor_defines SHADOW_CASTER=1
+	default_params
+	{
+		param_named_auto ambient ambient_light_colour
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+	}
+}
+vertex_program CrowdGLSL glsl
+{
+	source crowdVp.glsl
+	preprocessor_defines SHADOW_CASTER=0
+	default_params
+	{
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto numBones custom 0
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+		param_named_auto lightPos light_position 0
+		param_named_auto lightDiffuseColour light_diffuse_colour 0
+		param_named_auto ambient ambient_light_colour
+	}
+}
+vertex_program CrowdShadowCasterGLSL glsl
+{
+	source crowdVp.glsl
+	preprocessor_defines SHADOW_CASTER=1
+	default_params
+	{
+		param_named_auto viewProjectionMatrix viewproj_matrix
+		param_named_auto numBones custom 0
+		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
+		param_named_auto ambient ambient_light_colour
+	}
+}
+
+
+vertex_program Instancing unified
+{
+	delegate InstancingGLSL
+	delegate InstancingCg
+}
+vertex_program InstancingShadowCaster unified
+{
+	delegate InstancingShadowCasterGLSL
+	delegate InstancingShadowCasterCg
+}
+vertex_program Crowd unified
+{
+	delegate CrowdGLSL
+	delegate CrowdCg
+}
+vertex_program CrowdShadowCaster unified
+{
+	delegate CrowdShadowCasterGLSL
+	delegate CrowdShadowCasterCg
+}
+
Index: code/branches/skybox/Media/materials/scripts/smoke.material
===================================================================
--- code/branches/skybox/Media/materials/scripts/smoke.material	(revision 390)
+++ code/branches/skybox/Media/materials/scripts/smoke.material	(revision 390)
@@ -0,0 +1,19 @@
+
+material Examples/Smoke
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture smoke.png
+				tex_address_mode clamp
+			}
+		}
+	}
+}
