
// ***-- Begin HLSL section --**

vertex_program Ogre/DepthShadowmap/CasterVP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point casterVP
    target vs_2_0

    default_params
    {
        param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texelOffsets texel_offsets
    }
}


fragment_program Ogre/DepthShadowmap/CasterFP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point casterFP
    target ps_2_0
	
    default_params
    {
    }
}


vertex_program Ogre/DepthShadowmap/ReceiverVP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point receiverVP
    target vs_2_0

    default_params
    {
        param_named_auto world world_matrix
        param_named_auto worldIT inverse_transpose_world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position 0
		param_named_auto lightColour light_diffuse_colour 0
    }
}


fragment_program Ogre/DepthShadowmap/ReceiverFP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point receiverFP
	target ps_2_0

	preprocessor_defines PCF=0

	default_params
    {
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}

fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point receiverFP
	target ps_2_0

	preprocessor_defines PCF=1

	default_params
    {
        param_named inverseShadowmapSize float 0.0009765625
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}
vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point normalMapShadowReceiverVp
    target vs_2_0

    default_params
    {
        param_named_auto world world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position_object_space 0
    }
}

fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point normalMapShadowReceiverFp
	target ps_2_0

	preprocessor_defines PCF=0

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}
fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL hlsl
{
    source DepthShadowmap.hlsl
    entry_point normalMapShadowReceiverFp
	target ps_2_0

	preprocessor_defines PCF=1

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}



// **-- End HLSL Section --**

// **-- Begin GLSL Section --**
vertex_program Ogre/DepthShadowmap/CasterVP_GLSL glsl
{
    source DepthShadowmapCasterVp.glsl
	
    default_params
    {
        param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texelOffsets texel_offsets
    }
}


fragment_program Ogre/DepthShadowmap/CasterFP_GLSL glsl
{
    source DepthShadowmapCasterFp.glsl
	
    default_params
    {
    }
}


vertex_program Ogre/DepthShadowmap/ReceiverVP_GLSL glsl
{
    source DepthShadowmapReceiverVp.glsl

    default_params
    {
        param_named_auto world world_matrix
        param_named_auto worldIT inverse_transpose_world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position 0
		param_named_auto lightColour light_diffuse_colour 0
    }
}


fragment_program Ogre/DepthShadowmap/ReceiverFP_GLSL glsl
{
    source DepthShadowmapReceiverFp.glsl

	preprocessor_defines PCF=0

	default_params
    {
		param_named shadowMap int 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}

fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_GLSL glsl
{
    source DepthShadowmapReceiverFp.glsl

	preprocessor_defines PCF=1

	default_params
    {
        param_named inverseShadowmapSize float 0.0009765625
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
    }
}
vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL glsl
{
    source DepthShadowmapNormalMapReceiverVp.glsl

    default_params
    {
        param_named_auto world world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position_object_space 0
    }
}

fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL glsl
{
    source DepthShadowmapNormalMapReceiverFp.glsl

	preprocessor_defines PCF=0

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0

		param_named shadowMap int 0
		param_named normalMap int 1
    }
}
fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL glsl
{
    source DepthShadowmapNormalMapReceiverFp.glsl

	preprocessor_defines PCF=1

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0

		param_named shadowMap int 0
		param_named normalMap int 1
    }
}

// **-- End GLSL Section --**

// **-- Begin GLSL ES Section --**
vertex_program Ogre/DepthShadowmap/CasterVP_GLSLES glsles
{
    source DepthShadowmapCasterVp.glsles

	preprocessor_defines LINEAR_RANGE=0

    default_params
    {
        param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texelOffsets texel_offsets
		//param_named_auto depthRange scene_depth_range
    }
}


fragment_program Ogre/DepthShadowmap/CasterFP_GLSLES glsles
{
    source DepthShadowmapCasterFp.glsles

	preprocessor_defines LINEAR_RANGE=0

    default_params
    {
    }
}


vertex_program Ogre/DepthShadowmap/ReceiverVP_GLSLES glsles
{
    source DepthShadowmapReceiverVp.glsles

	preprocessor_defines LINEAR_RANGE=0

    default_params
    {
        param_named_auto world world_matrix
        param_named_auto worldIT inverse_transpose_world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position 0
		param_named_auto lightColour light_diffuse_colour 0
		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
    }
}


fragment_program Ogre/DepthShadowmap/ReceiverFP_GLSLES glsles
{
    source DepthShadowmapReceiverFp.glsles

	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0

	default_params
    {
		param_named shadowMap int 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
		//param_named shadowFuzzyWidth float 1
    }
}

fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_GLSLES glsles
{
    source DepthShadowmapReceiverFp.glsles

	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1

	default_params
    {
        param_named inverseShadowmapSize float 0.0009765625
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
		//param_named shadowFuzzyWidth float 1
    }
}
vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_GLSLES glsles
{
    source DepthShadowmapNormalMapReceiverVp.glsles

	preprocessor_defines LINEAR_RANGE=0

    default_params
    {
        param_named_auto world world_matrix
		param_named_auto worldViewProj worldviewproj_matrix
		param_named_auto texViewProj texture_viewproj_matrix
		param_named_auto lightPosition light_position_object_space 0
		//param_named_auto shadowDepthRange shadow_scene_depth_range 0
    }
}

fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_GLSLES glsles
{
    source DepthShadowmapNormalMapReceiverFp.glsles

	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
		//param_named shadowFuzzyWidth float 1

		param_named shadowMap int 0
		param_named normalMap int 1
    }
}
fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSLES glsles
{
    source DepthShadowmapNormalMapReceiverFp.glsles

	preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1

	default_params
    {
		param_named_auto lightColour light_diffuse_colour 0
        param_named inverseShadowmapSize float 0.0009765625
		param_named fixedDepthBias float 0.0005
		param_named gradientClamp float 0.0098
		param_named gradientScaleBias float 0
		//param_named shadowFuzzyWidth float 1

		param_named shadowMap int 0
		param_named normalMap int 1
    }
}

