//Dark Sylinc's Bloom
compositor Bloom
{
    technique
    {
        // Temporary textures
        texture rt_output target_width target_height PF_R8G8B8
        texture rt0 target_width_scaled 0.25 target_height_scaled 0.25 PF_R8G8B8
        texture rt1 target_width_scaled 0.25 target_height_scaled 0.25 PF_R8G8B8

        target rt_output
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target rt0
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BrightPass2
                input 0 rt_output
            }
        }

        target rt1
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BlurV
                input 0 rt0
            }
        }

        target rt0
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BlurH
                input 0 rt1
            }
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BloomBlend2
                input 0 rt_output
                input 1 rt0
            }
        }
    }
}

compositor Glass
{
    technique
    {
        texture rt0 target_width target_height PF_R8G8B8

        target rt0 { input previous }

        target_output
        {
            // Start with clear output
            input none

            pass render_quad
            {
                material Ogre/Compositor/GlassPass
                input 0 rt0
            }
        }
    }
}

compositor "Old TV"
{
    technique
    {
        texture rt0 target_width target_height PF_R8G8B8

        // render scene to a texture
        target rt0 { input previous }

        target_output
        {
            // Start with clear output
            input none

            pass render_quad
            {
                // convert the previous render target to a black and white image, add some noise, distort it,
                // then render to scene aligned quad
                material Ogre/Compositor/OldTV
                input 0 rt0
            }
        }
    }
}


// Black and white effect
compositor B&W
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BlackAndWhite
                input 0 rt0
            }
        }
    }
}

//compositor DOF // based on Blur but final pass does depth of field
//{
//    technique
//    {
//        // Temporary textures
//        texture rt0 target_width target_height PF_A8R8G8B8
//        texture rt1 target_width target_height PF_A8R8G8B8
//
//        target rt1
//        {
//            // Render output from previous compositor (or original scene)
//            input previous
//        }
//
//        target rt0
//        {
//            // Start with clear texture
//            input none
//            // Vertical blur pass
//            pass render_quad
//            {
//                // Renders a fullscreen quad with a material
//                material Ogre/Compositor/DOF_Blur0
//                input 0 rt1
//            }
//        }
//
//        target rt1
//        {
//            // Start with clear texture
//            input none
//            // Horizontal blur pass
//            pass render_quad
//            {
//                // Renders a fullscreen quad with a material
//                material Ogre/Compositor/DOF_Blur1
//                input 0 rt0
//            }
//        }
//
//        target_output
//        {
//            // Start with clear output
//            input none
//            // Draw a fullscreen quad
//            pass render_quad
//            {
//                // Renders a fullscreen quad with a material
//                material Ogre/Compositor/DOF_Blend
//                input 0 rt0
//                input 1 rt1
//            }
//        }
//    }
//}

// Embossed (fake bump) effect
compositor Embossed
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/Embossed
                input 0 rt0
            }
        }
    }
}

// SharpenEdges
compositor "Sharpen Edges"
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/SharpenEdges
                input 0 rt0
            }
        }
    }
}

// Invert
compositor Invert
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/Invert
                input 0 rt0
            }
        }
    }
}

// Posterize
compositor Posterize
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/Posterize
                input 0 rt0
            }
        }
    }
}

// Laplace
compositor Laplace
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/Laplace
                input 0 rt0
            }
        }
    }
}

// Tiling
compositor Tiling
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/Tiling
                input 0 rt0
            }
        }
    }
}

// Old Movie
compositor "Old Movie"
{
    technique
    {
        // Temporary textures
        texture rt0 target_width target_height PF_A8R8G8B8

        target rt0
        {
            // Render output from previous compositor (or original scene)
            input previous
        }

        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the black and white image
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/OldMovie
                input 0 rt0
            }
        }
    }
}

