Commits

Frederic De Groef committed 5cee9b8

major cleanup of the source tree, ready to test several techniques

Comments (0)

Files changed (31)

 *.ilk
 *.dep
 *.res
-*.user
+*.user
+*.log
+*.dat

bin/Debug/resources.cfg

 FileSystem=../../media/Grid
 FileSystem=../../media/npr
 FileSystem=../../media/ssao
+FileSystem=../../media/ssao/ogre
+FileSystem=../../media/ssao/shanmugam
+FileSystem=../../media/ssao/rgba_iq
+FileSystem=../../media/ssao/crytek
 FileSystem=../../media/ulb_building
 FileSystem=../../media/models
 FileSystem=../../media/models/cassini

bin/Release/resources.cfg

 FileSystem=../../media/Grid
 FileSystem=../../media/npr
 FileSystem=../../media/ssao
+FileSystem=../../media/ssao/ogre
+FileSystem=../../media/ssao/shanmugam
+FileSystem=../../media/ssao/rgba_iq
+FileSystem=../../media/ssao/crytek
 FileSystem=../../media/ulb_building
 FileSystem=../../media/models
 FileSystem=../../media/models/cassini

media/ssao/ambient.cg

-struct VOut {
-    float4 p      : POSITION;
-    float2 uv     : TEXCOORD0;
-    float3 a      : TEXCOORD1;
-    float4 ssaoUV : TEXCOORD2;
-};
-
-VOut ambient_vs(
-    in float4 p : POSITION,
-    in float2 uv : TEXCOORD0,
-    uniform float3 ambient,
-    uniform float4x4 wvp
-    ) {
-    VOut OUT;
-    OUT.p = mul(wvp, p);
-    // just use projective texture which == OUT.p
-    OUT.ssaoUV = OUT.p;
-    OUT.a = ambient;
-    OUT.uv = uv;
-    return OUT;
-}
-
-struct PIn {
-    float2 uv     : TEXCOORD0;
-    float3 a      : TEXCOORD1;
-    float4 ssaoUV : TEXCOORD2;
-};
-
-float4 ambient_ps(PIn IN,
-    uniform sampler2D diffuseTex : TEXUNIT0,
-    uniform sampler2D ssaoTex    : TEXUNIT1): COLOR0 {
-    float2 ssaoUV = IN.ssaoUV.xy / IN.ssaoUV.w; // perspective divide
-
-    // move into texture space
-    ssaoUV = (float2(ssaoUV.x, -ssaoUV.y) + 1.0) * 0.5;
-    float3 ssao = tex2D(ssaoTex, ssaoUV).rgb;
-
-    float3 diffuse = tex2D(diffuseTex, IN.uv).rgb;
-    return float4(diffuse * IN.a/* * ssao*/, 1);
-}

media/ssao/ambient.program

-vertex_program ambient_vs cg
-{
-    source ambient.cg
-    profiles vs_1_1 arbvp1
-    entry_point ambient_vs
-
-    default_params
-    {
-        param_named_auto ambient ambient_light_colour
-        param_named_auto wvp worldviewproj_matrix
-    }
-}
-
-fragment_program ambient_ps cg
-{
-    source ambient.cg
-    profiles ps_2_0 arbfp1
-    entry_point ambient_ps
-
-    default_params
-    {
-    }
-}

media/ssao/blue.bmp

Removed
Old image

media/ssao/colours.material

-import diffuse_template from "diffuse.material"
-
-material white : diffuse_template
-{
-    set_texture_alias ambient_tex white.bmp
-    set_texture_alias diffuse_tex white.bmp
-}
-
-material orange : diffuse_template
-{
-    set_texture_alias ambient_tex orange.bmp
-    set_texture_alias diffuse_tex orange.bmp
-}
-
-material red : diffuse_template
-{
-    set_texture_alias ambient_tex red.bmp
-    set_texture_alias diffuse_tex red.bmp
-}
-
-material blue : diffuse_template
-{
-    set_texture_alias ambient_tex blue.bmp
-    set_texture_alias diffuse_tex blue.bmp
-}
-
-material green : diffuse_template
-{
-    set_texture_alias ambient_tex green.bmp
-    set_texture_alias diffuse_tex green.bmp
-}

media/ssao/crytek_ssao.cg

-struct AppData
-{
-    float4 p   : POSITION;
-    float3 n   : NORMAL;
-    float2 uv  : TEXCOORD0;
-};
-
-struct VertexOut
-{
-    float4 p             : POSITION;
-    float2 pixelPos      : TEXCOORD0;
-    float3 eyeViewVector : TEXCOORD1;
-};
-
-struct FragmentInput
-{
-    float2 pixelPos      : TEXCOORD0;
-    float3 eyeViewVector : TEXCOORD1;
-};
-
-//------------------------------------------------------------------------------
-VertexOut crytek_ssao_vs(AppData IN, uniform float4x4 wvp, uniform float3 farCorner)
-{
-    VertexOut OUT;
-    OUT.p = mul(wvp, IN.p);
-    // clean up inaccuracies for the UV coords
-    float2 uv = sign(IN.p);
-    // convert to image space
-    uv = (float2(uv.x, -uv.y) + 1.0) * 0.5;
-    OUT.pixelPos = uv;
-    // calculate the correct ray (modify XY parameters based on screen-space quad XY)
-    OUT.eyeViewVector = farCorner * float3(sign(IN.p.xy), 1);
-    
-	return OUT;
-}
-////------------------------------------------------------------------------------
-//float3 computeZ(float2 xy)
-//{
-    //return float3(xy, sqrt(1.0 - dot(xy, xy)));
-//}
-////------------------------------------------------------------------------------
-//// for ps_3_0, we want to use tex2Dlod because it's faster
-//ps_3_0 float4 TEX2DLOD(sampler2D map, float2 uv)
-//{
-    //return tex2Dlod(map, float4(uv.xy, 0, 0));
-//}
-////------------------------------------------------------------------------------
-//float4 TEX2DLOD(sampler2D map, float2 uv)
-//{
-    //return tex2D(map, uv);
-//}
-//------------------------------------------------------------------------------
-
-
-
-
-#define PI 3.14159265
-
-
-
-float compute_h(float3 PC, float r)
-{
-   return 1.0f - cos(asin(r/length(PC)));
-}
-
-//------------------------------------------------------------------------------
-
-
-float compute_sphere_cap_area(float3 PC, float r)
-{
-	float h = compute_h(PC, r);
-	return 2*PI*h;
-}
-
-
-
-//------------------------------------------------------------------------------
-
-float compute_approximate_AO(float3 C, float r, float3 P, float3 n)
-{
-	float3 PC = P-C;
-	return compute_sphere_cap_area(PC, r) * max(dot(n, normalize(PC)), 0.0f);
-}
-
-
-bool is_in_area(float2 top_left, float2 bottom_right, float2 pos)
-{
-    return	pos.x > top_left.x && pos.x < bottom_right.x &&  	
-			pos.y > top_left.y && pos.y < bottom_right.y;		
-}
-
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-
-
-#define NUM_SAMPLES 16
-#define INV_SAMPLES 1.0f / 16.0f
-#define R_FAR 0.5
-
-#define TOP_LEFT float2(0.2,0.2)
-#define BOTTOM_RIGHT float2(0.8, 0.8)
-
-
-void crytek_ssao_ps(
-    FragmentInput IN
-    ,uniform sampler2D geomMap : TEXUNIT0
-	,uniform sampler2D randMap : TEXUNIT1
-	,uniform float radius
-	,uniform float far
-	,uniform float4x4 clip_to_image_matrix 
-	,out float4 oColor : COLOR0)
-{
-
-    #define MAX_RAND_SAMPLES 14
-
-    const float3 RAND_SAMPLES[MAX_RAND_SAMPLES] =
-    {
-        float3(1, 0, 0),
-        float3(	-1, 0, 0),
-        float3(0, 1, 0),
-        float3(0, -1, 0),
-        float3(0, 0, 1),
-        float3(0, 0, -1),
-        normalize(float3(1, 1, 1)),
-        normalize(float3(-1, 1, 1)),
-        normalize(float3(1, -1, 1)),
-        normalize(float3(1, 1, -1)),
-        normalize(float3(-1, -1, 1)),
-        normalize(float3(-1, 1, -1)),
-        normalize(float3(1, -1, -1)),
-        normalize(float3(-1, -1, -1))
-    };
-
-
-
-	//if( is_in_area(TOP_LEFT, BOTTOM_RIGHT, IN.pixelPos))
-	//{		
-
-	    float3 randN = tex2D(randMap, IN.pixelPos * 24).xyz * 2.0 - 1.0;	
-
-		float4 current_pixel_data = tex2D(geomMap, IN.pixelPos);
-		float depth = current_pixel_data.r;
-		float3 normal = current_pixel_data.gba;
-
-		float3 viewPos = IN.eyeViewVector * depth;
-
-		float occlusion = 0.0f;
-		
-		// sampling neighbours
-		for(int i=0 ; i<6; i++)
-		{
-
-			float3 direction = reflect(RAND_SAMPLES[i], randN) + normal; 
-
-			float4 neighbour_coords = mul(clip_to_image_matrix,  float4(viewPos + direction * radius, 1));
-			neighbour_coords.xy /=  neighbour_coords.w;
-
-
-			float zd = saturate(far * (depth - tex2D(geomMap, neighbour_coords.xy).r));
-		
-	        occlusion += saturate(pow(1.0 - zd, 11) + zd);	
-			//occlusion += 1.0  / (1.0+zd*zd);
-		}
-
-		occlusion /= 6;
-		oColor=float4(occlusion, occlusion, occlusion, 1.0f);
-	//}
-//
-	//else
-	//{		
-		//oColor=float4( 1.0);
-	//}
-}

