// -------------------------------
// Cel Shading Section
// -------------------------------
vertex_program Ogre/CelShadingVPCg cg
{
	source Example_CelShading.cg
	entry_point main_vp
	profiles vs_4_0 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/CelShadingFPCg cg
{
	source Example_CelShading.cg
	entry_point main_fp
	profiles ps_4_0 ps_1_1 arbfp1 fp20

}

vertex_program Ogre/CelShadingVPGLSLES glsles
{
	source Example_CelShadingVp.glsles
	profiles glsles

	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/CelShadingFPGLSLES glsles
{
	source Example_CelShadingFp.glsles
	profiles glsles
}

vertex_program Ogre/CelShadingVPGLSL glsl
{
	source Example_CelShadingVp.glsl
	syntax glsl150

	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/CelShadingFPGLSL glsl
{
	source Example_CelShadingFp.glsl
	syntax glsl150
}

fragment_program Ogre/CelShadingFP unified
{
	delegate Ogre/CelShadingFPGLSL
	delegate Ogre/CelShadingFPGLSLES
	delegate Ogre/CelShadingFPCg
}

vertex_program Ogre/CelShadingVP unified
{
	delegate Ogre/CelShadingVPGLSL
	delegate Ogre/CelShadingVPGLSLES
	delegate Ogre/CelShadingVPCg
}

//shared_params lighting
//{
//    shared_param_named diffuse float4 0 0.5 0 1
//    shared_param_named specular float4 0.3 0.5 0.3 1.0
//}

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
			{
//    			shared_params_ref lighting
				// map diffuse from custom renderable param 2
				param_named_auto diffuse custom 2
				// map specular from custom renderable param 3
				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/BumpMapVPCg cg
{
	source Example_BumpMapping.cg
	entry_point main_vp
	profiles vs_4_0 vs_1_1 arbvp1
}

vertex_program Examples/BumpMapVPGLSLES glsles
{
	source Example_BumpMappingVp.glsles
	profiles glsles
}

vertex_program Examples/BumpMapVPGLSL glsl
{
	source Example_BumpMappingVp.glsl
	syntax glsl150
}

vertex_program Examples/BumpMapVP unified
{
	delegate Examples/BumpMapVPGLSL
	delegate Examples/BumpMapVPGLSLES
	delegate Examples/BumpMapVPCg
}

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

// Bump map vertex program, with tangent parity support for this is required
vertex_program Examples/BumpMapVPTangentParityGLSLES glsles
{
	source BumpMapVPTangentParity.glsles
}

vertex_program Examples/BumpMapVPTangentParityGLSL glsl
{
	source BumpMapVPTangentParity.glsl
	syntax glsl150
	default_params
	{
        param_named_auto lightDiffuse light_diffuse_colour 0 
    }
}

vertex_program Examples/BumpMapVPTangentParity unified
{
	delegate Examples/BumpMapVPTangentParityGLSL
	delegate Examples/BumpMapVPTangentParityGLSLES
	delegate Examples/BumpMapVPTangentParityCg
}

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

fragment_program Examples/BumpMapFPGLSLES glsles
{
	source Example_BumpMappingFp.glsles
	profiles glsles
	default_params
	{
		// assign samplers as required by GLSL
		param_named normalMap int 0
	}
}

fragment_program Examples/BumpMapFPGLSL glsl
{
	source Example_BumpMappingFp.glsl
	syntax glsl150
	default_params
	{
		// assign samplers as required by GLSL
		param_named normalMap int 0
	}
}

fragment_program Examples/BumpMapFP unified
{
	delegate Examples/BumpMapFPGLSL
	delegate Examples/BumpMapFPGLSLES
	delegate Examples/BumpMapFPCg
}

// Bump map vertex program shadow receiver
vertex_program Examples/BumpMapVPShadowRcvCg cg
{
	source Example_BumpMapping.cg
	entry_point main_shadowreceiver_vp
	profiles vs_1_1 arbvp1
}

// Bump map vertex program shadow receiver
vertex_program Examples/BumpMapVPShadowRcvGLSLES glsles
{
	source Example_BumpMappingShadowRcvVp.glsles
	profiles glsles
}

vertex_program Examples/BumpMapVPShadowRcvGLSL glsl
{
	source Example_BumpMappingShadowRcvVp.glsl
	syntax glsl150
}

vertex_program Examples/BumpMapVPShadowRcv unified
{
	delegate Examples/BumpMapVPShadowRcvGLSL
	delegate Examples/BumpMapVPShadowRcvGLSLES
	delegate Examples/BumpMapVPShadowRcvCg
}

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

// Bump map fragment program shadow receiver, support for this is optional
fragment_program Examples/BumpMapFPShadowRcvGLSLES glsles
{
	source Example_BumpMappingShadowRcvFp.glsles
	profiles glsles
	default_params
	{
		// assign samplers as required by GLSL
		param_named shadowMap int 0
		param_named normalMap int 1
	}
}

fragment_program Examples/BumpMapFPShadowRcvGLSL glsl
{
	source Example_BumpMappingShadowRcvFp.glsl
	syntax glsl150
	default_params
	{
		// assign samplers as required by GLSL
		param_named shadowMap int 0
		param_named normalMap int 1
	}
}

fragment_program Examples/BumpMapFPShadowRcv unified
{
	delegate Examples/BumpMapFPShadowRcvGLSL
	delegate Examples/BumpMapFPShadowRcvGLSLES
	delegate Examples/BumpMapFPShadowRcvCg
}

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

// Bump map with specular vertex program, support for this is required
vertex_program Examples/BumpMapVPSpecularGLSLES glsles
{
	source Example_BumpMappingSpecularVp.glsles
	profiles glsles
}

vertex_program Examples/BumpMapVPSpecularGLSL glsl
{
	source Example_BumpMappingSpecularVp.glsl
	syntax glsl150
}

vertex_program Examples/BumpMapVPSpecular unified
{
	delegate Examples/BumpMapVPSpecularGLSL
	delegate Examples/BumpMapVPSpecularGLSLES
	delegate Examples/BumpMapVPSpecularCg
}

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

// Bump map fragment program, support for this is optional
fragment_program Examples/BumpMapFPSpecularGLSLES glsles
{
	source Example_BumpMappingSpecularFp.glsles
	profiles glsles
	default_params
	{
		// assign samplers as required by GLSL
		param_named normalMap int 0
	}
}

fragment_program Examples/BumpMapFPSpecularGLSL glsl
{
	source Example_BumpMappingSpecularFp.glsl
	syntax glsl150
	default_params
	{
		// assign samplers as required by GLSL
		param_named normalMap int 0
	}
}

fragment_program Examples/BumpMapFPSpecular unified
{
	delegate Examples/BumpMapFPSpecularGLSL
	delegate Examples/BumpMapFPSpecularGLSLES
	delegate Examples/BumpMapFPSpecularCg
}

// 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/AmbientOneTextureUnified
			{
				param_named_auto ambient ambient_light_colour
			}
			fragment_program_ref Ogre/BasicFragmentPrograms/PassthroughFP
			{
			}
			
		}
		// 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/AmbientOneTextureUnified
			{
				param_named ambient float4 1 1 1 1
			}
			fragment_program_ref Ogre/BasicFragmentPrograms/PassthroughFP
			{
			}
			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
			}
			fragment_program_ref Ogre/BasicFragmentPrograms/PassthroughFP
			{
			}
			
		}
		
	}

}



