Index: data/media/materials/programs/GlassFP.cg
===================================================================
--- data/media/materials/programs/GlassFP.cg	(revision 5312)
+++ data/media/materials/programs/GlassFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/GrayScale.cg
===================================================================
--- data/media/materials/programs/GrayScale.cg	(revision 5312)
+++ data/media/materials/programs/GrayScale.cg	(revision 5312)
@@ -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: data/media/materials/programs/InvertFP.cg
===================================================================
--- data/media/materials/programs/InvertFP.cg	(revision 5312)
+++ data/media/materials/programs/InvertFP.cg	(revision 5312)
@@ -0,0 +1,6 @@
+sampler RT : register(s0);
+
+float4 Invert_ps (float2 iTexCoord : TEXCOORD0) : COLOR
+{
+	return 1 - tex2D(RT, iTexCoord);
+}
Index: data/media/materials/programs/LaplaceFP.cg
===================================================================
--- data/media/materials/programs/LaplaceFP.cg	(revision 5312)
+++ data/media/materials/programs/LaplaceFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/OldMovieFP.cg
===================================================================
--- data/media/materials/programs/OldMovieFP.cg	(revision 5312)
+++ data/media/materials/programs/OldMovieFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/OldTV.cg
===================================================================
--- data/media/materials/programs/OldTV.cg	(revision 5312)
+++ data/media/materials/programs/OldTV.cg	(revision 5312)
@@ -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: data/media/materials/programs/PosterizeFP.cg
===================================================================
--- data/media/materials/programs/PosterizeFP.cg	(revision 5312)
+++ data/media/materials/programs/PosterizeFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/Radial_Blur_FP.cg
===================================================================
--- data/media/materials/programs/Radial_Blur_FP.cg	(revision 5312)
+++ data/media/materials/programs/Radial_Blur_FP.cg	(revision 5312)
@@ -0,0 +1,57 @@
+//------------------------------------------------------
+//Radial_Blur_FP.cg
+//  Implements radial blur to be used with the compositor
+//  It's very dependant on screen resolution
+//------------------------------------------------------
+
+uniform sampler tex: register(s0);
+
+static const float samples[10] =
+{
+-0.08,
+-0.05,
+-0.03,
+-0.02,
+-0.01,
+0.01,
+0.02,
+0.03,
+0.05,
+0.08
+};
+
+float4 main(float2 texCoord: TEXCOORD0,
+            uniform float sampleDist,
+            uniform float sampleStrength
+           ) : COLOR
+{
+   //Vector from pixel to the center of the screen
+   float2 dir = 0.5 - texCoord;
+
+   //Distance from pixel to the center (distant pixels have stronger effect)
+   //float dist = distance( float2( 0.5, 0.5 ), texCoord );
+   float dist = sqrt( dir.x*dir.x + dir.y*dir.y );
+
+
+   //Now that we have dist, we can normlize vector
+   dir = normalize( dir );
+
+   //Save the color to be used later
+   float4 color = tex2D( tex, texCoord );
+
+   //Average the pixels going along the vector
+   float4 sum = color;
+   for (int i = 0; i < 10; i++)
+   {
+      sum += tex2D( tex, texCoord + dir * samples[i] * sampleDist );
+   }
+   sum /= 11;
+
+   //Calculate amount of blur based on
+   //distance and a strength parameter
+   float t = dist * sampleStrength;
+   t = saturate( t );//We need 0 <= t <= 1
+
+   //Blend the original color with the averaged pixels
+   return lerp( color, sum, t );
+}
Index: data/media/materials/programs/SharpenEdgesFP.cg
===================================================================
--- data/media/materials/programs/SharpenEdgesFP.cg	(revision 5312)
+++ data/media/materials/programs/SharpenEdgesFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/TilingFP.cg
===================================================================
--- data/media/materials/programs/TilingFP.cg	(revision 5312)
+++ data/media/materials/programs/TilingFP.cg	(revision 5312)
@@ -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: data/media/materials/programs/hdr.hlsl
===================================================================
--- data/media/materials/programs/hdr.hlsl	(revision 5312)
+++ data/media/materials/programs/hdr.hlsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_bloom.glsl
===================================================================
--- data/media/materials/programs/hdr_bloom.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_bloom.glsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_downscale2x2luminence.glsl
===================================================================
--- data/media/materials/programs/hdr_downscale2x2luminence.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_downscale2x2luminence.glsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_downscale3x3.glsl
===================================================================
--- data/media/materials/programs/hdr_downscale3x3.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_downscale3x3.glsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_downscale3x3brightpass.glsl
===================================================================
--- data/media/materials/programs/hdr_downscale3x3brightpass.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_downscale3x3brightpass.glsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_finalToneMapping.glsl
===================================================================
--- data/media/materials/programs/hdr_finalToneMapping.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_finalToneMapping.glsl	(revision 5312)
@@ -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: data/media/materials/programs/hdr_tonemap_util.glsl
===================================================================
--- data/media/materials/programs/hdr_tonemap_util.glsl	(revision 5312)
+++ data/media/materials/programs/hdr_tonemap_util.glsl	(revision 5312)
@@ -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: data/media/materials/scripts/BlackAndWhite.material
===================================================================
--- data/media/materials/scripts/BlackAndWhite.material	(revision 5312)
+++ data/media/materials/scripts/BlackAndWhite.material	(revision 5312)
@@ -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: data/media/materials/scripts/Embossed.material
===================================================================
--- data/media/materials/scripts/Embossed.material	(revision 5312)
+++ data/media/materials/scripts/Embossed.material	(revision 5312)
@@ -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: data/media/materials/scripts/Examples.compositor
===================================================================
--- data/media/materials/scripts/Examples.compositor	(revision 5304)
+++ data/media/materials/scripts/Examples.compositor	(revision 5312)
@@ -1,136 +1,2 @@
-// 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
 //{