media/ssao/crytek_ssao.compositor

-compositor CrytekSSAO/Compositor
-{
-    technique
-    {
-        texture geom target_width target_height PF_FLOAT32_RGBA
-        texture scene target_width target_height PF_R8G8B8A8
-        //texture ssao target_width_scaled 0.5 target_height_scaled 0.5 PF_R8G8B8
-		texture ssao target_width target_height PF_R8G8B8
-        texture final target_width target_height PF_R8G8B8A8
-
-        // the scene we want to modulate
-        target scene
-        {
-            input previous
-        }
-
-        // the normals + depth render
-        // feel free to play with it
-        // right now it uses a 64-bit "fat" buffer that contains
-        // unnormalized depth and XYZ normals
-        target geom
-        {
-            input none
-            material_scheme geom
-
-            pass clear
-            {
-            }
-
-            pass render_scene
-            {
-            }
-        }
-
-        target ssao
-        {
-            input none
-
-            pass clear
-            {
-            }
-
-            pass render_quad
-            {
-                // our SSAO listener number
-                identifier 42
-
-                material CrytekSSAO/ssao
-                input 0 geom
-            }
-        }
-
-   
-
-		target final
-		{
-            input none
-
-            pass render_quad
-            {
-                // just output something, for example, use a modulate
-                // material to just multiply the scene by the ssao
-                material CrytekSSAO/Modulate
-                input 0 scene
-                input 1 ssao
-            }
-        }
-
-
-        target_output
-        {
-			input none
-
-			pass render_quad
-			{
-				material debug_view
-				input 0 geom
-				input 1 ssao
-				input 2 scene
-				input 3 final
-			}
-		}
-    }
-}

media/ssao/crytek_ssao.material

-
-// full screen quad with camera-to-pixel ray calculations
-
-vertex_program crytek_ssao_vs cg
-{
-    source       crytek_ssao.cg
-    profiles     vs_1_1 arbvp1
-    entry_point  crytek_ssao_vs
-    
-    default_params
-    {
-        param_named_auto wvp worldviewproj_matrix
-    }
-}
-
-fragment_program crytek_ssao_ps cg
-{
-    source       crytek_ssao.cg
-    entry_point  crytek_ssao_ps
-    profiles     ps_2_x arbfp1
-    default_params
-    {
-    }
-}
-
-
-material CrytekSSAO/ssao
-{
-    technique
-    {
-        pass
-        {
-            vertex_program_ref crytek_ssao_vs
-            {
-            }
-
-            fragment_program_ref crytek_ssao_ps
-			{
-				param_named radius float 0.2125
-            }
-
-            texture_unit geomMap
-            {
-                tex_address_mode clamp
-                filtering none
-            }    
-
-            texture_unit randMap
-            {
-                texture random.png
-                filtering none
-				tex_coord_set 0
-				tex_address_mode wrap
-            }     
-      
-        }
-    }
-}
-
-material CrytekSSAO/Modulate
-{
-    technique
-    {
-        pass
-        {
-            lighting off
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-        }
-    }
-}

media/ssao/diffuse.cg