//---------------------------
// 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/FresnelRefractReflectVPCg cg
{
	source Example_Fresnel.cg
	entry_point main_vp
	profiles vs_4_0 vs_1_1 arbvp1
}
vertex_program Examples/FresnelRefractReflectVPold cg
{
	source Example_Fresnel.cg
	entry_point main_vp_old
	profiles vs_1_1 arbvp1
}
vertex_program Examples/FresnelRefractReflectVPGLSLES glsles
{
	source Example_FresnelVp.glsles
	entry_point main
	profiles glsles
}
vertex_program Examples/FresnelRefractReflectVPGLSL glsl
{
	source Example_FresnelVp.glsl
	syntax glsl150
}

vertex_program Examples/FresnelRefractReflectVP unified
{
	delegate Examples/FresnelRefractReflectVPGLSL
	delegate Examples/FresnelRefractReflectVPGLSLES
	delegate Examples/FresnelRefractReflectVPCg
}

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

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

fragment_program Examples/FresnelRefractReflectFPGLSLES glsles
{
	source Example_FresnelFp.glsles
	entry_point main
	profiles glsles
	default_params
	{
		// assign samplers as required by GLSL
		param_named noiseMap int 0
		param_named reflectMap int 1
		param_named refractMap int 2
	}
}

fragment_program Examples/FresnelRefractReflectFPGLSL glsl
{
	source Example_FresnelFp.glsl
	syntax glsl150
	default_params
	{
		// assign samplers as required by GLSL
		param_named noiseMap int 0
		param_named reflectMap int 1
		param_named refractMap int 2
	}
}

