// -------------------------------
// Cel Shading Section
// -------------------------------
vertex_program Ogre/CelShadingVP cg
{
	source Example_CelShading.cg
	entry_point main_vp
	profiles vs_1_1 arbvp1

	default_params
	{
		param_named_auto lightPosition light_position_object_space 0
		param_named_auto eyePosition camera_position_object_space
		param_named_auto worldViewProj worldviewproj_matrix
		param_named shininess float 10 
	}
}

fragment_program Ogre/CelShadingFP cg
{
	source Example_CelShading.cg
	entry_point main_fp
	profiles ps_1_1 arbfp1 fp20
}


material Examples/CelShading
{
	technique
	{
		pass
		{
			vertex_program_ref Ogre/CelShadingVP
			{
				// map shininess from custom renderable param 1
				param_named_auto shininess custom 1
			}
			fragment_program_ref Ogre/CelShadingFP
			{
				// map diffuse from custom renderable param 2
				param_named_auto diffuse custom 2
				// map specular from custom renderable param 2
				param_named_auto specular custom 3
			}
			texture_unit
			{
				texture cel_shading_diffuse.png 1d
				tex_address_mode clamp
				filtering none
			}
			texture_unit
			{
				texture cel_shading_specular.png 1d
				tex_address_mode clamp
				filtering none
			}
			texture_unit
			{
				texture cel_shading_edge.png 1d
				tex_address_mode clamp
				filtering none
			}
		}
	}
	
}



//------------------------
// Bump mapping section
//------------------------

// Bump map vertex program, support for this is required
vertex_program Examples/BumpMapVP cg
{
	source Example_BumpMapping.cg
	entry_point main_vp
	profiles vs_1_1 arbvp1
}

// Bump map vertex program, with tangent parity support for this is required
vertex_program Examples/BumpMapVPTangentParity cg
{
	source Example_BumpMapping.cg
	entry_point main_vp
	profiles vs_1_1 arbvp1
	compile_arguments -DTANGENTS_HAVE_PARITY=1
}

// Bump map fragment program, support for this is optional
fragment_program Examples/BumpMapFP cg
{
	source Example_BumpMapping.cg
	entry_point main_fp
	profiles ps_2_0 arbfp1 fp20
}

// Bump map vertex program shadow receiver
vertex_program Examples/BumpMapVPShadowRcv cg
{
	source Example_BumpMapping.cg
	entry_point main_shadowreceiver_vp
	profiles vs_1_1 arbvp1
}
// Bump map fragment program shadow receiver, support for this is optional
fragment_program Examples/BumpMapFPShadowRcv cg
{
	source Example_BumpMapping.cg
	entry_point main_shadowreceiver_fp
	profiles ps_2_0 arbfp1 fp20
}


// Bump map with specular vertex program, support for this is required
vertex_program Examples/BumpMapVPSpecular cg
{
	source Example_BumpMapping.cg
	entry_point specular_vp
	profiles vs_1_1 arbvp1
}

// Bump map fragment program, support for this is optional
fragment_program Examples/BumpMapFPSpecular cg
{
	source Example_BumpMapping.cg
	entry_point specular_fp
	profiles ps_2_0 arbfp1 fp20
}


