<?xml version="1.0" encoding="utf-8"?>
<!-- 
	@Name: DirtShader
	@Info: Shader for washable vehicle
	@Author: Manuel Leithner
	@Team:	SFM-Modding
	@Date:	25/12/2009
-->
<CustomShader version="1.0" classRequirement="">
    <LodLevel startDistance="0">
        <Parameters>
            <Parameter name="dirtScale" target="In.mat.dirtScale" type="float4"/>
		 				<Parameter name="UVPlaySpeed" target="In.mat.UVPlaySpeed" type="float3"/>
        </Parameters>
        <Textures>
			<Texture name="dirtTexture" />
        </Textures>
        <CodeInjections>
            <CodeInjection position="SAMPLERS">
<![CDATA[
uniform sampler2D dirtTexture : TEXUNITN;
]]>
            </CodeInjection>
            <CodeInjection position="MATERIALINFO">
<![CDATA[
uniform float4 dirtScale;
uniform float3 UVPlaySpeed;
]]>
            </CodeInjection>
            <CodeInjection position="POST_ALBEDO_FS">
<![CDATA[
	float3 albedoDirt = tex2D(In.samplers.dirtTexture, getTexCoords(In, globals, ALBEDOMAP_TEXCOORD).xy).xyz;
	albedo.xyz = albedo.xyz*(1-In.mat.dirtScale.x) + albedoDirt.xyz*In.mat.dirtScale.x;
]]>
            </CodeInjection>
						<CodeInjection position="POST_SET_TEXCOORDS_VS">
<![CDATA[
	#if defined(ALBEDO_MAP) || defined(EMISSIVE_MAP)
		float2 uv = getTexCoords(In, ALBEDOMAP_TEXCOORD);
		uv.y -= In.mat.UVPlaySpeed.y;
		setTexCoords(Out.texCoords[ALBEDOMAP_TEXCOORD/2], ALBEDOMAP_TEXCOORD, uv);
	#endif
]]>
						</CodeInjection>

        </CodeInjections>
    </LodLevel>
</CustomShader>