@@ -189,207 +55,4 @@
 //}
 
-// 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
@@ -400,5 +63,5 @@
         // Temporary textures
 		// Fullsize HDR render target, used as tone mapping source
-        texture rt_full target_width target_height PF_FLOAT16_RGB
+		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
@@ -449,5 +112,5 @@
             pass render_quad
             {
-				// Downsample using a 3x3 filter
+                // Downsample using a 3x3 filter
                 material Ogre/Compositor/HDR/Downsample3x3
                 input 0 rt_lum4
@@ -492,13 +155,13 @@
 		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
+			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
-            }
+			}
 		}
 
@@ -541,52 +204,4 @@
 			}
 		}
-
-
 	}
-
 }
-
-
-// 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: data/media/materials/scripts/Glass.material
===================================================================
--- data/media/materials/scripts/Glass.material	(revision 5312)
+++ data/media/materials/scripts/Glass.material	(revision 5312)
@@ -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: data/media/materials/scripts/Invert.material
===================================================================
--- data/media/materials/scripts/Invert.material	(revision 5312)
+++ data/media/materials/scripts/Invert.material	(revision 5312)
@@ -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: data/media/materials/scripts/Laplace.material
===================================================================
--- data/media/materials/scripts/Laplace.material	(revision 5312)
+++ data/media/materials/scripts/Laplace.material	(revision 5312)
@@ -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: data/media/materials/scripts/OldMovie.material
===================================================================
--- data/media/materials/scripts/OldMovie.material	(revision 5312)
+++ data/media/materials/scripts/OldMovie.material	(revision 5312)
@@ -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: data/media/materials/scripts/OldTV.material
===================================================================
--- data/media/materials/scripts/OldTV.material	(revision 5312)
+++ data/media/materials/scripts/OldTV.material	(revision 5312)
@@ -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: data/media/materials/scripts/Posterize.material
===================================================================
--- data/media/materials/scripts/Posterize.material	(revision 5312)
+++ data/media/materials/scripts/Posterize.material	(revision 5312)
@@ -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: data/media/materials/scripts/RadialBlur.material
===================================================================
--- data/media/materials/scripts/RadialBlur.material	(revision 5312)
+++ data/media/materials/scripts/RadialBlur.material	(revision 5312)
@@ -0,0 +1,36 @@
+//Cg Pixel Shader ps_2_0
+fragment_program Radial_Blur_ps_cg cg
+{
+	source Radial_Blur_FP.cg
+	profiles ps_2_0 arbfp1
+	entry_point main
+
+}
+
+
+//Effect: Radial Blur
+material Ogre/Compositor/Radial_Blur
+{
+	technique
+	{
+		pass
+		{
+			//State: D3DRS_CULLMODE, Value : D3DCULL_NONE
+			cull_hardware none
+			cull_software none
+			depth_check off
+
+			fragment_program_ref Radial_Blur_ps_cg
+			{
+				param_named sampleDist float 0.5
+				param_named sampleStrength float 2.2
+			}
+			texture_unit
+			{
+				tex_coord_set 0
+				tex_address_mode clamp
+				filtering trilinear
+			}
+		}
+	}
+}
Index: data/media/materials/scripts/Shaders.compositor
===================================================================
--- data/media/materials/scripts/Shaders.compositor	(revision 5312)
+++ data/media/materials/scripts/Shaders.compositor	(revision 5312)
@@ -0,0 +1,399 @@
+// 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
+            }
+        }
+    }
+}
+
+// Black and white effect
+compositor BW
+{
+    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 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
+            }
+        }
+    }
+}
+
+// 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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+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
+            }
+        }
+    }
+}
+
+compositor Radial Blur
+{
+    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
+            // Blur vertically
+            pass render_quad
+            {
+                // Renders a fullscreen quad with a material
+                material Ogre/Compositor/Radial_Blur
+                input 0 rt0
+            }
+        }
+    }
+}
Index: data/media/materials/scripts/SharpenEdges.material
===================================================================
--- data/media/materials/scripts/SharpenEdges.material	(revision 5312)
+++ data/media/materials/scripts/SharpenEdges.material	(revision 5312)
@@ -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: data/media/materials/scripts/Tiling.material
===================================================================
--- data/media/materials/scripts/Tiling.material	(revision 5312)
+++ data/media/materials/scripts/Tiling.material	(revision 5312)
@@ -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: data/media/materials/scripts/hdr.material
===================================================================
--- data/media/materials/scripts/hdr.material	(revision 5312)
+++ data/media/materials/scripts/hdr.material	(revision 5312)
@@ -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
+			}
+		}
+	}
+}
+
+
