//Postfilter generating the GBuffer
compositor DeferredShading/GBuffer
{
	technique
	{
		// temporary textures
		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
			{
				//These values are synchronized with the code
				first_render_queue 10
				last_render_queue  79	
			}
		}
	}
}

//Postfilter lighting the scene using the GBuffer
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 the objects that skipped rendering into the gbuffer
			pass render_scene
			{
				material_scheme NoGBuffer
				first_render_queue 10
				last_render_queue 79
			}
			
			//Render the post-GBuffer render queue objects
			pass render_scene
			{
				//This value is synchronized with the code
				first_render_queue 80
			}
		}
	}
}

// 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
			}
        }
	}
}
