// HUD Crosshair

cbuffer g_CameraVS_CB : register(b0)
{

  struct
  {
    row_major float4x4 vs_viewProj;
    row_major float4x4 vs_view;
    float4 vs_worldCamPos;
    float4 vs_projection_params;
    float4 vs_inverse_projection_xy;
    float4 vs_frustum_params;
    float4 vs_inverse_projection2;
    float4 vs_cameraOrigin;
  } g_CameraVS : packoffset(c0);

}

cbuffer g_MaterialVS_CB : register(b1)
{

  struct
  {
    float4 vs_layer0_diffuse;
    float4 vs_bitangentFlip;
    float4 vs_misc_params;
    float4 vs_vtf_kOffset_kHeight;
    float4 vs_ambientColor;
    float4 vs_fxAttributes;
    float4 vs_vtf_direction;
    float4 vs_UVMatrix01[4];
    float4 vs_UVMatrix23[4];
    float4 vs_bias;
  } g_MaterialVS : packoffset(c0);

}

cbuffer g_FogTexVS_CB : register(b2)
{

  struct
  {
    float4 vs_fog_tex_params;
  } g_FogTexVS : packoffset(c0);

}

cbuffer g_InstanceVS_CB : register(b3)
{

  struct
  {
    row_major float4x4 vs_world;
  } g_InstanceVS : packoffset(c0);

}

cbuffer g_MiscGroup1VS_Frequent_CB : register(b4)
{

  struct
  {
    float4 vs_lightmapOffset;
    float4 vs_kTint;
    float4 vs_defunct;
    float4 vs_fastBlendWeights;
  } g_MiscGroup1VS_Frequent : packoffset(c0);

}



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


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

  r0.xyz = g_InstanceVS.vs_world._m10_m11_m12 * v0.yyy;
  r0.xyz = v0.xxx * g_InstanceVS.vs_world._m00_m01_m02 + r0.xyz;
  r0.xyz = v0.zzz * g_InstanceVS.vs_world._m20_m21_m22 + r0.xyz;
  r0.xyz = g_InstanceVS.vs_world._m30_m31_m32 + r0.xyz;
  r1.xyzw = g_CameraVS.vs_viewProj._m10_m11_m12_m13 * r0.yyyy;
  r1.xyzw = r0.xxxx * g_CameraVS.vs_viewProj._m00_m01_m02_m03 + r1.xyzw;
  r1.xyzw = r0.zzzz * g_CameraVS.vs_viewProj._m20_m21_m22_m23 + r1.xyzw;
  o0.xyzw = g_CameraVS.vs_viewProj._m30_m31_m32_m33 + r1.xyzw;
  
  float4 stereo = StereoParams.Load(0);
  float4 iniParams = IniParams.Load(0);
  
  float4 tex_filter = IniParams.Load(int2(2,0));
  if (tex_filter.x == 2)
  {
  o0.x -= stereo.x * (o0.w - stereo.y) * iniParams.x;
  }
  
  if (tex_filter.x == 5)
  {
  o0.x -= stereo.x * (o0.w - stereo.y) * iniParams.y;
  }
  
  if (tex_filter.x == 6)
  {
  //o0.x -= stereo.x * (o0.w - stereo.y);
  o0 = 0;
  }
  
  r0.w = saturate(-r0.y * g_FogTexVS.vs_fog_tex_params.x + 1);
  r0.xyz = -g_CameraVS.vs_worldCamPos.xyz + r0.xyz;
  r1.x = dot(r0.xyz, r0.xyz);
  r1.y = rsqrt(r1.x);
  r1.x = sqrt(r1.x);
  r1.x = 1 + r1.x;
  r1.x = log2(r1.x);
  r1.x = 0.0752566829 * r1.x;
  o1.z = min(1, r1.x);
  r0.xz = r1.yy * r0.xz;
  r0.y = g_FogTexVS.vs_fog_tex_params.z + r0.y;
  r0.y = log2(r0.y);
  r1.x = saturate(r0.y * g_FogTexVS.vs_fog_tex_params.w + g_FogTexVS.vs_fog_tex_params.y);
  r0.xy = r0.xz * r0.ww;
  r1.yz = r0.xy * float2(0.5,0.5) + float2(0.5,0.5);
  o1.w = r1.z;
  o2.xy = r1.xy;
  r0.xy = v2.xy;
  r0.z = 1;
  o1.x = dot(r0.xyz, g_MaterialVS.vs_UVMatrix01[0].xyw);
  o1.y = dot(r0.xyz, g_MaterialVS.vs_UVMatrix01[1].xyw);
  o3.xyz = saturate(g_MiscGroup1VS_Frequent.vs_kTint.xyz);
  o3.w = g_MiscGroup1VS_Frequent.vs_kTint.w * v1.w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Fri Jul 01 15:17:07 2016
