// HUD: red rectangle + ingame HUD + Lensflares - Need texture separation

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_InstanceVS_CB : register(b2)
{

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

}

cbuffer g_MiscGroup1VS_Frequent_CB : register(b3)
{

  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,
  float4 v2 : COLOR0,
  float2 v3 : TEXCOORD0,
  out float4 o0 : SV_Position0,
  out float4 o1 : COLOR0,
  out float4 o2 : TEXCOORD0)
{
  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;
  r0.xyzw = r0.zzzz * g_CameraVS.vs_viewProj._m20_m21_m22_m23 + r1.xyzw;
  o0.xyzw = g_CameraVS.vs_viewProj._m30_m31_m32_m33 + r0.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;  //HUD
  }
  
  
  if (tex_filter.x == 3)
  {
  //o0.x -= stereo.x * (o0.w - stereo.y) * iniParams.y; //Lensflares
  o0.x -= stereo.x * (o0.w - stereo.y) * (2.75 * stereo.y - 5.025); //Lensflares
  }
  
  r0.xyz = v2.xyz;
  r0.w = v1.w;
  o1.xyzw = g_MiscGroup1VS_Frequent.vs_kTint.xyzw * r0.xyzw;
  o2.zw = float2(0,0);
  r0.xy = v3.xy;
  r0.z = 1;
  o2.x = dot(r0.xyz, g_MaterialVS.vs_UVMatrix01[0].xyw);
  o2.y = dot(r0.xyz, g_MaterialVS.vs_UVMatrix01[1].xyw);
  
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Fri Jul 01 15:20:57 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_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_InstanceVS_CB                   cbuffer      NA          NA    2        1
// g_MiscGroup1VS_Frequent_CB        cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// NORMAL                   0   xyzw        1     NONE   float      w
// COLOR                    0   xyzw        2     NONE   float   xyz 
// TEXCOORD                 0   xy          3     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[4], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[4], immediateIndexed
dcl_constantbuffer cb3[2], immediateIndexed
dcl_input v0.xyz
dcl_input v1.w
dcl_input v2.xyz
dcl_input v3.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_temps 2
mul r0.xyz, v0.yyyy, cb2[1].xyzx
mad r0.xyz, v0.xxxx, cb2[0].xyzx, r0.xyzx
mad r0.xyz, v0.zzzz, cb2[2].xyzx, r0.xyzx
add r0.xyz, r0.xyzx, cb2[3].xyzx
mul r1.xyzw, r0.yyyy, cb0[1].xyzw
mad r1.xyzw, r0.xxxx, cb0[0].xyzw, r1.xyzw
mad r0.xyzw, r0.zzzz, cb0[2].xyzw, r1.xyzw
add o0.xyzw, r0.xyzw, cb0[3].xyzw
mov r0.xyz, v2.xyzx
mov r0.w, v1.w
mul o1.xyzw, r0.xyzw, cb3[1].xyzw
mov o2.zw, l(0,0,0,0)
mov r0.xy, v3.xyxx
mov r0.z, l(1.000000)
dp3 o2.x, r0.xyzx, cb1[7].xywx
dp3 o2.y, r0.xyzx, cb1[8].xywx
ret 
// Approximately 17 instruction slots used

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