float4x4 matWorldViewProjection;
float3 vScales;
struct VS_INPUT
{
	float4 Position : POSITION0;
	float2 Tex	    : TEXCOORD0;
};
struct VS_OUTPUT
{
	float4 Position : POSITION0;
	float2 Tex	    : TEXCOORD0;
	float4 Splat12  : TEXCOORD1;
	float2 NoiseUV  : TEXCOORD2;
};
VS_OUTPUT vs_main(VS_INPUT Input)
{
	VS_OUTPUT Output;
	Output.Position = mul(matWorldViewProjection, Input.Position);
	
	Output.Tex = Input.Tex / 600.0f;
	Output.Splat12.xy = Output.Tex * vScales.x;
	Output.Splat12.zw = Output.Tex * vScales.y;
	Output.NoiseUV = Output.Tex * vScales.z;
	return Output;
}
sampler2D NoiseTex;
sampler2D Splat1;
struct PS_INPUT
{
	float2 Tex	    : TEXCOORD0;
	float4 Splat12  : TEXCOORD1;
	float2 NoiseUV  : TEXCOORD2;
};
float4 ps_main(PS_INPUT Input) : COLOR0
{   
   float fNoise = 0.0f;
   float fFrequency = 1.0f;
   float2 vNoiseUVOffset = Input.NoiseUV;
   for (int i=0;i<6;i++)
   {
      fNoise += tex2D(NoiseTex, vNoiseUVOffset ).x * fFrequency;
      fFrequency *= 0.5f;
      vNoiseUVOffset *= 2.0f;
   }
   
   float3 vSplat1 = tex2D(Splat1, Input.Splat12.xy).xyz * fNoise;
	return float4(vSplat1,1);
}
	