Index: data/branches/environment/programs/Godrays_blur.cg
===================================================================
--- data/branches/environment/programs/Godrays_blur.cg	(revision 8258)
+++ data/branches/environment/programs/Godrays_blur.cg	(revision 8258)
@@ -0,0 +1,240 @@
+/**
+*
+* @brief Godrays_*.cg is a radial blur based shader implementation of the natural effects of godrays (ray light scattering).
+*
+* @author Markus Wegmann
+*
+**/
+
+
+struct OneTexelVertex {
+    float4 Position	: POSITION;
+    float2 UV		: TEXCOORD0;
+};
+
+//// Vertex Shader ////
+
+OneTexelVertex ScreenQuadVS(
+		float3 Position : POSITION, 
+		float2 UV	: TEXCOORD0
+) {
+    OneTexelVertex OUT = (OneTexelVertex)0;
+    OUT.Position = float4(Position, 1);
+    OUT.UV = float2(UV.xy);
+    return OUT;
+}
+
+OneTexelVertex ScreenQuadVSWithLightPosition(
+		float3 Position : POSITION, 
+		float2 UV	: TEXCOORD0,
+		
+		uniform float4x4 viewProj,
+		uniform float4 sunLightPosition,
+		
+		out float2 projSunLightPosition : TEXCOORD1
+) {
+    OneTexelVertex OUT = (OneTexelVertex)0;
+    OUT.Position = float4(Position, 1);
+    OUT.UV = float2(UV.xy);
+	
+	projSunLightPosition = (mul(viewProj, float4(0,0,0,1))).xy;
+	projSunLightPosition = float2(0.5, 0.5) + projSunLightPosition / 35;
+	
+    return OUT;
+}
+
+//// Fragment Shader ////
+
+void godray_blur(
+        OneTexelVertex IN,
+
+		float2 projSunLightPosition : TEXCOORD1,
+		
+        out float4 oColor: COLOR,
+        
+        uniform float exposure, 
+        uniform float decay,
+        uniform float density,
+        uniform sampler2D decal)
+
+{
+	const int NUM_SAMPLES = 36;
+	
+	float2 texCoord = IN.UV;
+	
+	
+	oColor = float4(0,0,0,1);
+	
+    float2 deltaTextCoord = IN.UV - projSunLightPosition;
+    deltaTextCoord *= 1.0f / NUM_SAMPLES * density;
+
+	float illuminationDecay = 1.0f;
+
+    for(int i=0; i < NUM_SAMPLES; i++)
+    {
+        texCoord -= deltaTextCoord;
+        float4 sample = tex2D(decal, texCoord);
+		
+		oColor += sample;
+        sample *= illuminationDecay;
+
+        illuminationDecay *= decay;
+    }
+
+    oColor *= exposure / NUM_SAMPLES;
+}
+
+
+void combineRenderAndGodrays(
+	OneTexelVertex IN,
+
+    out float4 color : COLOR,
+
+    uniform sampler2D renderDecal,
+    uniform sampler2D godraysDecal)
+{
+    color = tex2D(renderDecal, IN.UV) + tex2D(godraysDecal, IN.UV);
+}
+
+
+
+
+/* CgFx based code
+
+//// Variables ////
+/////////////////////////////////////////////////////////////////////////////////////
+
+float Script : STANDARDSGLOBAL <
+    string UIWidget = "none";
+    string ScriptClass = "scene";
+    string ScriptOrder = "postprocess";
+    string ScriptOutput = "color";
+    string Script = "Technique=Main;";
+> = 0.8;
+
+float4 SunLightPosition : Position <
+    string UIName =  "Sun Light Position";
+    string Space = "World";
+> = {0, 0, 0, 1};
+
+float4 SkyColor <
+    string UIName =  "Sky Color";
+	string UIWidget = "Color";
+> = {0f,0f,0f,1.0f};
+
+float GodrayExposure = 1f;
+float GodrayDecay = 0.1f;
+float GodrayDensity = 0.7f;
+
+texture ScnTarget : RenderColorTarget <
+	float2 ViewPortRatio = {1,1};
+    int MipLevels = 1;
+    string Format = "X8R8G8B8" ;
+    string UIWidget = "None";
+>;
+
+sampler2D ScnDecal = sampler_state {
+    Texture = <ScnTarget>;
+	WrapS = Repeat;
+    WrapT = Repeat;
+    MinFilter = Linear;
+    MagFilter = Linear;
+};
+
+texture GodrayTarget : RenderColorTarget <
+	float2 ViewPortRatio = {1,1};
+    int MipLevels = 1;
+    string Format = "X8R8G8B8" ;
+    string UIWidget = "None";
+>;
+
+sampler2D GodrayDecal = sampler_state {
+    Texture = <GodrayTarget>;
+	WrapS = ClampToEdge;
+    WrapT = ClampToEdge;
+    MinFilter = Linear;
+    MagFilter = Linear;
+};
+
+texture DepthBuffer : RENDERDEPTHSTENCILTARGET <
+    float2 ViewPortRatio = {1,1};
+    string Format = "D24S8";
+    string UIWidget = "None";
+>;
+
+texture LowDepthBuffer : RENDERDEPTHSTENCILTARGET <
+    float2 ViewPortRatio = {1,1};
+    string Format = "D24S8";
+    string UIWidget = "None";
+>;
+//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS ////////////////
+
+float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >;
+float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >;
+float4x4 VpXf : ViewProjection < string UIWidget="None"; >;
+float4x4 WorldXf : World < string UIWidget="None"; >;
+float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >;
+
+// Standard full-screen imaging value
+
+float ClearDepth <
+    string UIWidget = "None";
+> = 1.0;
+
+float2 ViewportSize : VIEWPORTPIXELSIZE <
+    string UIName="Screen Size";
+    string UIWidget="None";
+>;
+
+technique Main <
+	string Script =
+	"RenderColorTarget0=ScnTarget;"
+	"RenderDepthStencilTarget=DepthBuffer;"
+		"ClearSetColor=SkyColor;"
+		"ClearSetDepth=ClearDepth;"
+		"Clear=Color;"
+		"Clear=Depth;"
+	    "ScriptExternal=color;"
+	"Pass=BlurRaw;"
+	"Pass=CombineRender;";
+>
+{
+
+	pass BlurRaw
+	<
+		string Script = "RenderColorTarget=GodrayTarget;"
+			"RenderDepthStencilTarget=LowDepthBuffer;"
+			"Draw=Buffer;";
+    >
+	{
+		DepthTestEnable = false;
+		DepthMask = false;
+		BlendEnable = false;
+		
+		VertexShader = compile vp40 ScreenQuadVSWithLightPosition(VpXf, SunLightPosition);
+    	FragmentProgram = compile fp40 godray_blur(
+			GodrayExposure, 
+			GodrayDecay, 
+			GodrayDensity,
+			ScnDecal);
+  	}
+	
+	pass CombineRender
+	<
+		string Script = "RenderColorTarget0=;"
+			"RenderDepthStencilTarget=;"
+			"Draw=Buffer;";
+    >
+	{
+		DepthTestEnable = false;
+		DepthMask = false;
+		BlendEnable = false;
+		
+		VertexShader = compile vp40 ScreenQuadVS();
+    	FragmentProgram = compile fp40 combineRenderAndGodrays(
+			ScnDecal,
+			GodrayDecal);
+  	}
+}
+
+*/
Index: data/branches/environment/programs/Godrays_raw.cg
===================================================================
--- data/branches/environment/programs/Godrays_raw.cg	(revision 8258)
+++ data/branches/environment/programs/Godrays_raw.cg	(revision 8258)
@@ -0,0 +1,91 @@
+/**
+*
+* @brief
+* Godrays_*.cg is a radial blur based shader implementation of the natural effects of godrays (ray light scattering).
+* Godrays_raw.cg includes the shader programs for the preparating step.
+*
+* @author Markus Wegmann
+*
+**/
+
+
+void sun_shader(
+    float4 position : POSITION,
+	float4 normal: NORMAL,
+
+    out float4 oPosition : POSITION,
+    out float4 oColor : COLOR,
+
+    uniform float4x4 modelViewProj,
+    uniform float4 sunColor)
+{
+    oPosition = mul(modelViewProj, position);
+    oColor    = 2 * normalize(sunColor);
+}
+
+
+void black_shader(
+    float4 position : POSITION,
+
+    out float4 oPosition : POSITION,
+	out float4 oColor: COLOR0,
+
+    uniform float4x4 modelViewProj)
+{
+    oPosition = mul(modelViewProj, position);
+    oColor    = float4 (0, 0, 0, 1);
+}
+
+
+/* CgFx based code
+
+
+//// Variables ////
+/////////////////////////////////////////////////////////////////////////////////////
+
+float4 SunLightColor : Specular <
+    string UIName =  "Lamp 0 Color";
+    string Object = "Pointlight0";
+    string UIWidget = "Color";
+> = {0.3, 0.42, 1, 1};
+
+//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS ////
+
+float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >;
+float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >;
+float4x4 VpXf : ViewProjection < string UIWidget="None"; >;
+float4x4 WorldXf : World < string UIWidget="None"; >;
+float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >;
+
+
+//// Techniques ////
+technique SunShader
+{
+	pass p0 <
+	string Script = "Draw=geometry;";
+> 	{
+		DepthTestEnable = true;
+		DepthMask = true;
+		BlendEnable = true;
+		CullFaceEnable = true;
+			
+		VertexProgram = compile vp40 sun_shader(WvpXf, SunLightColor);  	
+  	}
+}
+
+technique BlackShader
+{
+		pass p0 <
+		string Script = "Draw=geometry;";
+> 		{
+			DepthTestEnable = true;
+			DepthMask = true;
+			BlendEnable = true;
+			CullFaceEnable = true;
+		
+			VertexProgram = compile vp40 black_shader(WvpXf);
+  		}
+}
+
+*/
+
