//Postfilter generating the GBuffer
//! [gbuffer]
compositor DeferredShading/GBuffer
{
	technique
	{
		// GBuffer textures
		// PF_BYTE_RGBA would be sufficient for color, but D3D9 requires same bitdepth for all MRTs
		texture mrt_output target_width target_height PF_FLOAT16_RGBA PF_FLOAT16_RGBA chain_scope
		
		target mrt_output
		{
			input none
			pass clear
			{
			}
			
			shadows off
			material_scheme GBuffer
			
			// everything but the lights and their meshes
			// could do this with something like a visibility mask too
			pass render_scene
			{
				first_render_queue 10
				last_render_queue  80
			}
		}
	}
}
//! [gbuffer]

//Postfilter lighting the scene using the GBuffer
//! [showlit]
compositor DeferredShading/ShowLit
{

	technique
	{
		//Reference the main Gbuffer texture
		texture_ref mrt_output DeferredShading/GBuffer mrt_output
		
        target_output
        {
			input none
			//We will dispatch the shadow texture rendering ourselves
			shadows off
			
			pass clear
			{
				
			}
			
			// render skies and other pre-gbuffer objects
			pass render_scene
			{
				first_render_queue 1
				last_render_queue  9			
			}
			
			//Render the lights and their meshes
			pass render_custom DeferredLight
			{
				input 0 mrt_output 0
				input 1 mrt_output 1
			}
			
			//Render transparents and other post-GBuffer render queue objects
			pass render_scene
			{
				first_render_queue 90
			}
		}
	}
}
//! [showlit]

// Postfilter that shows the colour channel
compositor DeferredShading/ShowColour
{
	technique 
	{
		//Reference the main Gbuffer texture
		texture_ref mrt_output DeferredShading/GBuffer mrt_output
		
		target_output
        {
			input none
			
			pass render_quad
			{
				material DeferredShading/Post/ShowColour
				input 0 mrt_output 0
				input 1 mrt_output 1
			}
        }
	}
}

// Postfilter that shows the normal channel
compositor DeferredShading/ShowNormals
{
	technique 
	{
		//Reference the main Gbuffer texture
		texture_ref mrt_output DeferredShading/GBuffer mrt_output
		
		target_output
        {
			input none
			
			pass render_quad
			{
				material DeferredShading/Post/ShowNormal
				input 0 mrt_output 0
				input 1 mrt_output 1
			}
        }
	}
}

// Postfilter that shows the depth and specular channel
compositor DeferredShading/ShowDepthSpecular
{
	technique 
	{
		//Reference the main Gbuffer texture
		texture_ref mrt_output DeferredShading/GBuffer mrt_output

		target_output
        {
			input none
			
			pass render_quad
			{
				material DeferredShading/Post/ShowDS
				input 0 mrt_output 0
				input 1 mrt_output 1
			}
        }
	}
}
