<?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="2" classRequirement="">
    <LodLevel startDistance="0">
        <Parameters>
            <Parameter name="dirtScale" target="dirtScale" type="float4"/>
            <Parameter name="UVPlaySpeed" target="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(dirtTexture, getTexCoords(In, globals, ALBEDOMAP_TEXCOORD).xy).xyz;
        albedo.xyz = albedo.xyz*(1-dirtScale.x) + albedoDirt.xyz*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 -= UVPlaySpeed.y;
                setTexCoords(Out.texCoords[ALBEDOMAP_TEXCOORD/2], ALBEDOMAP_TEXCOORD, uv);
        #endif
]]></CodeInjection>
        </CodeInjections>
    </LodLevel>
</CustomShader>