-struct VIn
-{
-    float4 p    : POSITION;
-    float3 n    : NORMAL;
-    float2 uv   : TEXCOORD0;
-};
-
-struct VOut
-{
-    float4 p    : POSITION;
-
-    float2 uv   : TEXCOORD0;
-    float4 wp   : TEXCOORD1;
-    float3 n    : TEXCOORD2;
-    float4 lp   : TEXCOORD3;
-    float3 sdir : TEXCOORD4;
-};
-
-struct PIn
-{
-    float2 uv   : TEXCOORD0;
-    float4 wp   : TEXCOORD1;
-    float3 n    : TEXCOORD2;
-    float4 lp   : TEXCOORD3;
-    float3 sdir : TEXCOORD4;
-};
-
-struct POut
-{
-    float4 c : COLOR;
-};
-
-VOut diffuse_vs(VIn IN,
-    uniform float4x4 wMat,
-    uniform float4x4 wvpMat,
-    uniform float4x4 tvpMat,
-    uniform float4 spotlightDir
-)
-{
-    VOut OUT;
-    OUT.wp = mul(wMat, IN.p);
-    OUT.p = mul(wvpMat, IN.p);
-
-    OUT.uv = IN.uv;
-
-    OUT.n = mul(wMat, float4(IN.n, 0)).xyz; // world-space normal
-    OUT.sdir = mul(wMat, spotlightDir).xyz; // spotlight dir in world space
-
-    OUT.lp = mul(tvpMat, OUT.wp);
-
-    return OUT;
-}
-
-float4 btex2D(sampler2D map, float2 uv, float radius, float steps)
-{
-    half stepSize = 2.0 * radius / steps;
-    uv.xy -= radius.xx;
-
-    float4 total = float4(0, 0, 0, 0);
-    for (int x = 0; x < steps; ++x)
-        for (int y = 0; y < steps; ++y)
-            total +=
-                tex2D(map, float2(uv.xy + float2(x * stepSize, y * stepSize)));
-
-    return total / (steps * steps);
-}
-
-float computeShadow(
-    sampler2D shadowMap, float4 shadowMapPos, float ourDepth)
-{
-    float2 suv = shadowMapPos.xy / shadowMapPos.w;
-
-    float2 moments = btex2D(shadowMap, suv, 0.01, 4).rg;
-    float litFactor = (ourDepth <= moments.x ? 1 : 0);
-
-    // standard variance shadow mapping code
-    float E_x2 = moments.y;
-    float Ex_2 = moments.x * moments.x;
-    float vsmEpsilon = 0.0001;
-    float variance = min(max(E_x2 - Ex_2, 0.0) + vsmEpsilon, 1.0);
-    float m_d = moments.x - ourDepth;
-    float p = variance / (variance + m_d * m_d);
-
-    return smoothstep(0.2, 1, max(litFactor, p));
-}
-
-// to put it simply, this does 100% per pixel diffuse lighting
-POut diffuse_ps(
-    PIn IN,
-    uniform float3 lightDif0,
-    uniform float4 lightPos0,
-    uniform float4 lightAtt0,
-    uniform float3 lightSpec0,
-    uniform float shininess,
-    uniform float3 camPos,
-    uniform float4 invSMSize,
-    uniform float4 spotlightParams,
-    uniform sampler2D dMap : TEXUNIT0,
-    uniform sampler2D shadowMap : TEXUNIT1)
-{
-    POut OUT;
-
-    // direction
-    float3 ld0 = normalize(lightPos0.xyz - (lightPos0.w * IN.wp.xyz));
-
-    half lightDist = length(lightPos0.xyz - IN.wp.xyz) / lightAtt0.r;
-    // attenuation
-    half ila = lightDist * lightDist; // quadratic falloff
-    half la = 1.0 - ila;
-
-    float3 normal = normalize(IN.n);
-
-    float3 diffuse = max(dot(ld0, normal), 0);
-
-    // calculate the spotlight effect
-    float spot = (spotlightParams.x == 1 &&
-        spotlightParams.y == 0 &&
-        spotlightParams.z == 0 &&
-        spotlightParams.w == 1 ? 1 : // if so, then it's not a spot light
-        saturate(
-            (dot(ld0, normalize(-IN.sdir)) - spotlightParams.y) /
-            (spotlightParams.x - spotlightParams.y)));
-
-    float3 camDir = normalize(camPos - IN.wp.xyz);
-    float3 halfVec = normalize(ld0 + camDir);
-    float3 specular = pow(max(dot(normal, halfVec), 0), shininess);
-
-    float4 diffuseTex = tex2D(dMap, IN.uv);
-    //float4 specTex = tex2D(sMap, IN.uv);
-
-    float3 diffuseContrib = (diffuse * lightDif0 * diffuseTex.rgb);
-    float3 specularContrib = (specular * lightSpec0);// * specTex.rgb);
-    float3 light0C = (diffuseContrib + specularContrib) * la * spot;
-
-    float3 shadow = computeShadow(
-        // pass in the shadow map
-        shadowMap,
-        // the calculated shadow position in the shadow map
-        IN.lp,
-        // distance to light, done just as in the caster shader
-        lightDist).xxx; // 3 components
-
-    OUT.c = float4(light0C * shadow, 1);
-    //OUT.c = float4(1, 0, 0, 1);
-
-    return OUT;
-}
-
-void geom_vs(
-    in float4 p : POSITION, in float3 n : NORMAL,
-    out float4 cp : POSITION,
-    out float4 vp : TEXCOORD0, // view-space position
-    out float4 vn : TEXCOORD1,
-    uniform float4x4 wvpMat, uniform float4x4 wvMat)
-{
-    cp = mul(wvpMat, p);
-    vp = mul(wvMat, p);
-    vn = mul(wvMat, float4(n, 0));
-}
-
-struct geomOut
-{
-    float4 c : COLOR0;
-};
-
-geomOut geom_ps(in float4 vp : TEXCOORD0, in float4 vn : TEXCOORD1, uniform float far)
-{
-    geomOut OUT;
-    //OUT.c = float4(length(vp.xyz) / far, normalize(vn.xyz).xyz);
-    float depth = length(vp.xyz) / far ;
-    OUT.c = float4(depth, normalize(vn.xyz).xyz);
-    return OUT;
-}

media/ssao/diffuse.material

-material diffuse_template
-{
-	technique lighting
-	{
-	    scheme lighting
-
-	    pass
-	    {
-            ambient  1 1 1
-            diffuse  0 0 0
-            specular 0 0 0 0
-            emissive 0 0 0
-
-            vertex_program_ref ambient_vs
-            {
-            }
-
-            fragment_program_ref ambient_ps
-            {
-            }
-
-            texture_unit ambient_tex
-            {
-            }
-	    }
-		pass
-		{
-		    max_lights 8
-			scene_blend add
-            iteration once_per_light
-
-            ambient  0 0 0
-            diffuse  1 1 1
-            specular 0 0 0 128
-			
-            vertex_program_ref diffuse_vs
-            {
-            }
-
-            fragment_program_ref diffuse_ps
-            {
-            }
-
-			texture_unit diffuse_tex
-			{
-			}
-
-            texture_unit shadow_tex
-            {
-                content_type shadow
-                filtering anisotropic
-                max_anisotropy 16
-                tex_address_mode border
-                tex_border_colour 1 1 1
-            }
-		}
-	}
-
-    // this is the technique for the scheme "geom" that the SSAO
-    // compositor uses to render the geometry map
-	technique geom
-	{
-	    scheme geom
-
-	    pass
-	    {
-	        vertex_program_ref geom_vs
-	        {
-	        }
-
-	        fragment_program_ref geom_ps
-	        {
-	        }
-	    }
-	}
-}

media/ssao/diffuse.program