//
//
// Buffer Definitions: 
//
// cbuffer g_CameraVS_CB
// {
//
//   struct CameraVS
//   {
//       
//       row_major float4x4 vs_viewProj;// Offset:    0
//       row_major float4x4 vs_view;    // Offset:   64
//       float4 vs_worldCamPos;         // Offset:  128
//       float4 vs_projection_params;   // Offset:  144
//       float4 vs_inverse_projection_xy;// Offset:  160
//       float4 vs_frustum_params;      // Offset:  176
//       float4 vs_inverse_projection2; // Offset:  192
//       float4 vs_cameraOrigin;        // Offset:  208
//
//   } g_CameraVS;                      // Offset:    0 Size:   224
//
// }
//
// cbuffer g_MaterialVS_CB
// {
//
//   struct MaterialVS
//   {
//       
//       float4 vs_layer0_diffuse;      // Offset:    0
//       float4 vs_bitangentFlip;       // Offset:   16
//       float4 vs_misc_params;         // Offset:   32
//       float4 vs_vtf_kOffset_kHeight; // Offset:   48
//       float4 vs_ambientColor;        // Offset:   64
//       float4 vs_fxAttributes;        // Offset:   80
//       float4 vs_vtf_direction;       // Offset:   96
//       float4 vs_UVMatrix01[4];       // Offset:  112
//       float4 vs_UVMatrix23[4];       // Offset:  176
//       float4 vs_bias;                // Offset:  240
//
//   } g_MaterialVS;                    // Offset:    0 Size:   256
//
// }
//
// cbuffer g_FogTexVS_CB
// {
//
//   struct FogTexVS
//   {
//       
//       float4 vs_fog_tex_params;      // Offset:    0
//
//   } g_FogTexVS;                      // Offset:    0 Size:    16
//
// }
//
// cbuffer g_InstanceVS_CB
// {
//
//   struct InstanceVS
//   {
//       
//       row_major float4x4 vs_world;   // Offset:    0
//
//   } g_InstanceVS;                    // Offset:    0 Size:    64
//
// }
//
// cbuffer g_MiscGroup1VS_Frequent_CB
// {
//
//   struct MiscGroup1VS_Frequent
//   {
//       
//       float4 vs_lightmapOffset;      // Offset:    0
//       float4 vs_kTint;               // Offset:   16
//       float4 vs_defunct;             // Offset:   32
//       float4 vs_fastBlendWeights;    // Offset:   48
//
//   } g_MiscGroup1VS_Frequent;         // Offset:    0 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_CameraVS_CB                     cbuffer      NA          NA    0        1
// g_MaterialVS_CB                   cbuffer      NA          NA    1        1
// g_FogTexVS_CB                     cbuffer      NA          NA    2        1
// g_InstanceVS_CB                   cbuffer      NA          NA    3        1
// g_MiscGroup1VS_Frequent_CB        cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// NORMAL                   0   xyzw        1     NONE   float      w
// TEXCOORD                 0   xy          2     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xy          2     NONE   float   xy  
// COLOR                    0   xyzw        3     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[9], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[4], immediateIndexed
dcl_constantbuffer cb4[2], immediateIndexed
dcl_input v0.xyz
dcl_input v1.w
dcl_input v2.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_output o3.xyzw
dcl_temps 2
mul r0.xyz, v0.yyyy, cb3[1].xyzx
mad r0.xyz, v0.xxxx, cb3[0].xyzx, r0.xyzx
mad r0.xyz, v0.zzzz, cb3[2].xyzx, r0.xyzx
add r0.xyz, r0.xyzx, cb3[3].xyzx
mul r1.xyzw, r0.yyyy, cb0[1].xyzw
mad r1.xyzw, r0.xxxx, cb0[0].xyzw, r1.xyzw
mad r1.xyzw, r0.zzzz, cb0[2].xyzw, r1.xyzw
add o0.xyzw, r1.xyzw, cb0[3].xyzw
mad_sat r0.w, -r0.y, cb2[0].x, l(1.000000)
add r0.xyz, r0.xyzx, -cb0[8].xyzx
dp3 r1.x, r0.xyzx, r0.xyzx
rsq r1.y, r1.x
sqrt r1.x, r1.x
add r1.x, r1.x, l(1.000000)
log r1.x, r1.x
mul r1.x, r1.x, l(0.0752566829)
min o1.z, r1.x, l(1.000000)
mul r0.xz, r0.xxzx, r1.yyyy
add r0.y, r0.y, cb2[0].z
log r0.y, r0.y
mad_sat r1.x, r0.y, cb2[0].w, cb2[0].y
mul r0.xy, r0.wwww, r0.xzxx
mad r1.yz, r0.xxyx, l(0.000000, 0.500000, 0.500000, 0.000000), l(0.000000, 0.500000, 0.500000, 0.000000)
mov o1.w, r1.z
mov o2.xy, r1.xyxx
mov r0.xy, v2.xyxx
mov r0.z, l(1.000000)
dp3 o1.x, r0.xyzx, cb1[7].xywx
dp3 o1.y, r0.xyzx, cb1[8].xywx
mov_sat o3.xyz, cb4[1].xyzx
mul o3.w, v1.w, cb4[1].w
ret 
// Approximately 32 instruction slots used

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