// **-- End GLSL ES Section --**

// **-- Begin Unified Section --**
vertex_program Ogre/DepthShadowmap/CasterVP unified
{
	delegate Ogre/DepthShadowmap/CasterVP_GLSL
	delegate Ogre/DepthShadowmap/CasterVP_GLSLES
	delegate Ogre/DepthShadowmap/CasterVP_HLSL
}
fragment_program Ogre/DepthShadowmap/CasterFP unified
{
	delegate Ogre/DepthShadowmap/CasterFP_GLSL
	delegate Ogre/DepthShadowmap/CasterFP_GLSLES
	delegate Ogre/DepthShadowmap/CasterFP_HLSL
}
vertex_program Ogre/DepthShadowmap/ReceiverVP unified
{
	delegate Ogre/DepthShadowmap/ReceiverVP_GLSL
	delegate Ogre/DepthShadowmap/ReceiverVP_GLSLES
	delegate Ogre/DepthShadowmap/ReceiverVP_HLSL
}
fragment_program Ogre/DepthShadowmap/ReceiverFP unified
{
	delegate Ogre/DepthShadowmap/ReceiverFP_GLSL
	delegate Ogre/DepthShadowmap/ReceiverFP_GLSLES
	delegate Ogre/DepthShadowmap/ReceiverFP_HLSL
}
fragment_program Ogre/DepthShadowmap/ReceiverFPPCF unified
{
	delegate Ogre/DepthShadowmap/ReceiverFPPCF_GLSL
	delegate Ogre/DepthShadowmap/ReceiverFPPCF_GLSLES
	delegate Ogre/DepthShadowmap/ReceiverFPPCF_HLSL
}
vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP unified
{
	delegate Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL
	delegate Ogre/DepthShadowmap/NormalMapReceiverVP_GLSLES
	delegate Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL
}
fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP unified
{
	delegate Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL
	delegate Ogre/DepthShadowmap/NormalMapReceiverFP_GLSLES
	delegate Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL
}
fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF unified
{
	delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL
	delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSLES
	delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL
}

// **-- End Unified Section --**


// Generic Shadow caster material (floating point shadowmap)
material Ogre/DepthShadowmap/Caster/Float
{
	technique
    {
        pass 
        {
            vertex_program_ref Ogre/DepthShadowmap/CasterVP
            {
            }
            fragment_program_ref Ogre/DepthShadowmap/CasterFP
            {
            }
        }
    }
}

// Generic Shadow receiver material (floating point shadowmap)
material Ogre/DepthShadowmap/Receiver/Float
{
	technique
    {
        pass 
        {
            vertex_program_ref Ogre/DepthShadowmap/ReceiverVP
            {
            }
            fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
            {
            }
            texture_unit ShadowMap
            {
                tex_address_mode clamp
                filtering none
            }
        }
    }
}


// Specific receiver material for rockwall
material Ogre/DepthShadowmap/Receiver/RockWall
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Base ambient pass
		pass
		{
			// 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
			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
			{
			}
			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 lighting
		{
			// 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 Ogre/DepthShadowmap/ReceiverVP
			{
			}
			shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/ReceiverVP
			{
			}

			// Fragment program
			fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
			{
			}
			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFP
			{
			}

			// shadowmap texture will be bound by code

		}
		
		// Decal pass
		pass
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			lighting off
			// Really basic vertex program
			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
			{
				param_named ambient float4 1 1 1 1
			}

			scene_blend dest_colour zero


			texture_unit
			{
				texture rockwall.tga
			}
			
		}
	}


}

// Specific receiver material for Athene
material Ogre/DepthShadowmap/Receiver/Athene
{

	// This is the preferred technique which uses both vertex and
	// fragment programs, supports coloured lights
	technique
	{
		// Base ambient pass
		pass
		{
			// 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
			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified
			{
			}
			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 lighting
		{
			// 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 Ogre/DepthShadowmap/NormalMapReceiverVP
			{
			}
			shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/NormalMapReceiverVP
			{
			}

			// Fragment program
			fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP
			{
			}
			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP
			{
			}

			// shadowmap texture will be bound by code

			// Base bump map
			texture_unit
			{
				texture atheneNormalMap.png
				colour_op replace
			}
			// Normalisation cube map
			texture_unit
			{
				cubic_texture nm.png combinedUVW
				tex_coord_set 1
				tex_address_mode clamp
			}

		}
		
		// Decal pass
		pass
		{
			// base colours, not needed for rendering, but as information
			// to lighting pass categorisation routine
			lighting off
			// Really basic vertex program
			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
			{
				texture egyptrockyfull.jpg 
			}
			
		}
	}


}



// Specialisation to use PCF
material Ogre/DepthShadowmap/Receiver/Float/PCF : Ogre/DepthShadowmap/Receiver/Float
{
	technique
	{
		pass
		{
			// override just receiver program 
			fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF
			{
			}
			
		}
	}
}

// Specialisation to use PCF
material Ogre/DepthShadowmap/Receiver/RockWall/PCF : Ogre/DepthShadowmap/Receiver/RockWall
{
	technique
	{
		pass lighting
		{
			// override just receiver program 
			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF
			{
			}
			
		}
	}
}
// Specialisation to use PCF
material Ogre/DepthShadowmap/Receiver/Athene/PCF : Ogre/DepthShadowmap/Receiver/Athene
{
	technique
	{
		pass lighting
		{
			// override just receiver program 
			shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFPPCF
			{
			}
			
		}
	}
}