-vertex_program diffuse_vs cg
-{
-    source diffuse.cg
-    profiles vs_1_1 arbvp1
-    entry_point diffuse_vs
-
-    default_params
-    {
-        param_named_auto wMat world_matrix
-        param_named_auto wvpMat worldviewproj_matrix
-        param_named_auto tvpMat texture_viewproj_matrix 0
-        param_named_auto spotlightDir light_direction_object_space 0
-    }
-}
-
-fragment_program diffuse_ps cg
-{
-    source diffuse.cg
-    profiles ps_2_x arbfp1
-    entry_point diffuse_ps
-
-    default_params
-    {
-        param_named_auto lightDif0 light_diffuse_colour 0
-        param_named_auto lightSpec0 light_specular_colour 0
-        param_named_auto camPos camera_position
-        param_named_auto shininess surface_shininess
-        param_named_auto lightPos0 light_position 0
-        param_named_auto lightAtt0 light_attenuation 0
-        //param_named_auto invSMSize inverse_texture_size 1
-        param_named_auto spotlightParams spotlight_params 0
-    }
-}
-
-vertex_program geom_vs cg
-{
-    source diffuse.cg
-    profiles vs_1_1 arbvp1
-    entry_point geom_vs
-
-    default_params
-    {
-        param_named_auto wvpMat worldviewproj_matrix
-        param_named_auto wvMat worldview_matrix
-    }
-}
-
-fragment_program geom_ps cg
-{
-    source diffuse.cg
-    profiles ps_2_0 arbfp1
-    entry_point geom_ps
-
-    default_params
-    {
-        param_named_auto far far_clip_distance
-    }
-}

media/ssao/diffuse_gbuffer.cg

+void geom_vs(
+    in float4 p : POSITION, in float3 n : NORMAL,
+    out float4 cp : POSITION,
+    out float4 vp : TEXCOORD0, // view-space position
+    out float4 vn : TEXCOORD1,
+    uniform float4x4 wvpMat, uniform float4x4 wvMat)
+{
+    cp = mul(wvpMat, p);
+    vp = mul(wvMat, p);
+    vn = mul(wvMat, float4(n, 0));
+}
+
+struct geomOut
+{
+    float4 c : COLOR0;
+};
+
+geomOut geom_ps(in float4 vp : TEXCOORD0, in float4 vn : TEXCOORD1, uniform float far)
+{
+    geomOut OUT;
+    //OUT.c = float4(length(vp.xyz) / far, normalize(vn.xyz).xyz);
+    float depth = length(vp.xyz) / far ;
+    OUT.c = float4(depth, normalize(vn.xyz).xyz);
+    return OUT;
+}

media/ssao/diffuse_gbuffer.material

+material SSAO/DiffuseLight_GBuffer
+{
+  technique lighting
+  {
+    scheme lighting
+    pass
+    {
+      ambient 0.3 0.3 0.3 1.0
+      diffuse  0.5 0.5 0.5
+    }
+  }
+  
+  technique geom
+  {  
+    scheme geom
+    pass
+    {
+        vertex_program_ref gbuffer_vs
+        {
+        }
+
+        fragment_program_ref gbuffer_ps
+        {
+        }
+    }
+  }
+}

media/ssao/diffuse_gbuffer.program

+
+vertex_program gbuffer_vs cg
+{
+    source diffuse_gbuffer.cg
+    profiles vs_1_1 arbvp1
+    entry_point geom_vs
+
+    default_params
+    {
+        param_named_auto wvpMat worldviewproj_matrix
+        param_named_auto wvMat worldview_matrix
+    }
+}
+
+fragment_program gbuffer_ps cg
+{
+    source diffuse_gbuffer.cg
+    profiles ps_2_0 arbfp1
+    entry_point geom_ps
+
+    default_params
+    {
+        param_named_auto far far_clip_distance
+    }
+}

media/ssao/noise.png

Removed
Old image

media/ssao/ogre/noise.png

Added
New image

media/ssao/ogre/ogre_ssao.cg

+struct AppData
+{
+    float4 p   : POSITION;
+    float3 n   : NORMAL;
+    float2 uv  : TEXCOORD0;
+};
+
+struct VertexOut
+{
+    float4 p             : POSITION;
+    float2 pixelPos      : TEXCOORD0;
+    float3 eyeViewVector : TEXCOORD1;
+};
+
+struct FragmentInput
+{
+    float2 pixelPos      : TEXCOORD0;
+    float3 eyeViewVector : TEXCOORD1;
+};
+
+//------------------------------------------------------------------------------
+VertexOut ogre_ssao_vs(AppData IN, uniform float4x4 wvp, uniform float3 farCorner)
+{
+    VertexOut OUT;
+    OUT.p = mul(wvp, IN.p);
+    // clean up inaccuracies for the UV coords
+    float2 uv = sign(IN.p);
+    // convert to image space
+    uv = (float2(uv.x, -uv.y) + 1.0) * 0.5;
+    OUT.pixelPos = uv;
+    // calculate the correct ray (modify XY parameters based on screen-space quad XY)
+    OUT.eyeViewVector = farCorner * float3(sign(IN.p.xy), 1);
+    
+	return OUT;
+}
+////------------------------------------------------------------------------------
+//float3 computeZ(float2 xy)
+//{
+    //return float3(xy, sqrt(1.0 - dot(xy, xy)));
+//}
+////------------------------------------------------------------------------------
+//// for ps_3_0, we want to use tex2Dlod because it's faster
+//ps_3_0 float4 TEX2DLOD(sampler2D map, float2 uv)
+//{
+    //return tex2Dlod(map, float4(uv.xy, 0, 0));
+//}
+////------------------------------------------------------------------------------
+//float4 TEX2DLOD(sampler2D map, float2 uv)
+//{
+    //return tex2D(map, uv);
+//}
+//------------------------------------------------------------------------------
+
+
+
+
+#define PI 3.14159265
+
+
+
+float compute_h(float3 PC, float r)
+{
+   return 1.0f - cos(asin(r/length(PC)));
+}
+
+//------------------------------------------------------------------------------
+
+
+float compute_sphere_cap_area(float3 PC, float r)
+{
+	float h = compute_h(PC, r);
+	return 2*PI*h;
+}
+
+
+
+//------------------------------------------------------------------------------
+
+float compute_approximate_AO(float3 C, float r, float3 P, float3 n)
+{
+	float3 PC = P-C;
+	return compute_sphere_cap_area(PC, r) * max(dot(n, normalize(PC)), 0.0f);
+}
+
+
+bool is_in_area(float2 top_left, float2 bottom_right, float2 pos)
+{
+    return	pos.x > top_left.x && pos.x < bottom_right.x &&  	
+			pos.y > top_left.y && pos.y < bottom_right.y;		
+}
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+#define NUM_SAMPLES 16
+#define INV_SAMPLES 1.0f / 16.0f
+#define R_FAR 0.5
+
+#define TOP_LEFT float2(0.2,0.2)
+#define BOTTOM_RIGHT float2(0.8, 0.8)
+
+
+void ogre_ssao_ps(
+    FragmentInput IN
+    ,uniform sampler2D geomMap : TEXUNIT0
+	,uniform sampler2D randMap : TEXUNIT1
+	,uniform float radius
+	,uniform float far
+	,uniform float4x4 clip_to_image_matrix 
+	,out float4 oColor : COLOR0)
+{
+
+    #define MAX_RAND_SAMPLES 14
+
+    const float3 RAND_SAMPLES[MAX_RAND_SAMPLES] =
+    {
+        float3(1, 0, 0),
+        float3(	-1, 0, 0),
+        float3(0, 1, 0),
+        float3(0, -1, 0),
+        float3(0, 0, 1),
+        float3(0, 0, -1),
+        normalize(float3(1, 1, 1)),
+        normalize(float3(-1, 1, 1)),
+        normalize(float3(1, -1, 1)),
+        normalize(float3(1, 1, -1)),
+        normalize(float3(-1, -1, 1)),
+        normalize(float3(-1, 1, -1)),
+        normalize(float3(1, -1, -1)),
+        normalize(float3(-1, -1, -1))
+    };
+
+
+
+	//if( is_in_area(TOP_LEFT, BOTTOM_RIGHT, IN.pixelPos))
+	//{		
+
+	    float3 randN = tex2D(randMap, IN.pixelPos * 24).xyz * 2.0 - 1.0;	
+
+		float4 current_pixel_data = tex2D(geomMap, IN.pixelPos);
+		float depth = current_pixel_data.r;
+		float3 normal = current_pixel_data.gba;
+
+		float3 viewPos = IN.eyeViewVector * depth;
+
+		float occlusion = 0.0f;
+		
+		// sampling neighbours
+		for(int i=0 ; i<6; i++)
+		{
+
+			float3 direction = reflect(RAND_SAMPLES[i], randN) + normal; 
+
+			float4 neighbour_coords = mul(clip_to_image_matrix,  float4(viewPos + direction * radius, 1));
+			neighbour_coords.xy /=  neighbour_coords.w;
+
+
+			float zd = saturate(far * (depth - tex2D(geomMap, neighbour_coords.xy).r));
+		
+	        occlusion += saturate(pow(1.0 - zd, 11) + zd);	
+			//occlusion += 1.0  / (1.0+zd*zd);
+		}
+
+		occlusion /= 6;
+		oColor=float4(occlusion, occlusion, occlusion, 1.0f);
+	//}
+//
+	//else
+	//{		
+		//oColor=float4( 1.0);
+	//}
+}

