/*
   Author: Themaister
   License: Public domain
*/

struct input
{
   float2 video_size;
   float2 texture_size;
   float2 output_size;
};

const float box_scale = 3.0; // 3x scale.

void main_vertex
(
   float4 position : POSITION,
   out float4 oPosition : POSITION,
   uniform float4x4 modelViewProj,

   float4 color : COLOR,
   out float4 oColor : COLOR,

   float2 tex : TEXCOORD,
   out float2 oTex : TEXCOORD,

   uniform input IN
)
{
   oPosition = mul(modelViewProj, position);
   oColor = color;
   
   float2 scale = (IN.output_size / IN.video_size) / box_scale;
   float2 middle = 0.5 * IN.video_size / IN.texture_size;
   float2 diff = tex.xy - middle;
   oTex = middle + diff * scale;
}

float4 main_fragment (float2 tex : TEXCOORD, uniform sampler2D s0 : TEXUNIT0) : COLOR
{
   return tex2D(s0, tex);
}


