//*****************************************************************************
// Deferred shading MRT Shader
//*****************************************************************************
#define IN_HLSL
#include "../shdrConsts.h"

//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct VertData
{
   float3 normal          : NORMAL;
   float4 position        : POSITION;
   float4 texCoord        : TEXCOORD0;
};


struct ConnectData
{
   float4 hpos            : POSITION;
   float2 texCoord        : TEXCOORD0;
   float3 normal          : TEXCOORD1;
//   float  color           : COLOR0;
};


//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
ConnectData main( VertData IN,
                  uniform float4x4 modelview       : register(VC_WORLD_PROJ),
                  uniform float4x4 viewMat         : register(VC_VIEW),
                  uniform float3   inLightVec      : register(VC_LIGHT_DIR1),
                  uniform float4x4 texMat          : register(VC_TEX_TRANS1)
)
{
   ConnectData OUT;
   OUT.hpos = mul(modelview, IN.position);

   OUT.texCoord = mul(texMat, IN.texCoord);

//   OUT.color = saturate( 0.3 + max( 0.0, dot( -inLightVec, IN.normal ) ) );  // must saturate for it to compile using the COLOR register

   float3 tempNorm = mul( viewMat, IN.normal );         // put normal in view space
   OUT.normal.xyz = tempNorm * 0.5f + 0.5f;

   return OUT;
}