media/ssao/ogre/ogre_ssao.material

+
+// full screen quad with camera-to-pixel ray calculations
+
+vertex_program ogre_ssao_vs cg
+{
+    source       ogre_ssao.cg
+    profiles     vs_1_1 arbvp1
+    entry_point  ogre_ssao_vs
+    
+    default_params
+    {
+        param_named_auto wvp worldviewproj_matrix
+    }
+}
+
+fragment_program ogre_ssao_ps cg
+{
+    source       ogre_ssao.cg
+    entry_point  ogre_ssao_ps
+    profiles     ps_2_x arbfp1
+    default_params
+    {
+    }
+}
+
+
+material SSAO/Ogre/ssao
+{
+    technique
+    {
+        pass
+        {
+            vertex_program_ref ogre_ssao_vs
+            {
+            }
+
+            fragment_program_ref ogre_ssao_ps
+			{
+				param_named radius float 0.2125
+            }
+
+            texture_unit geomMap
+            {
+                tex_address_mode clamp
+                filtering none
+            }    
+
+            texture_unit randMap
+            {
+                texture random.png
+                filtering none
+				tex_coord_set 0
+				tex_address_mode wrap
+            }     
+      
+        }
+    }
+}
+
+material SSAO/Ogre/Modulate
+{
+    technique
+    {
+        pass
+        {
+            lighting off
+
+            texture_unit
+            {
+                texture white.bmp
+                filtering bilinear
+            }
+
+            texture_unit
+            {
+                texture white.bmp
+                filtering bilinear
+            }
+        }
+    }
+}

media/ssao/ogre_ssao.cg

-struct AppData
-{
-    float4 p   : POSITION;
-    float3 n   : NORMAL;
-    float2 uv  : TEXCOORD0;
-};
-
-struct VertexOut
-{
-    float4 p             : POSITION;
-    float2 pixelPos      : TEXCOORD0;
-    float3 eyeViewVector : TEXCOORD1;
-};
-
-struct FragmentInput
-{
-    float2 pixelPos      : TEXCOORD0;
-    float3 eyeViewVector : TEXCOORD1;
-};
-
-//------------------------------------------------------------------------------
-VertexOut ogre_ssao_vs(AppData IN, uniform float4x4 wvp, uniform float3 farCorner)
-{
-    VertexOut OUT;
-    OUT.p = mul(wvp, IN.p);
-    // clean up inaccuracies for the UV coords
-    float2 uv = sign(IN.p);
-    // convert to image space
-    uv = (float2(uv.x, -uv.y) + 1.0) * 0.5;
-    OUT.pixelPos = uv;
-    // calculate the correct ray (modify XY parameters based on screen-space quad XY)
-    OUT.eyeViewVector = farCorner * float3(sign(IN.p.xy), 1);
-    
-	return OUT;
-}
-////------------------------------------------------------------------------------
-//float3 computeZ(float2 xy)
-//{
-    //return float3(xy, sqrt(1.0 - dot(xy, xy)));
-//}
-////------------------------------------------------------------------------------
-//// for ps_3_0, we want to use tex2Dlod because it's faster
-//ps_3_0 float4 TEX2DLOD(sampler2D map, float2 uv)
-//{
-    //return tex2Dlod(map, float4(uv.xy, 0, 0));
-//}
-////------------------------------------------------------------------------------
-//float4 TEX2DLOD(sampler2D map, float2 uv)
-//{
-    //return tex2D(map, uv);
-//}
-//------------------------------------------------------------------------------
-
-
-
-
-#define PI 3.14159265
-
-
-
-float compute_h(float3 PC, float r)
-{
-   return 1.0f - cos(asin(r/length(PC)));
-}
-
-//------------------------------------------------------------------------------
-
-
-float compute_sphere_cap_area(float3 PC, float r)
-{
-	float h = compute_h(PC, r);
-	return 2*PI*h;
-}
-
-
-
-//------------------------------------------------------------------------------
-
-float compute_approximate_AO(float3 C, float r, float3 P, float3 n)
-{
-	float3 PC = P-C;
-	return compute_sphere_cap_area(PC, r) * max(dot(n, normalize(PC)), 0.0f);
-}
-
-
-bool is_in_area(float2 top_left, float2 bottom_right, float2 pos)
-{
-    return	pos.x > top_left.x && pos.x < bottom_right.x &&  	
-			pos.y > top_left.y && pos.y < bottom_right.y;		
-}
-
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-
-
-#define NUM_SAMPLES 16
-#define INV_SAMPLES 1.0f / 16.0f
-#define R_FAR 0.5
-
-#define TOP_LEFT float2(0.2,0.2)
-#define BOTTOM_RIGHT float2(0.8, 0.8)
-
-
-void ogre_ssao_ps(
-    FragmentInput IN
-    ,uniform sampler2D geomMap : TEXUNIT0
-	,uniform sampler2D randMap : TEXUNIT1
-	,uniform float radius
-	,uniform float far
-	,uniform float4x4 clip_to_image_matrix 
-	,out float4 oColor : COLOR0)
-{
-
-    #define MAX_RAND_SAMPLES 14
-
-    const float3 RAND_SAMPLES[MAX_RAND_SAMPLES] =
-    {
-        float3(1, 0, 0),
-        float3(	-1, 0, 0),
-        float3(0, 1, 0),
-        float3(0, -1, 0),
-        float3(0, 0, 1),
-        float3(0, 0, -1),
-        normalize(float3(1, 1, 1)),
-        normalize(float3(-1, 1, 1)),
-        normalize(float3(1, -1, 1)),
-        normalize(float3(1, 1, -1)),
-        normalize(float3(-1, -1, 1)),
-        normalize(float3(-1, 1, -1)),
-        normalize(float3(1, -1, -1)),
-        normalize(float3(-1, -1, -1))
-    };
-
-
-
-	//if( is_in_area(TOP_LEFT, BOTTOM_RIGHT, IN.pixelPos))
-	//{		
-
-	    float3 randN = tex2D(randMap, IN.pixelPos * 24).xyz * 2.0 - 1.0;	
-
-		float4 current_pixel_data = tex2D(geomMap, IN.pixelPos);
-		float depth = current_pixel_data.r;
-		float3 normal = current_pixel_data.gba;
-
-		float3 viewPos = IN.eyeViewVector * depth;
-
-		float occlusion = 0.0f;
-		
-		// sampling neighbours
-		for(int i=0 ; i<6; i++)
-		{
-
-			float3 direction = reflect(RAND_SAMPLES[i], randN) + normal; 
-
-			float4 neighbour_coords = mul(clip_to_image_matrix,  float4(viewPos + direction * radius, 1));
-			neighbour_coords.xy /=  neighbour_coords.w;
-
-
-			float zd = saturate(far * (depth - tex2D(geomMap, neighbour_coords.xy).r));
-		
-	        occlusion += saturate(pow(1.0 - zd, 11) + zd);	
-			//occlusion += 1.0  / (1.0+zd*zd);
-		}
-
-		occlusion /= 6;
-		oColor=float4(occlusion, occlusion, occlusion, 1.0f);
-	//}
-//
-	//else
-	//{		
-		//oColor=float4( 1.0);
-	//}
-}

