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

<CustomShader version="2" classRequirement="">
    <LodLevel startDistance="0">
        <Parameters>
            <Parameter name="fadeStartEnd" target="fadeStartEnd" type="float2" />
        </Parameters>
        <CodeInjections>
            <CodeInjection position="GET_NORMAL_VS">
<![CDATA[
    // convert from ubyte to [-1,1] range
    return In.normal.xyz/127.5 - 1.0;
]]>
            </CodeInjection>
			<CodeInjection position="GET_TEXCOORDS_VS">
<![CDATA[
return In.texCoords[texCoordSet].xy;
]]>
			</CodeInjection>
			<CodeInjection position="MATERIALINFO">
<![CDATA[
float4 fadeStartEnd;
]]>
            </CodeInjection>
            <CodeInjection position="VS_OUTPUT">
<![CDATA[
float alphaOffset : VARYINGN;
]]>
            </CodeInjection>
            <CodeInjection position="VS_END">
<![CDATA[
Out.alphaOffset = 0.49-saturate((length(viewDir)-fadeStartEnd.x)/(fadeStartEnd.y-fadeStartEnd.x));
]]>
            </CodeInjection>
            <CodeInjection position="POST_ALBEDO_FS">
<![CDATA[
albedo.w += In.vs.alphaOffset;
]]>
            </CodeInjection>
        </CodeInjections>
    </LodLevel>
</CustomShader>
