Commits

Murat Sari committed dad2d33

SSAO: Add sample compositor which shows how to modulate occulsion map
with the orginal scene

  • Participants
  • Parent commits 9cd3c28
  • Branches v1-9

Comments (0)

Files changed (6)

Samples/Media/materials/scripts/SSAO/Modulate.cg

+void Modulate_fp
+(
+    in float2 uv: TEXCOORD0, 
+    
+    out float4 oColor0 : COLOR0,
+
+    uniform sampler scene: register(s0),
+    uniform sampler occlusion : register(s1)
+)
+{
+    oColor0 = float4((tex2D(scene, uv) * tex2D(occlusion, uv)).rgb, 1);
+}

Samples/Media/materials/scripts/SSAO/Modulate.material

+fragment_program SSAO/Post/Modulate_fp_hlsl hlsl
+{
+    source Modulate.cg
+    entry_point Modulate_fp
+    target ps_3_0 
+}
+
+fragment_program SSAO/Post/Modulate_fp_cg cg
+{
+    source Modulate.cg
+    entry_point Modulate_fp
+    profiles ps_3_0 arbfp1
+}
+
+fragment_program SSAO/Post/Modulate_fp_glsl glsl
+{
+    source ModulateFP.glsl
+    	
+	default_params
+	{
+		param_named scene int 0
+		param_named occlusion int 1
+	}
+}
+
+fragment_program SSAO/Post/Modulate_fp unified
+{
+	delegate SSAO/Post/Modulate_fp_glsl
+	delegate SSAO/Post/Modulate_fp_hlsl
+	delegate SSAO/Post/Modulate_fp_cg 
+}
+
+material SSAO/Post/Modulate
+{
+    technique
+    {
+        pass
+        {
+            lighting off
+
+			vertex_program_ref Ogre/Compositor/StdQuad_vp {}
+            fragment_program_ref SSAO/Post/Modulate_fp {}
+			
+            texture_unit
+            {
+				content_type compositor SSAO/GBuffer scene
+                filtering bilinear
+            }
+
+			texture_unit
+            {
+                content_type compositor SSAO/GBuffer occlusion
+                tex_address_mode clamp
+                filtering bilinear
+            }
+        }
+    }
+}

Samples/Media/materials/scripts/SSAO/ModulateFP.glsl

+#version 120
+varying vec2 uv;
+
+uniform sampler2D scene;
+uniform sampler2D occlusion;
+	
+void main()
+{
+    gl_FragColor = vec4((texture2D(scene, uv) * texture2D(occlusion, uv)).rgb, 1.0);
+}

Samples/Media/materials/scripts/SSAO/SSAO.compositor

         // ---------------------------------------------------------------------
         texture mrt target_width target_height PF_FLOAT32_RGBA PF_FLOAT32_RGBA PF_FLOAT32_RGBA chain_scope
         texture occlusion target_width target_height PF_FLOAT32_RGBA chain_scope
+		texture scene target_width target_height PF_R8G8B8A8 chain_scope
+		
+		// the scene we want to modulate
+        target scene
+        {
+            input previous
+        }
 		
         target mrt
         {

Samples/Media/materials/scripts/SSAO/SSAOPost.compositor

+compositor SSAO/Post/Modulate
+{
+    technique 
+    {
+        target_output
+        {
+            input none
+            
+            pass render_quad
+            {
+                material SSAO/Post/Modulate
+            }
+        }
+    }
+}
+
 compositor SSAO/Post/NoFilter
 {
     technique 

Samples/SSAO/include/SSAO.h

         mCompositorNames.push_back("SSAO/ShowViewPos");
         
         mPostNames.push_back("SSAO/Post/NoFilter");
+        mPostNames.push_back("SSAO/Post/Modulate");
         mPostNames.push_back("SSAO/Post/CrossBilateralFilter");
         mPostNames.push_back("SSAO/Post/SmartBoxFilter");
         mPostNames.push_back("SSAO/Post/BoxFilter");