media/ssao/ogre_ssao.material

-
-// full screen quad with camera-to-pixel ray calculations
-
-vertex_program crytek_ssao_vs cg
-{
-    source       ogre_ssao.cg
-    profiles     vs_1_1 arbvp1
-    entry_point  ogre_ssao_vs
-    
-    default_params
-    {
-        param_named_auto wvp worldviewproj_matrix
-    }
-}
-
-fragment_program ogre_ssao_ps cg
-{
-    source       ogre_ssao.cg
-    entry_point  ogre_ssao_ps
-    profiles     ps_2_x arbfp1
-    default_params
-    {
-    }
-}
-
-
-material SSAO/Ogre/ssao
-{
-    technique
-    {
-        pass
-        {
-            vertex_program_ref ogre_ssao_vs
-            {
-            }
-
-            fragment_program_ref ogre_ssao_ps
-			{
-				param_named radius float 0.2125
-            }
-
-            texture_unit geomMap
-            {
-                tex_address_mode clamp
-                filtering none
-            }    
-
-            texture_unit randMap
-            {
-                texture random.png
-                filtering none
-				tex_coord_set 0
-				tex_address_mode wrap
-            }     
-      
-        }
-    }
-}
-
-material SSAO/Ogre/Modulate
-{
-    technique
-    {
-        pass
-        {
-            lighting off
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-        }
-    }
-}

media/ssao/shadow_caster.cg

-struct VIn
-{
-    float4 p    : POSITION;
-};
-
-struct VOut
-{
-    float4 p     : POSITION;
-    float4 depth : TEXCOORD0;
-};
-
-VOut shadow_caster_vs(
-    VIn IN,
-    uniform float4x4 pMat,
-    uniform float4x4 wvMat
-)
-{
-    VOut OUT;
-
-    // this is the view space position
-    float4 fp = mul(wvMat, IN.p);
-    // interpolate the whole position
-    OUT.depth = fp;
-    // and then output the projection space position
-    OUT.p = mul(pMat, fp);
-
-    return OUT;
-}
-
-struct PIn
-{
-    float4 depth : TEXCOORD0;
-};
-
-struct POut
-{
-    float4 color : COLOR;
-};
-
-POut shadow_caster_ps(PIn IN, uniform float far)
-{
-    POut OUT;
-
-    // get a per-pixel depth and depth squared
-    // (length of the view space position == distance from camera)
-    // (this is linear space, not post-projection quadratic space)
-    float d = length(IN.depth.xyz) / far;
-    OUT.color = float4(d, d * d, 1, 1);
-
-    return OUT;
-}

media/ssao/shadow_caster.material

-material shadow_caster
-{
-    technique
-    {
-        // all this will do is write depth and depth^2 to red and green
-        pass
-        {
-            vertex_program_ref shadow_caster_vs
-            {
-            }
-
-            fragment_program_ref shadow_caster_ps
-            {
-            }
-        }
-    }
-}

media/ssao/shadow_caster.program

-// declare the vertex shader (CG for the language)
-vertex_program shadow_caster_vs cg
-{
-    // source file
-    source shadow_caster.cg
-    // will run on vertex shader 1.1+
-    profiles vs_1_1 arbvp1
-    // entry function
-    entry_point shadow_caster_vs
-
-    default_params
-    {
-        // pMat == projection matrix
-        param_named_auto pMat projection_matrix
-        // wvMat == world * view matrix
-        param_named_auto wvMat worldview_matrix
-    }
-}
-
-// declare the fragment shader (CG for the language)
-fragment_program shadow_caster_ps cg
-{
-    // source file
-    source shadow_caster.cg
-    // will run on pixel shader 2.0 and up
-    profiles ps_2_0 arbfp1
-    // entry function
-    entry_point shadow_caster_ps
-
-    default_params
-    {
-        // light's range == camera far clip
-        param_named_auto far far_clip_distance
-    }
-}

media/ssao/ssao.cg

