#define IN_HLSL
#include "shdrConsts.h"

//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct ConnectData
{
   float2 texCoord        : TEXCOORD0;
   float3 normal          : TEXCOORD1;
   float4 texCoord2       : TEXCOORD2;
};


struct Fragout
{
   float4 col : COLOR0;
};


//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( ConnectData IN,
              uniform sampler2D refractBuff  : register(S0),
              uniform sampler2D texMap       : register(S1),
              uniform float2 fadeVal       : register(PC_USERDEF1)
)
{
   Fragout OUT;

   float timeVal = fadeVal.y;

   IN.texCoord2.xy += IN.normal.xy * 0.2;

   float4 refractColor = tex2Dproj( refractBuff, IN.texCoord2 );
   OUT.col = refractColor;// + float4( 0.2, 0.2, 0.2, 0.0 );


IN.texCoord += float2( timeVal * 0.2, timeVal * 0.4 );
//   OUT.col += tex2D( texMap, IN.texCoord) * 0.5;

float3 plasmaColor = tex2D( texMap, IN.texCoord) * 0.5;


IN.texCoord *= 0.5;
IN.texCoord -= float2( timeVal * 0.2, timeVal * 0.4 );
   plasmaColor += tex2D( texMap, IN.texCoord ) * 0.5;

   OUT.col.xyz += plasmaColor * 0.8;

//OUT.col.rgb = plasmaColor;

   OUT.col.a = 1.0 - fadeVal.x;


   return OUT;
}