// HDR
compositor HDR
{
	// floating point only for now
	technique
	{
		compositor_logic HDR
		
        // Temporary textures
		// Fullsize HDR render target, used as tone mapping source
        texture rt_full target_width target_height PF_FLOAT16_RGB
		// Targets used for luminance evaluation (3x3 downsample, point filtering)
		texture rt_lum0 1 1 PF_FLOAT16_RGB
		texture rt_lum1 4 4 PF_FLOAT16_RGB
		texture rt_lum2 16 16 PF_FLOAT16_RGB
		texture rt_lum3 64 64 PF_FLOAT16_RGB
		texture rt_lum4 128 128 PF_FLOAT16_RGB
		// Bright-pass filtered target (tone mapped)
		texture rt_brightpass 128 128 PF_R8G8B8
		// Bloom filter targets
		texture rt_bloom0 128 128 PF_R8G8B8
		texture rt_bloom1 128 128 PF_R8G8B8


		target rt_full
		{
			// No input, render differently
			input none

			// Use float target HDR material scheme (unclamped shaders)
			material_scheme HDR

			pass clear
			{
			}

			pass render_scene
			{
			}

		}

		// Downsample the original HDR scene to extract luminence value
		target rt_lum4
		{
            input none
            pass render_quad
            {
                // Downsample using a 2x2 filter and convert to greyscale
                material Ogre/Compositor/HDR/Downsample2x2Luminence
                input 0 rt_full
                identifier 994
            }
		}
		target rt_lum3
		{
            input none
            pass render_quad
            {
				// Downsample using a 3x3 filter
                material Ogre/Compositor/HDR/Downsample3x3
                input 0 rt_lum4
                identifier 993
            }
		}
		target rt_lum2
		{
            input none
            pass render_quad
            {
                // Downsample using a 3x3 filter
                material Ogre/Compositor/HDR/Downsample3x3
                input 0 rt_lum3
                identifier 992
            }
		}
		target rt_lum1
		{
            input none
            pass render_quad
            {
                // Downsample using a 3x3 filter
                material Ogre/Compositor/HDR/Downsample3x3
                input 0 rt_lum2
                identifier 991
            }
		}
		target rt_lum0
		{
            input none
            pass render_quad
            {
                // Downsample using a 3x3 filter
                material Ogre/Compositor/HDR/Downsample3x3
                input 0 rt_lum1
                identifier 990
            }
		}


		target rt_brightpass
		{
            input none
            pass render_quad
            {
                // Downsample using a 3x3 filter, hi-pass and tone map
                material Ogre/Compositor/HDR/Downsample3x3Brightpass
                input 0 rt_full
		        input 1 rt_lum0
				identifier 800
            }
		}

		target rt_bloom1
		{
			input none
			pass render_quad
			{
				// Blur horizontally
				material Ogre/Compositor/HDR/GaussianBloom
				input 0 rt_brightpass
				identifier 701
			}
		}
		target rt_bloom0
		{
			input none
			pass render_quad
			{
				// Blur horizontally
				material Ogre/Compositor/HDR/GaussianBloom
				input 0 rt_bloom1
				identifier 700
			}
		}


		// Final output combines tone mapping of the original scene, with an
		// exposure setting passed in as a GPU parameter, and an additive bloom
		// effect
		target_output
		{
			input none
			pass render_quad
			{
				material Ogre/Compositor/HDR/ToneMapping
				input 0 rt_full
				input 1 rt_bloom0
				input 2 rt_lum0
			}
		}


	}

}


// Gaussian blur effect
compositor "Gaussian Blur"
{
    technique
    {
		compositor_logic GaussianBlur
		
        // 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
            }
        }
    }
}

// Testing MRT
compositor TestMRT
{
	technique
	{
		// temporary texture (MRT!)
		// 4 sub-surfaces, all 32-bit
		texture mrt0 target_width target_height PF_A8R8G8B8 PF_A8R8G8B8 PF_A8R8G8B8 PF_A8R8G8B8

        target mrt0
        {
            // Render scene using MRT-compatible material scheme
          input none
			material_scheme MRT			
			pass clear
			{
				
			}
			pass render_scene
			{
			}
        }

		target_output
		{
			input none
            pass render_quad
            {
                // Renders a fullscreen quad 
				material Ogre/MRTtest/quad
				// bind 4 MRT surfaces as texture inputs
                input 0 mrt0 0
                input 1 mrt0 1
				input 2 mrt0 2
                input 3 mrt0 3
          }
			
		}

	}
}

//Radial blur effect
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
            }
        }
    }
}

// ASCII effect
compositor ASCII
{
    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/ASCII
                input 0 rt0
            }
        }
    }
}

// Halftone effect
compositor Halftone
{
    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/Halftone
                input 0 rt0
            }
        }
    }
}

//Night Vision effect
compositor "Night Vision"
{
    technique
    {
        texture rt0 target_width target_height PF_A8R8G8B8
	
	target rt0
	{
	    input previous
	}
	
	target_output
	{
	    input none
	   
	    pass render_quad
	    {
	    	material Ogre/Compositor/NightVision
	    	input 0 rt0
	    }
	}
    }
}

//Dither effect
compositor Dither
{
    technique
    {
        texture rt0 target_width target_height PF_A8R8G8B8
	
	target rt0
	{
	    input previous
	}
	
	target_output
	{
	    input none
	   
	    pass render_quad
	    {
	    	material Ogre/Compositor/Dither
	    	input 0 rt0
	    }
	}
    }
}