-struct VIn
-{
-    float4 p   : POSITION;
-    float3 n   : NORMAL;
-    float2 uv  : TEXCOORD0;
-};
-
-struct VOut
-{
-    float4 p   : POSITION;
-    float2 uv  : TEXCOORD0;
-    float3 ray : TEXCOORD1;
-};
-
-struct PIn
-{
-    float2 uv  : TEXCOORD0;
-    float3 ray : TEXCOORD1;
-};
-
-VOut ssao_vs(VIn IN, uniform float4x4 wvp, uniform float3 farCorner)
-{
-    VOut OUT;
-    OUT.p = mul(wvp, IN.p);
-    // clean up inaccuracies for the UV coords
-    float2 uv = sign(IN.p);
-    // convert to image space
-    uv = (float2(uv.x, -uv.y) + 1.0) * 0.5;
-    OUT.uv = uv;
-    // calculate the correct ray (modify XY parameters based on screen-space quad XY)
-    OUT.ray = farCorner * float3(sign(IN.p.xy), 1);
-    return OUT;
-}
-
-float3 computeZ(float2 xy)
-{
-    return float3(xy, sqrt(1.0 - dot(xy, xy)));
-}
-
-// for ps_3_0, we want to use tex2Dlod because it's faster
-ps_3_0 float4 TEX2DLOD(sampler2D map, float2 uv)
-{
-    return tex2Dlod(map, float4(uv.xy, 0, 0));
-}
-
-float4 TEX2DLOD(sampler2D map, float2 uv)
-{
-    return tex2D(map, uv);
-}
-
-float4 ssao_ps(
-    PIn IN,
-    uniform float4x4 ptMat,
-    uniform float far,
-    uniform sampler2D geomMap : TEXUNIT0,
-    uniform sampler2D randMap  : TEXUNIT1): COLOR0
-{
-    #define MAX_RAND_SAMPLES 14
-
-    const float3 RAND_SAMPLES[MAX_RAND_SAMPLES] =
-    {
-        float3(1, 0, 0),
-        float3(	-1, 0, 0),
-        float3(0, 1, 0),
-        float3(0, -1, 0),
-        float3(0, 0, 1),
-        float3(0, 0, -1),
-        normalize(float3(1, 1, 1)),
-        normalize(float3(-1, 1, 1)),
-        normalize(float3(1, -1, 1)),
-        normalize(float3(1, 1, -1)),
-        normalize(float3(-1, -1, 1)),
-        normalize(float3(-1, 1, -1)),
-        normalize(float3(1, -1, -1)),
-        normalize(float3(-1, -1, -1))
-    };
-
-    // constant expressin != const int :(
-    #define NUM_BASE_SAMPLES 6
-
-    // random normal lookup from a texture and expand to [-1..1]
-    float3 randN = TEX2DLOD(randMap, IN.uv * 24).xyz * 2.0 - 1.0;
-    float4 geom = TEX2DLOD(geomMap, IN.uv);
-    float depth = geom.x;
-
-    // IN.ray will be distorted slightly due to interpolation
-    // it should be normalized here
-    float3 viewPos = IN.ray * depth;
-
-    // by computing Z manually, we lose some accuracy under extreme angles
-    // considering this is just for bias, this loss is acceptable
-    float3 viewNorm = geom.yzw;//computeZ(geom.yz);
-
-    // accumulated occlusion factor
-    float occ = 0;
-    for (int i = 0; i < NUM_BASE_SAMPLES; ++i)
-    {
-        // reflected direction to move in for the sphere
-        // (based on random samples and a random texture sample)
-        // bias the random direction away from the normal
-        // this tends to minimize self occlusion
-        float3 randomDir = reflect(RAND_SAMPLES[i], randN) + viewNorm;
-
-        // move new view-space position back into texture space
-        #define RADIUS 0.2125
-        float4 nuv = mul(ptMat, float4(viewPos.xyz + randomDir * RADIUS, 1));
-        nuv.xy /= nuv.w;
-
-        // compute occlusion based on the (scaled) Z difference
-        float zd = saturate(far * (depth - TEX2DLOD(geomMap, nuv.xy).x));
-        // this is a sample occlusion function, you can always play with
-        // other ones, like 1.0 / (1.0 + zd * zd) and stuff
-        occ += saturate(pow(1.0 - zd, 11) + zd);
-    }
-    occ /= NUM_BASE_SAMPLES;
-
-    return float4(occ, occ, occ, 1);
-}
-
-#define NUM_BLUR_SAMPLES 8
-
-float4 ssaoBlurX_ps(float2 uv : TEXCOORD0,
-    uniform float4 invTexSize,
-    uniform sampler2D map : TEXUNIT0, uniform sampler2D geomMap : TEXUNIT1): COLOR0
-{
-//    return TEX2DLOD(ssaoMap, uv);
-    float2 o = float2(invTexSize.x, 0);
-    float4 sum = TEX2DLOD(map, uv) * (NUM_BLUR_SAMPLES + 1);
-    float denom = NUM_BLUR_SAMPLES + 1;
-    float4 geom = TEX2DLOD(geomMap, uv);
-    for (int i = 1; i <= NUM_BLUR_SAMPLES; ++i)
-    {
-        float2 nuv = uv + o * i;
-        float4 nGeom = TEX2DLOD(geomMap, nuv);
-        float coef = (NUM_BLUR_SAMPLES + 1 - i) * (dot(geom.yzw, nGeom.yzw) > 0.9);
-        sum += TEX2DLOD(map, nuv) * coef;
-        denom += coef;
-    }
-    for (int i = 1; i <= 4; ++i)
-    {
-        float2 nuv = uv + o * -i;
-        float4 nGeom = TEX2DLOD(geomMap, nuv);
-        float coef = (NUM_BLUR_SAMPLES + 1 - i) * (dot(geom.yzw, nGeom.yzw) > 0.9);
-        sum += TEX2DLOD(map, nuv) * coef;
-        denom += coef;
-    }
-    return sum / denom;
-}
-
-float4 ssaoBlurY_ps(float2 uv : TEXCOORD0,
-    uniform float4 invTexSize,
-    uniform sampler2D map : TEXUNIT0, uniform sampler2D geomMap : TEXUNIT1): COLOR0
-{
-//    return TEX2DLOD(map, uv);
-    float2 o = float2(0, invTexSize.y);
-    float4 sum = TEX2DLOD(map, uv) * (NUM_BLUR_SAMPLES + 1);
-    float denom = NUM_BLUR_SAMPLES + 1;
-    float4 geom = TEX2DLOD(geomMap, uv);
-    for (int i = 1; i <= NUM_BLUR_SAMPLES; ++i)
-    {
-        float2 nuv = uv + o * i;
-        float4 nGeom = TEX2DLOD(geomMap, nuv);
-        float coef = (NUM_BLUR_SAMPLES + 1 - i) * (dot(geom.yzw, nGeom.yzw) > 0.9);
-        sum += TEX2DLOD(map, nuv) * coef;
-        denom += coef;
-    }
-    for (int i = 1; i <= 4; ++i)
-    {
-        float2 nuv = uv + o * -i;
-        float4 nGeom = TEX2DLOD(geomMap, nuv);
-        float coef = (NUM_BLUR_SAMPLES + 1 - i) * (dot(geom.yzw, nGeom.yzw) > 0.9);
-        sum += TEX2DLOD(map, nuv) * coef;
-        denom += coef;
-    }
-    return sum / denom;
-}
-
-

media/ssao/ssao.compositor

-compositor ssao
+compositor SSAO/Compositor
 {
     technique
     {
-        texture geom target_width target_height PF_FLOAT16_RGBA
+        texture geom target_width target_height PF_FLOAT32_RGBA
         texture scene target_width target_height PF_R8G8B8A8
-        texture ssao target_width_scaled 0.5 target_height_scaled 0.5 PF_R8G8B8
-        texture ssaoBlurX target_width target_height PF_R8G8B8
-        texture ssaoBlurY target_width target_height PF_R8G8B8
+        //texture ssao target_width_scaled 0.5 target_height_scaled 0.5 PF_R8G8B8
+		texture ssao target_width target_height PF_R8G8B8
         texture final target_width target_height PF_R8G8B8A8
 
         // the scene we want to modulate
                 // our SSAO listener number
                 identifier 42
 
-                material ssao
-                // pass in the "geometry map"
+                material SSAO/Ogre/ssao
                 input 0 geom
             }
         }
 
