//HUD 1 (crosshair and compass).
// ---- Created with 3Dmigoto v1.2.45 on Sat Oct 29 00:39:39 2016

cbuffer VSConstants : register(b0)
{
  float4 mvp[4] : packoffset(c0);
  float4 texgen[2] : packoffset(c4);
}



// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);
#include <crosshair.hlsl>

void main( 
  int4 v0 : POSITION0,
  float4 v1 : COLOR0,
  out float4 o0 : COLOR0,
  out float2 o1 : TEXCOORD0,
  out float4 o2 : SV_Position0)
{
  float4 r0;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 stereo = StereoParams.Load(0);
  float4 iniparams = IniParams.Load(0);
  float4 iniparams1 = IniParams.Load(int2(1,0));
  float4 iniparams2 = IniParams.Load(int2(2,0));
  float4 iniparams3 = IniParams.Load(int2(3,0));
  float separation = stereo.x;
  float convergence = stereo.y;
  
  o0.xyzw = v1.xyzw;
  r0.xyzw = (int4)v0.xyzw;
  o1.x = dot(r0.xyzw, texgen[0].xyzw);
  o1.y = dot(r0.xyzw, texgen[1].xyzw);
  o2.x = dot(r0.xyzw, mvp[0].xyzw);
  o2.y = dot(r0.xyzw, mvp[1].xyzw);
  o2.zw = r0.zw;

  //HUD depth.
  if (iniparams1.w==2)
  {
	o2.x+=adjust_from_depth_buffer(0,0);
  }
  else if (o2.x > -0.1 && o2. x < 0.1 && o2.y > -0.1 && o2.y < 0.1 && iniparams1.w==1)
  {
	o2.x+=adjust_from_depth_buffer(0,0);
  }
  else
  {
	if (o2.x<0)
	{
		o2.x+=iniparams1.z*iniparams1.x*separation*iniparams.x*(o2.x*-o2.x)*0.5+separation*iniparams.x+iniparams1.z*iniparams1.y*o2.x*-o2.x*iniparams.x*(o2.y*o2.y)*0.25;
	}
	else
	{
		o2.x+=iniparams1.z*iniparams1.x*separation*iniparams.x*(o2.x*-o2.x)*0.5+separation*iniparams.x+iniparams1.z*iniparams1.y*o2.x*-o2.x*iniparams.x*(o2.y*-o2.y)*0.25;
	}
  }
  
  //HUD on/off.
  if (iniparams2.x==1)
  {
	o2=0;
  }
  
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.45 on Sat Oct 29 00:39:39 2016
//
//
// Buffer Definitions: 
//
// cbuffer VSConstants
// {
//
//   float4 mvp[4];                     // Offset:    0 Size:    64
//   float4 texgen[2];                  // Offset:   64 Size:    32
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// VSConstants                       cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE     int   xyzw
// COLOR                    0   xyzw        1     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR                    0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy  
// SV_Position              0   xyzw        2      POS   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[6], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xyzw
dcl_output o0.xyzw
dcl_output o1.xy
dcl_output_siv o2.xyzw, position
dcl_temps 1
mov o0.xyzw, v1.xyzw
itof r0.xyzw, v0.xyzw
dp4 o1.x, r0.xyzw, cb0[4].xyzw
dp4 o1.y, r0.xyzw, cb0[5].xyzw
dp4 o2.x, r0.xyzw, cb0[0].xyzw
dp4 o2.y, r0.xyzw, cb0[1].xyzw
mov o2.zw, r0.zzzw
ret 
// Approximately 8 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 