// Any number of lights, diffuse
material Examples/BumpMapping/MultiLight
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Base ambient pass
		pass ambient
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			ambient 1 1 1
			diffuse 0 0 0 
			specular 0 0 0 0 
			// Really basic vertex program
			// NB we don't use fixed function here because GL does not like
			// mixing fixed function and vertex programs, depth fighting can
			// be an issue
			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
			{
				param_named_auto worldViewProj worldviewproj_matrix
				param_named_auto ambient ambient_light_colour
			}
			
		}
		// Now do the lighting pass
		// NB we don't do decal texture here because this is repeated per light
		pass perlight
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			ambient 0 0 0 
			
			// do this for each light
			iteration once_per_light

		
			scene_blend add

			// Vertex program reference
			vertex_program_ref Examples/BumpMapVP
			{
				param_named_auto lightPosition light_position_object_space 0
				param_named_auto worldViewProj worldviewproj_matrix
			}

			// Fragment program
			fragment_program_ref Examples/BumpMapFP
			{
				param_named_auto lightDiffuse light_diffuse_colour 0 
			}

			// texture shadow receiver program
			shadow_receiver_vertex_program_ref Examples/BumpMapVPShadowRcv
			{
				param_named_auto lightPosition light_position_object_space 0
				param_named_auto worldViewProj worldviewproj_matrix
				param_named_auto worldMatrix world_matrix
				param_named_auto texViewProj texture_viewproj_matrix
			}
			// Additive texture shadow receiver program
			shadow_receiver_fragment_program_ref Examples/BumpMapFPShadowRcv
			{
				param_named_auto lightDiffuse light_diffuse_colour 0 
			}
			
			// Base bump map
			texture_unit normalmap
			{
				texture NMBumpsOut.png
				colour_op replace
			}
		}
		
		// Decal pass
		pass decal
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			lighting off
			// Really basic vertex program
			// NB we don't use fixed function here because GL does not like
			// mixing fixed function and vertex programs, depth fighting can
			// be an issue
			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
			{
				param_named_auto worldViewProj worldviewproj_matrix
				param_named ambient float4 1 1 1 1
			}
			scene_blend dest_colour zero
			texture_unit decalmap
			{
				texture RustedMetal.jpg 
			}
			
		}
	}


}

// Any number of lights, diffuse and specular
material Examples/BumpMapping/MultiLightSpecular : Examples/BumpMapping/MultiLight
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Overlay nothing new onto the old ambient pass
		pass ambient
		{
		}
		// Now do the lighting pass
		// NB we don't do decal texture here because this is repeated per light
		pass perlight
		{

			// Vertex program reference
			vertex_program_ref Examples/BumpMapVPSpecular
			{
				param_named_auto lightPosition light_position_object_space 0
				param_named_auto eyePosition camera_position_object_space
				param_named_auto worldViewProj worldviewproj_matrix
			}

			// Fragment program
			fragment_program_ref Examples/BumpMapFPSpecular
			{
				param_named_auto lightDiffuse light_diffuse_colour 0 
				param_named_auto lightSpecular light_specular_colour 0
			}
			
		}
		
	}

}

// Any number of lights, diffuse only, correct for tangent parity
material Examples/BumpMapping/MultiLightTangentParity : Examples/BumpMapping/MultiLight
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Overlay nothing new onto the old ambient pass
		pass ambient
		{
		}
		// Now do the lighting pass
		// NB we don't do decal texture here because this is repeated per light
		pass perlight
		{

			// Just change the vertex program
			vertex_program_ref Examples/BumpMapVPTangentParity
			{
				param_named_auto lightPosition light_position_object_space 0
				param_named_auto worldViewProj worldviewproj_matrix
			}

			
		}
		
	}

}

//---------------------------
// Projective texture section
//---------------------------


vertex_program Examples/TexProjectionVP cg
{
	source Example_Projection.cg
	entry_point generalPurposeProjection_vp
	profiles vs_1_1 arbvp1
}

fragment_program Examples/TexProjectionFP cg
{
	source Example_Projection.cg
	entry_point generalPurposeProjection_fp
	// sorry, ps_1_1 can't do this, fp20 can though
	profiles ps_2_0 arbfp1 fp20
}

material Examples/GeneralTexProjection
{
	technique
	{
		pass 
		{
			
			vertex_program_ref Examples/TexProjectionVP
			{
				param_named_auto worldViewProjMatrix worldviewproj_matrix
				param_named_auto worldMatrix world_matrix
				// You'll need to update the tex projection, I suggest using
				// the Frustum class
				//param_named_auto texWorldViewProj worldviewproj_matrix
			}
			fragment_program_ref Examples/TexProjectionFP
			{
				// no params
			}
			texture_unit
			{
				// Project the OGRE logo
				texture ogrelogo.png
				tex_address_mode clamp
			}
		}
		
			
	}
    
}

//----------------------------
// Distortion effects
//----------------------------

vertex_program Examples/FresnelRefractReflectVP cg
{
	source Example_Fresnel.cg
	entry_point main_vp
	profiles vs_1_1 arbvp1
}
vertex_program Examples/FresnelRefractReflectVPold cg
{
	source Example_Fresnel.cg
	entry_point main_vp_old
	profiles vs_1_1 arbvp1
}

