
vertex_program DiamondPlateVPCG cg
{
	source materials/programs/diamondplate.cgfx
	profiles vs_1_1
	entry_point BumpVS
}

fragment_program DiamondPlateFPCG cg
{
	source materials/programs/diamondplate.cgfx
	entry_point dplatePSStuds
	profiles ps_2_x
}

vertex_program DiamondPlateVP_gbufferCG cg
{
	source materials/programs/diamondplate.cgfx
	profiles vs_1_1
	entry_point BumpVS
	
	compile_arguments -DGBUFFER
}

fragment_program DiamondPlateFP_gbufferCG cg
{
	source materials/programs/diamondplate.cgfx
	entry_point dplatePSStuds
	profiles ps_2_x
	
	compile_arguments -DGBUFFER
}

vertex_program DiamondPlateVPGLSL glsl
{
	source materials/programs/glsl/vert/bump.vert
	preprocessor_defines GLSL=1,GLSL_VERT=1
}

fragment_program DiamondPlateFPGLSL glsl
{
	source materials/programs/glsl/frag/diamondplate.frag
	preprocessor_defines GLSL=1,GLSL_FRAG=1
	default_params
	{
		param_named StudsSamp int 0
		param_named NormalSamp int 1
	}
}

vertex_program DiamondPlateVP_gbufferGLSL glsl
{
	source materials/programs/glsl/vert/bump.vert
	preprocessor_defines GLSL=1,GLSL_VERT=1,GBUFFER=1
}

fragment_program DiamondPlateFP_gbufferGLSL glsl
{
	source materials/programs/glsl/frag/diamondplate.frag
	preprocessor_defines GLSL=1,GLSL_FRAG=1,GBUFFER=1
	default_params
	{
		param_named StudsSamp int 0
		param_named NormalSamp int 1
	}
}

vertex_program DiamondPlateVP unified
{
	delegate DiamondPlateVPCG
	delegate DiamondPlateVPGLSL
}

fragment_program DiamondPlateFP unified
{
	delegate DiamondPlateFPCG
	delegate DiamondPlateFPGLSL
}

vertex_program DiamondPlateVP_gbuffer unified
{
	delegate DiamondPlateVP_gbufferCG
	delegate DiamondPlateVP_gbufferGLSL
}

fragment_program DiamondPlateFP_gbuffer unified
{
	delegate DiamondPlateFP_gbufferCG
	delegate DiamondPlateFP_gbufferGLSL
}

material DiamondPlate_Low
{
	technique lod1
	{
		pass
		{
			ambient vertexcolour
			diffuse vertexcolour
			specular 0.0 0.0 0.0 25
			// mimic current wood shader limitation
			max_lights 2
		
			texture_unit
			{
				texture_alias Studs
				tex_coord_set 0
				texture textures/surfacesAlpha.png
				colour_op alpha_blend
				//ignore alpha from SurfaceAlpha.png. Use fixed alpha. VERY IMPORTANT FOR OFF-SCREEN RENDERING!
		        alpha_op_ex source1 src_manual src_manual 1 1 1
		        filtering trilinear
			}
		}
	}

}

material DiamondPlate_Med : DiamondPlate_Low
{
	lod_distances 320.0
	
	technique LegacyFF_lod0
	{
		lod_index 0
		pass
		{
			ambient vertexcolour
			diffuse vertexcolour
			specular 0.0 0.0 0.0 25
			// mimic current wood shader limitation
			max_lights 2
			
			texture_unit
			{
				tex_coord_set 1
				texture textures/DiamondPlateFallback.png
		        filtering trilinear
		        colour_op_ex add_signed src_texture src_current
				//ignore alpha from SurfaceAlpha.png. Use alpha from vertices (in this case, it is not set, so use manual 1.0). VERY IMPORTANT FOR OFF-SCREEN RENDERING!
		        alpha_op_ex source1 src_manual src_manual 1.0 1.0 1.0
		        transform 0.28 0 0 0	0 0.28 0 0	0 0 0.28 0	0 0 0 1
			}
			
			texture_unit
			{
				texture_alias Studs
				tex_coord_set 0
				texture textures/surfacesAlpha.png
				colour_op alpha_blend
				//ignore alpha from SurfaceAlpha.png. Use fixed alpha. VERY IMPORTANT FOR OFF-SCREEN RENDERING!
		        alpha_op_ex source1 src_manual src_manual 1 1 1
        
		        filtering trilinear
			}
		}
	}
	
	technique lod1
	{
		lod_index 1
		pass
		{
			ambient vertexcolour
			diffuse vertexcolour
			specular 0.0 0.0 0.0 25
			// mimic current wood shader limitation
			max_lights 2
			
		}
	}
}

material DiamondPlate_High : DiamondPlate_Low
{
	lod_distances 320.0
	technique Procedural_lod0
	{
		lod_index 0

		pass
		{
			max_lights 2
			
			vertex_program_ref DiamondPlateVP
			{
				param_named_auto Lamp0Pos light_position 0
				param_named_auto Lamp1Pos light_position 1
				param_named_auto WorldITXf inverse_transpose_world_matrix
				param_named_auto WorldXf world_matrix
				param_named_auto ViewIXf inverse_view_matrix
				param_named_auto WvpXf worldviewproj_matrix
				param_named_auto WorldXf world_matrix
				param_named_auto WvXf worldview_matrix
				param_named NormMapScale float  1.2
				param_named FadeDistance float 180
			}

			fragment_program_ref DiamondPlateFP
			{
				param_named_auto AmbiColor ambient_light_colour
				param_named_auto Lamp0Color light_diffuse_colour 0
				param_named_auto Lamp1Color light_diffuse_colour 1
				param_named Ks float 0.9
				param_named SpecExpon float  25
				param_named_auto FogColour fog_colour
				param_named_auto FogParams fog_params
			}
			
			texture_unit
			{
				texture_alias Studs
				tex_coord_set 0
				texture textures/SurfacesAlpha.png
		        filtering trilinear
			}

			texture_unit
			{
				tex_coord_set 1
				texture textures/DPlate_Normal.dds
		        filtering trilinear 
			}
		}
	}

	technique Procedural_lod0
	{
		lod_index 0

		scheme MRT
		
		pass
		{
			max_lights 2
			
			vertex_program_ref DiamondPlateVP_gbuffer
			{
				param_named_auto Lamp0Pos light_position 0
				param_named_auto Lamp1Pos light_position 1
				param_named_auto WorldITXf inverse_transpose_world_matrix
				param_named_auto WorldXf world_matrix
				param_named_auto ViewIXf inverse_view_matrix
				param_named_auto WvpXf worldviewproj_matrix
				param_named_auto WorldXf world_matrix
				param_named_auto WvXf worldview_matrix
				param_named NormMapScale float  1.2
				param_named FadeDistance float 180			
			}

			fragment_program_ref DiamondPlateFP_gbuffer
			{
				param_named_auto AmbiColor ambient_light_colour
				param_named_auto Lamp0Color light_diffuse_colour 0
				param_named_auto Lamp1Color light_diffuse_colour 1
				param_named Ks float 0.9
				param_named SpecExpon float  25	
				param_named_auto FogColour fog_colour
				param_named_auto FogParams fog_params
			}
			
			texture_unit
			{
				texture_alias Studs
				tex_coord_set 0
				texture textures/SurfacesAlpha.png
		        filtering trilinear
			}

			texture_unit
			{
				tex_coord_set 1
				texture textures/DPlate_Normal.dds
		        filtering trilinear 
			}
		}
	}
		
	technique lod1
	{
		lod_index 1
	}
}