fragment_program Examples/FresnelRefractReflectFP unified
{
	delegate Examples/FresnelRefractReflectFPGLSL
	delegate Examples/FresnelRefractReflectFPGLSLES
	delegate Examples/FresnelRefractReflectFPCg
}

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

        // Please test this code on OpenGL before reenabling it
	// 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 
			}
			
		}

	}
}


vertex_program Examples/TextureArrayVScg cg
{
	source Example_TextureArrayVS.cg
	entry_point textureArray_v
	profiles vs_4_0

	default_params
	{
		param_named_auto worldViewProj worldviewproj_matrix
	}
}

vertex_program Examples/TextureArrayVSglsl glsl
{
	source Example_TextureArrayVS.glsl

	default_params
	{
		param_named_auto worldViewProj worldviewproj_matrix
	}
}

fragment_program Examples/TextureArrayPSglsl glsl
{
	source Example_TextureArrayPS.glsl

	default_params
	{
		param_named TextureArrayTex int 0
	}
}

vertex_program Examples/TextureArrayVSglsles glsles
{
	source Example_TextureArrayVS.glsles

	default_params
	{
		param_named_auto worldViewProj worldviewproj_matrix
	}
}

fragment_program Examples/TextureArrayPSglsles glsles
{
	source Example_TextureArrayPS.glsles

	default_params
	{
		param_named TextureArrayTex int 0
	}
}

fragment_program Examples/TextureArrayPShlsl4 hlsl
{
	entry_point textureArray_p
	source Example_TextureArrayPS.hlsl4
	target ps_4_0
}

fragment_program Examples/TextureArrayPSasm asm
{
	source Example_TextureArrayPS.asm
	syntax gp4fp
}

material Examples/TextureArray
{
	technique
	{
		pass
		{
			fragment_program_ref Examples/TextureArrayPSasm
			{
			}

		}
	}


	technique HLSL4
	{
		pass
		{
			vertex_program_ref Examples/TextureArrayVScg
			{
			}

			fragment_program_ref Examples/TextureArrayPShlsl4
			{
			}
		}
	}

	technique GLSL
	{
		pass
		{
			vertex_program_ref Examples/TextureArrayVSglsl
			{
			}

			fragment_program_ref Examples/TextureArrayPSglsl
			{
			}

			texture_unit
			{
				// Will be filled in at runtime
				texture TextureArrayTex
				tex_address_mode clamp
			}
		}
	}

	technique GLSLES
	{
		pass
		{
			vertex_program_ref Examples/TextureArrayVSglsles
			{
			}

			fragment_program_ref Examples/TextureArrayPSglsles
			{
			}

			texture_unit
			{
				// Will be filled in at runtime
				texture TextureArrayTex
				tex_address_mode clamp
			}
		}
	}

}
