///////////////////////////////////////////////////////////////////////////
/// Declare CG shaders for casters
///////////////////////////////////////////////////////////////////////////

// declare the fragment shader (CG for the language)
fragment_program Ogre/RTShader/shadow_caster_ps_cg cg
{
	// source file
	source HardwareSkinningShadow.cg
	// will run on pixel shader 2.0+
	profiles ps_2_0 arbfp1
	// entry function
	entry_point shadow_caster_ps
 	default_params
	{
		
	}
}

vertex_program Ogre/RTShader/shadow_caster_skinning_1weight_vs cg
{
	source HardwareSkinningShadow.cg
	//will run on 3 to accommodate the amount of registers
	profiles vs_3_0 vp40 arbvp1
	entry_point shadow_caster_skinning_1weight_vs

	default_params
	{
		param_named_auto viewProjectionMatrix viewproj_matrix	
		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
	}
}

vertex_program Ogre/RTShader/shadow_caster_skinning_2weight_vs_cg cg
{
	source HardwareSkinningShadow.cg
	//will run on 3 to accommodate the amount of registers
	profiles vs_3_0 vp40 arbvp1
	entry_point shadow_caster_skinning_2weight_vs

	default_params
	{
		param_named_auto viewProjectionMatrix viewproj_matrix	
		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
	}
}

vertex_program Ogre/RTShader/shadow_caster_skinning_3weight_vs cg
{
	source HardwareSkinningShadow.cg
	//will run on 3 to accommodate the amount of registers
	profiles vs_3_0 vp40 arbvp1
	entry_point shadow_caster_skinning_3weight_vs

	default_params
	{
		param_named_auto viewProjectionMatrix viewproj_matrix	
		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
	}
}


vertex_program Ogre/RTShader/shadow_caster_skinning_4weight_vs cg
{
	source HardwareSkinningShadow.cg
	//will run on 3 to accommodate the amount of registers
	profiles vs_3_0 vp40 arbvp1
	entry_point shadow_caster_skinning_4weight_vs

	default_params
	{
		param_named_auto viewProjectionMatrix viewproj_matrix	
		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
	}
}

///////////////////////////////////////////////////////////////////////////
/// Declare GLSL shaders for casters
///////////////////////////////////////////////////////////////////////////

fragment_program Ogre/RTShader/shadow_caster_ps_glsl glsl
{
	source HardwareSkinningShadow_Fragment.glsl
}

vertex_program Ogre/RTShader/shadow_caster_skinning_2weight_vs_glsl glsl
{
	source HardwareSkinningShadow_TwoWeights.glsl
	includes_skeletal_animation true

	default_params
	{
		param_named_auto viewProjectionMatrix viewproj_matrix	
		param_named_auto worldMatrix3x4Array world_matrix_array_3x4
		param_named_auto ambient ambient_light_colour
	}
}

///////////////////////////////////////////////////////////////////////////
/// Unified program declarations
///////////////////////////////////////////////////////////////////////////
fragment_program Ogre/RTShader/shadow_caster_ps unified
{
	delegate Ogre/RTShader/shadow_caster_ps_glsl
	delegate Ogre/RTShader/shadow_caster_ps_cg
}

vertex_program Ogre/RTShader/shadow_caster_skinning_2weight_vs unified
{
	delegate Ogre/RTShader/shadow_caster_skinning_2weight_vs_glsl
	delegate Ogre/RTShader/shadow_caster_skinning_2weight_vs_cg
}

///////////////////////////////////////////////////////////////////////////
/// Declare materials for casters and casters with hardware skinning
///////////////////////////////////////////////////////////////////////////

material Ogre/RTShader/shadow_caster_skinning_1weight
{
	technique
	{
		// all this will do is write depth and depth˛ to red and green
		pass
		{
			vertex_program_ref Ogre/RTShader/shadow_caster_skinning_1weight_vs
			{				
			}

			fragment_program_ref Ogre/RTShader/shadow_caster_ps
			{				
			}
		}
	}
}


material Ogre/RTShader/shadow_caster_skinning_2weight
{
	technique
	{
		// all this will do is write depth and depth˛ to red and green
		pass
		{
			vertex_program_ref Ogre/RTShader/shadow_caster_skinning_2weight_vs
			{				
			}

			fragment_program_ref Ogre/RTShader/shadow_caster_ps
			{				
			}
		}
	}
}


material Ogre/RTShader/shadow_caster_skinning_3weight
{
	technique
	{
		// all this will do is write depth and depth˛ to red and green
		pass
		{
			vertex_program_ref Ogre/RTShader/shadow_caster_skinning_3weight_vs
			{				
			}

			fragment_program_ref Ogre/RTShader/shadow_caster_ps
			{				
			}
		}
	}
}


material Ogre/RTShader/shadow_caster_skinning_4weight
{
	technique
	{
		// all this will do is write depth and depth˛ to red and green
		pass
		{
			vertex_program_ref Ogre/RTShader/shadow_caster_skinning_4weight_vs
			{				
			}

			fragment_program_ref Ogre/RTShader/shadow_caster_ps
			{				
			}
		}
	}
}

///////////////////////////////////////////////////////////////////////////
/// Declare programs for recievers
///////////////////////////////////////////////////////////////////////////


vertex_program Ogre/RTShader/shadow_receiver_vs cg
{
	source HardwareSkinningShadow.cg
	profiles vs_1_1 arbvp1
	entry_point shadow_receiver_vs

	default_params
	{				
		param_named_auto worldViewProjMatrix worldviewproj_matrix
	}
}

fragment_program Ogre/RTShader/shadow_receiver_ps cg
{
	source HardwareSkinningShadow.cg
	profiles ps_2_x arbfp1
	entry_point shadow_receiver_ps

	default_params
	{				
//		param_named_auto shadowColor		shadow_colour 					
	}
}

material Ogre/RTShader/shadow_receiver
{
	technique
	{
		pass
		{
			ambient 1 1 1 1
			diffuse 1 1 1 1
			
			depth_bias 1.25 1.15
			lighting off
			fog_override true none
			depth_write off
			
			vertex_program_ref Ogre/RTShader/shadow_receiver_vs 
			{
				param_named texViewProjMatrix0 float4x4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
				param_named texViewProjMatrix1 float4x4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
				param_named texViewProjMatrix2 float4x4	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0							
			}
			fragment_program_ref Ogre/RTShader/shadow_receiver_ps 
			{
				param_named pssmSplitPoints	float3	0 0 0							
			}

			texture_unit shadow_tex0
			{				
				tex_address_mode border
				tex_border_colour 1.0 1.0 1.0 1.0
			}
			texture_unit shadow_tex1
			{				
				tex_address_mode border
				tex_border_colour 1.0 1.0 1.0 1.0
			}
			texture_unit shadow_tex2
			{				
				tex_address_mode border
				tex_border_colour 1.0 1.0 1.0 1.0
			}			
		}
	}
}
