
// RTShader System materials.

// This is a single pass per pixel lighting based material.
// All scene lights will be applied within a single rendering pass.
// It saves geometry overdraw but it consumes more instructions during vertex and pixel shaders.
// Use this method when your scene uses small amount of lights. (1-3).
material RTSS/PerPixel_SinglePass
{
	technique
	{
		pass
		{
			// Turn off specular in order to use only diffuse based bump map technique.
			specular 1.0 1.0 1.0 32
			
			texture_unit
			{
				texture Panels_Diffuse.png
			}				

	        //![rtss_per_pixel]
			// RT Shader system section.
 			rtshader_system
 			{	 	
 				// Override lighting stage with per pixel lighting. 			
 				lighting_stage per_pixel				
 			}	
 			//![rtss_per_pixel]		
		}				
	}
}

sampler RTSS/NormalMapSampler
{
    filtering bilinear
    max_anisotropy 1
    mipmap_bias -1.0
}

// This is a single pass normal map lighting based material.
// All scene lights will be applied within a single rendering pass.
// It saves geometry overdraw but it consumes more instructions during vertex and pixel shaders.
material RTSS/NormalMapping_SinglePass
{
	technique
	{
		pass
		{
			// Comment the specular in order to use only diffuse based normal map technique.
			specular 1.0 1.0 1.0 32
			
			texture_unit
			{
				texture Bricks076C_diffspec.dds
			}				

			texture_unit
			{
				texture Bricks076C_normheight.dds
				sampler_ref RTSS/NormalMapSampler
				// RT Shader system section.
				rtshader_system
				{
					normal_map tangent_space
				}
			}
		}				
	}
}

// This is a multi pass normal map lighting based material.
// It acts as any other multi light material.
// It support any number of lights drawing but it uses more geometry drawing.
//![normal_map_multipass]
material RTSS/NormalMapping_MultiPass
{
	technique
	{
		// Base ambient pass
		pass ambient
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			diffuse 0 0 0

			// Override dynamic light count with zero light count.
			// Doing this will cause the RTSS to create
			// ambient lighting shaders.
			// If not doing that the RTSS it will use the current scene light count
			// which will result in full lighting calculation in this pass.
			max_lights 0
		}
		
		// Lighting pass.
		pass lighting
		{
			// Comment the specular in order to use only diffuse based normal map technique.
			specular 1.0 1.0 1.0 32
			
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			ambient 0 0 0 
			
			iteration once_per_light

			scene_blend add		
			
			texture_unit
			{
				texture Bricks076C_normheight.dds
				sampler_ref RTSS/NormalMapSampler

				rtshader_system
				{
					normal_map tangent_space
				}
			}
		}	
		
		// Decal pass
		pass decal
		{
			
			lighting off
			
			scene_blend modulate
			texture_unit decalmap
			{
				texture Bricks076C_diffspec.dds
			}			
		}			
	}
}
//![normal_map_multipass]

// Athene single multi pass material override.
material Examples/Athene/NormalMapped
{	
	technique
	{			
		pass
		{	
			// Override the diffuse map.
			texture_unit
			{
				texture egyptrockyfull.jpg 
			}	

			texture_unit
			{
				texture atheneNormalMap.png
				sampler_ref RTSS/NormalMapSampler
				// RT Shader system section.
				rtshader_system
				{
					normal_map tangent_space
				}
			}
		}				
	}
}

// Athene model multi pass material override.
material Examples/Athene/NormalMapped_MultiPass : RTSS/NormalMapping_MultiPass
{	
	technique
	{
		pass lighting
		{
			specular 0 0 0 0
			texture_unit
			{
				texture atheneNormalMap.png
				sampler_ref RTSS/NormalMapSampler
				// RT Shader system section.
				rtshader_system
				{
					normal_map tangent_space
				}
			}
		}
		
		// Decal pass
		pass decal
		{
			// Override the decal map.
			texture_unit decalmap
			{
				texture egyptrockyfull.jpg 
			}			
		}
	}
}

// This material derive from the multi pass normal map material.
// The only difference is that it process 2 point lights at each lighting pass.
material RTSS/NormalMapping_MultiPass_2lights : RTSS/NormalMapping_MultiPass
{
	technique
	{		
		pass lighting
		{
			// Override light iteration definition.
			iteration 1 per_n_lights 2 point										
		}							
	}
}
		
// This material demonstrates the texture blending extension.
material RTSS/LayeredBlending
{
	technique
	{
		pass
		{		
			lighting off	
			texture_unit
			{
				scale 0.1 0.1
				texture rockwall.tga
			}

			texture_unit
			{
				// RT Shader system section - required by the layered blend extension.
				rtshader_system
				{
					layered_blend luminosity
					source_modifier src1_inverse_modulate custom 2
				}
				texture ogrelogo.png
			}						
		}
	}
}

material Ogre/RTShader/TriplanarTexturing
{
	technique
	{
		pass
		{
			ambient 0.5 0.5 0.5
			diffuse 1.0 1.0 1.0
			rtshader_system
			{
				// Texturescale, Plateau-size (0 to 0.57, not bigger to avoid division by zero!), transition-speed
				// Texture from x, from y, from z
			   triplanarTexturing 0.05 0.2 4.0 BumpyMetal.jpg egyptrockyfull.jpg MtlPlat2.jpg
			}
		}
	}
}