-        target ssaoBlurX
-        {
-            input none
+   
 
-            pass clear
-            {
-            }
-
-            pass render_quad
-            {
-                identifier 43
-
-                material ssaoBlurX
-                input 0 ssao
-                input 1 geom
-            }
-        }
-
-        target ssaoBlurY
-        {
-            input none
-
-            pass clear
-            {
-            }
-
-            pass render_quad
-            {
-                identifier 43
-
-                material ssaoBlurY
-                input 0 ssaoBlurX
-                input 1 geom
-            }
-        }
-
-
-
-		target final
+		target output
 		{
             input none
 
             {
                 // just output something, for example, use a modulate
                 // material to just multiply the scene by the ssao
-                material modulate
+                material SSAO/Ogre/Modulate
                 input 0 scene
-                //input 1 ssaoBlurY
                 input 1 ssao
             }
         }
-
-
-        target_output
-        {
-			input none
-
-			pass render_quad
-			{
-				material debug_view
-				input 0 geom
-				input 1 ssao
-				input 2 scene
-				input 3 final
-			}
-		}
     }
 }

media/ssao/ssao.material

-
-// full screen quad with camera-to-pixel ray calculations
-
-vertex_program ssao_vs cg
-{
-    source ssao.cg
-    profiles vs_1_1 arbvp1
-    entry_point ssao_vs
-    default_params
-    {
-        param_named_auto wvp worldviewproj_matrix
-    }
-}
-
-fragment_program ssao_ps cg
-{
-    source ssao.cg
-    entry_point ssao_ps
-    // will run on anything with pixel shader 2.b and up
-    profiles ps_2_x arbfp1
-    default_params
-    {
-    }
-}
-
-fragment_program ssaoBlurX_ps cg
-{
-    source ssao.cg
-    entry_point ssaoBlurX_ps
-    profiles ps_2_x arbfp1
-    default_params
-    {
-        param_named_auto invTexSize inverse_texture_size 0
-    }
-}
-
-fragment_program ssaoBlurY_ps cg
-{
-    source ssao.cg
-    entry_point ssaoBlurY_ps
-    profiles ps_2_x arbfp1
-    default_params
-    {
-        param_named_auto invTexSize inverse_texture_size 0
-    }
-}
-
-material ssao
-{
-    technique
-    {
-        pass
-        {
-            vertex_program_ref ssao_vs
-            {
-            }
-
-            fragment_program_ref ssao_ps
-            {
-            }
-
-            texture_unit geomMap
-            {
-                tex_address_mode clamp
-                filtering bilinear
-            }
-
-            texture_unit randMap
-            {
-                texture random.png
-                filtering none
-            }
-        }
-    }
-}
-
-material ssaoBlurX
-{
-    technique
-    {
-        pass
-        {
-            fragment_program_ref ssaoBlurX_ps
-            {
-            }
-
-            texture_unit map
-            {
-                tex_address_mode clamp
-                filtering bilinear
-            }
-
-            texture_unit geomMap
-            {
-                tex_address_mode clamp
-                filtering bilinear
-            }
-        }
-    }
-}
-
-material ssaoBlurY
-{
-    technique
-    {
-        pass
-        {
-            fragment_program_ref ssaoBlurY_ps
-            {
-            }
-
-            texture_unit map
-            {
-                tex_address_mode clamp
-                filtering bilinear
-            }
-
-            texture_unit geomMap
-            {
-                tex_address_mode clamp
-                filtering bilinear
-            }
-        }
-    }
-}
-
-material modulate
-{
-    technique
-    {
-        pass
-        {
-            lighting off
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-
-            texture_unit
-            {
-                texture white.bmp
-                filtering bilinear
-            }
-        }
-    }
-}

media/ssao/ssao_with_debug.compositor

+compositor SSAO/DebugCompositor
+{
+    technique
+    {
+        texture geom target_width target_height PF_FLOAT32_RGBA
+        texture scene target_width target_height PF_R8G8B8A8
+        //texture ssao target_width_scaled 0.5 target_height_scaled 0.5 PF_R8G8B8
+		texture ssao target_width target_height PF_R8G8B8
+        texture final target_width target_height PF_R8G8B8A8
+
+        // the scene we want to modulate
+        target scene
+        {
+            input previous
+        }
+
+        // the normals + depth render
+        // feel free to play with it
+        // right now it uses a 64-bit "fat" buffer that contains
+        // unnormalized depth and XYZ normals
+        target geom
+        {
+            input none
+            material_scheme geom
+
+            pass clear
+            {
+            }
+
+            pass render_scene
+            {
+            }
+        }
+
+        target ssao
+        {
+            input none
+
+            pass clear
+            {
+            }
+
+            pass render_quad
+            {
+                // our SSAO listener number
+                identifier 42
+
+                material SSAO/Ogre/ssao
+                input 0 geom
+            }
+        }
+
+   
+
+		target final
+		{
+            input none
+
+            pass render_quad
+            {
+                // just output something, for example, use a modulate
+                // material to just multiply the scene by the ssao
+                material SSAO/Ogre/Modulate
+                input 0 scene
+                input 1 ssao
+            }
+        }
+
+
+        target_output
+        {
+			input none
+
+			pass render_quad
+			{
+				material debug_view
+				input 0 geom
+				input 1 ssao
+				input 2 scene
+				input 3 final
+			}
+		}
+    }
+}

ulb-building-visu/OgreApplication.cpp

 {
     Ogre::Viewport *viewport = mWindow->getViewport(0);
     assert(viewport);
-    mSSAOCompositor = Ogre::CompositorManager::getSingletonPtr()->addCompositor(viewport, "CrytekSSAO/Compositor");
+    mSSAOCompositor = Ogre::CompositorManager::getSingletonPtr()->addCompositor(viewport, "SSAO/DebugCompositor");
  
     if(!mSSAOCompositor)
         OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Failed to create ssao compositor", "OgreApplication::_initSSAO");

ulb-building-visu/ULBBuildingApp.cpp

     Ogre::Entity *ent = mSceneMgr->createEntity(entityName, _name+".mesh");
     Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode(ent->getName()+"Node", _pos);
 
-	//*e*/nt->setMaterialName("Shading/PerVertex/Gooch_noculling");
     //ent->setMaterialName("blue");
-    ent->setMaterialName("Objects/Cube");
+    ent->setMaterialName("SSAO/DiffuseLight_GBuffer");
     node->attachObject(ent);
 
     mScenePairs.push_back(ULBBuildingApp::ScenePair(ent, node));
 
-    //EdgeGeometryBuilder *edges = new EdgeGeometryBuilder("static edges"+ent->getName(), mLog, mSceneMgr);
-    //edges->begin();
-    //edges->addEdgesForEntity(ent);
-    //edges->end();
-
-    //edges->attachToSceneNode(node);
-    //mEdges.push_back(edges);
-
     return node;
 }
 //-----------------------------------------------------------------------------