fragment_program Examples/FresnelRefractReflectFP cg
{
	source Example_Fresnel.cg
	entry_point main_fp
	// sorry, ps_1_1 and fp20 can't do this
	profiles ps_2_0 arbfp1
}

fragment_program Examples/FresnelRefractReflectPS asm
{
	source Example_FresnelPS.asm
	// sorry, only for ps_1_4 :)
	syntax ps_1_4

}

material Examples/FresnelReflectionRefraction
{
	// ps_2_0 / arbfp1
	technique
	{
		pass 
		{
			
			vertex_program_ref Examples/FresnelRefractReflectVP
			{
				param_named_auto worldViewProjMatrix worldviewproj_matrix
				param_named_auto eyePosition camera_position_object_space
				param_named_auto timeVal time 0.05
				param_named scroll float 1  
				param_named scale float 1 
				param_named noise float 1 
				// scroll and noisePos will need updating per frame
			}
			fragment_program_ref Examples/FresnelRefractReflectFP
			{
				param_named fresnelBias float -0.1 
				param_named fresnelScale float 1.8 
				param_named fresnelPower float 8  
				param_named tintColour float4 0 0.05 0.05 1
				param_named noiseScale float 0.05 
			}
			// Noise
			texture_unit
			{
				// Perlin noise volume
				texture waves2.dds
				// min / mag filtering, no mip
				filtering linear linear none
			}
			// Reflection
			texture_unit
			{
				// Will be filled in at runtime
				texture Reflection
				tex_address_mode clamp
			}
			// Refraction
			texture_unit
			{
				// Will be filled in at runtime
				texture Refraction
				tex_address_mode clamp
			}
		}
		
			
	}

	// ATI 8500 +
	technique
	{
		pass
		{
			vertex_program_ref Examples/FresnelRefractReflectVPold
			{
				param_named_auto worldViewProjMatrix worldviewproj_matrix
				param_named_auto eyePosition camera_position_object_space
				param_named fresnelBias float -0.3
				param_named fresnelScale float 1.4
				param_named fresnelPower float 8
				param_named_auto timeVal time_0_1 20
				param_named scroll float 1 
				param_named scale float 4 
				param_named noise float 1
				// scroll and noisePos will need updating per frame
			}

			// for ATI RADEON 8500 - 9200
			fragment_program_ref Examples/FresnelRefractReflectPS
			{
				// distortionRange
				param_indexed 0  float 0.025  
				// tintColour
				param_indexed 1  float4 0.05 0.12 0.15 1
			}

			// Noise
			texture_unit
			{
				// Perlin noise volume
				texture perlinvolume.dds 3d
				// min / mag filtering, no mip
				filtering linear linear none
			}
			// Reflection
			texture_unit
			{
				// Will be filled in at runtime
				texture Reflection
				tex_address_mode clamp
			}
			// Refraction
			texture_unit
			{
				// Will be filled in at runtime
				texture Refraction
				tex_address_mode clamp
			}
		}
	}    
}

// Normal-mapped Athene statue
material Examples/Athene/NormalMapped : Examples/BumpMapping/MultiLight
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Now do the lighting pass
		// NB we don't do decal texture here because this is repeated per light
		pass perlight
		{

			
			// Base bump map
			texture_unit normalmap
			{
				texture atheneNormalMap.png
				colour_op replace
			}
		}
		
		// Decal pass
		pass decal
		{
			texture_unit decalmap
			{
				texture egyptrockyfull.jpg 
			}
			
		}
	}
}

// Basic Athene statue
material Examples/Athene/Basic
{

	technique
	{
		pass
		{
			ambient 0.3 0.3 0.3
			diffuse 1.0 1.0 0.9

			texture_unit
			{
				texture egyptrockyfull.jpg 
			}
			
		}
	}
}


// Any number of lights, diffuse and specular
material Examples/Athene/NormalMappedSpecular : Examples/BumpMapping/MultiLightSpecular
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Now do the lighting pass
		// NB we don't do decal texture here because this is repeated per light
		pass perlight
		{
			
			// Base bump map
			texture_unit normalmap
			{
				texture atheneNormalMap.png
			}
		}
		
		// Decal pass
		pass decal
		{
			texture_unit decalmap
			{
				texture egyptrockyfull.jpg 
			}
			
		}

	}
}





