<?xml version="1.0" encoding="utf-8"?>

<CustomShader version="1.0" classRequirement="">
    <LodLevel startDistance="0">
        <Parameters>
            <Parameter name="detailUVScale" target="In.mat.detailUVScale" type="float2"/>
            <Parameter name="detailUVOffset" target="In.mat.detailUVOffset" type="float2"/>
        </Parameters>
				<Textures>
					<Texture name="detailTexture" />
				</Textures>
        <CodeInjections>
	        <CodeInjection position="SAMPLERS">
<![CDATA[
uniform sampler2D detailTexture : TEXUNITN;
]]>
					</CodeInjection>
          <CodeInjection position="MATERIALINFO">
<![CDATA[
uniform float2 detailUVScale;
uniform float2 detailUVOffset;
]]>
          </CodeInjection>
					<CodeInjection position="NUM_TEXCOORDS">
<![CDATA[
#defeval DETAILMAP_TEXCOORD NEXT_TEXCOORD
]]>
					</CodeInjection>
					<CodeInjection position="POST_SET_TEXCOORDS_VS">
<![CDATA[
//float2 detailTexture = getTexCoords(In, ALBEDOMAP_INPUT_TEXCOORD)*In.mat.detailUVScale+In.mat.detailUVOffset;
float2 detailTexture = position.xz*In.mat.detailUVScale+In.mat.detailUVOffset;
setTexCoords(Out.texCoords[DETAILMAP_TEXCOORD/2], DETAILMAP_TEXCOORD, detailTexture.xy);

]]>
        	</CodeInjection>
        	<CodeInjection position="POST_ALBEDO_FS">
<![CDATA[
albedo.xyz *= tex2D(In.samplers.detailTexture, getTexCoords(In, globals, DETAILMAP_TEXCOORD).xy).xyz;
]]>
	        	</CodeInjection>
        	</CodeInjections>
    </LodLevel>
</CustomShader>
