/*
   Author: Themaister
   License: Public domain
*/

struct old_pass
{
   float2 tex_coord;
   uniform sampler2D texture;
};

struct vertex_data
{
   float2 tex;
   float2 orig_tex;
};

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

   float2 tex_coord : TEXCOORD0,

   old_pass ORIG,
   out vertex_data co 
)
{
   oPosition = mul(modelViewProj, position);
   co = vertex_data(tex_coord, ORIG.tex_coord);
}

float4 main_fragment(uniform sampler2D s0 : TEXUNIT0, old_pass ORIG, in vertex_data co) : COLOR
{
   float4 orig_color = tex2D(ORIG.texture, co.orig_tex);
   float4 color = tex2D(s0, co.tex);
   return lerp(orig_color, color, 0.5); // Mix ORIG and previous pass.
}

