#include "common.sh"


struct VsOutput
{
  float4 pos: POSITION;
  float2 tc : TEXCOORD0;
};

float4 ofs   : register(c16);
float4 texsz : register(c17);

VsOutput vsh(float2 pos : POSITION)
{
  VsOutput O;
  float2 p=pos*ofs.xy+ofs.zw;
  O.pos=float4(p, 1, 1);
  O.tc=p*texsz.xy+texsz.zw;
  return O;
}


sampler   baseTex : register(s0);
sampler   surfTex : register(s1);
sampler detailTex : register(s2);


float4 psh(VsOutput I) : COLOR
{
  float4 baseColor=tex2D(baseTex, I.tc.xy);
  float4 surfColor=tex2D(surfTex, I.tc.xy);
  float4 detail=tex2D(detailTex, I.tc.xy*16);

  float3 color=blend_surf(baseColor.rgb, surfColor.rgb, detail.a, surfColor.a);

  return float4(color, 0);
}
