// Sahdows Halo

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

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

}

cbuffer g_MiscGroup2VS_Infrequent_CB : register(b2)
{

  struct
  {
    float4 vs_wind_params;
    float4 vs_screenSize;
    float4 vs_viewportScaleBias;
    float4 vs_halfPixelOffset;
    float4 vs_screenDoorScaleBias;
  } g_MiscGroup2VS_Infrequent : packoffset(c0);

}

cbuffer g_SpotLightGeometryVS_CB : register(b3)
{

  struct
  {
    float4 spotGeometryParams;
  } g_SpotLightGeometryVS : packoffset(c0);

}



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


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

  r0.x = 0.00872663874 * g_SpotLightGeometryVS.spotGeometryParams.z;
  sincos(r0.x, r0.x, r1.x);
  r0.x = r0.x / r1.x;
  r0.y = g_SpotLightGeometryVS.spotGeometryParams.x * r0.x;
  r0.x = g_SpotLightGeometryVS.spotGeometryParams.w * r0.y;
  r0.zw = cmp(v0.xy < float2(0,0));
  r1.xyz = cmp(float3(0,0,0) < v0.xyz);
  r0.zw = (int2)r0.zw + (int2)-r1.xy;
  r0.zw = (int2)r0.zw;
  r0.xy = r0.zw * r0.xy;
  r0.z = g_SpotLightGeometryVS.spotGeometryParams.x;
  r1.xyw = g_SpotLightGeometryVS.spotGeometryParams.yyy * r0.xyz;
  r0.xyz = r1.zzz ? r1.xyw : r0.xyz;
  r1.xyzw = g_InstanceVS.vs_world._m10_m11_m12_m13 * r0.yyyy;
  r1.xyzw = r0.xxxx * g_InstanceVS.vs_world._m00_m01_m02_m03 + r1.xyzw;
  r0.xyzw = r0.zzzz * g_InstanceVS.vs_world._m20_m21_m22_m23 + r1.xyzw;
  r0.xyzw = g_InstanceVS.vs_world._m30_m31_m32_m33 + r0.xyzw;
  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;
  r0.xyzw = r0.wwww * g_CameraVS.vs_viewProj._m30_m31_m32_m33 + r1.xyzw;
  o0.xyzw = r0.xyzw;
  
  float4 stereo = StereoParams.Load(0);
  r0.x += stereo.x * (r0.w - stereo.y);
  
  r1.xyz = float3(0.5,-0.5,0.5) * r0.xyw;
  r1.xy = r1.xy + r1.zz;
  r1.zw = g_MiscGroup2VS_Infrequent.vs_viewportScaleBias.xy * r0.ww;
  o1.xy = r1.xy * g_MiscGroup2VS_Infrequent.vs_viewportScaleBias.zw + r1.zw;
  r1.xyzw = g_CameraVS.vs_inverse_projection_xy.xyzw * r0.xyww;
  o2.z = r0.w;
  o1.zw = r1.xy + r1.zw;
  o2.xy = g_CameraVS.vs_projection_params.xw;
  o2.w = g_CameraVS.vs_inverse_projection2.x;
  o3.xyzw = g_MiscGroup2VS_Infrequent.vs_screenSize.xyzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Fri Jul 01 14:14:25 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_InstanceVS_CB
// {
//
//   struct InstanceVS
//   {
//       
//       row_major float4x4 vs_world;   // Offset:    0
//
//   } g_InstanceVS;                    // Offset:    0 Size:    64
//
// }
//
// cbuffer g_MiscGroup2VS_Infrequent_CB
// {
//
//   struct MiscGroup2VS_Infrequent
//   {
//       
//       float4 vs_wind_params;         // Offset:    0
//       float4 vs_screenSize;          // Offset:   16
//       float4 vs_viewportScaleBias;   // Offset:   32
//       float4 vs_halfPixelOffset;     // Offset:   48
//       float4 vs_screenDoorScaleBias; // Offset:   64
//
//   } g_MiscGroup2VS_Infrequent;       // Offset:    0 Size:    80
//
// }
//
// cbuffer g_SpotLightGeometryVS_CB
// {
//
//   struct SpotLightGeometryVS
//   {
//       
//       float4 spotGeometryParams;     // Offset:    0
//
//   } g_SpotLightGeometryVS;           // Offset:    0 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_CameraVS_CB                     cbuffer      NA          NA    0        1
// g_InstanceVS_CB                   cbuffer      NA          NA    1        1
// g_MiscGroup2VS_Infrequent_CB      cbuffer      NA          NA    2        1
// g_SpotLightGeometryVS_CB          cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
//
//
// 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   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[13], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_constantbuffer cb3[1], immediateIndexed
dcl_input v0.xyz
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_temps 2
mul r0.x, cb3[0].z, l(0.00872663874)
sincos r0.x, r1.x, r0.x
div r0.x, r0.x, r1.x
mul r0.y, r0.x, cb3[0].x
mul r0.x, r0.y, cb3[0].w
lt r0.zw, v0.xxxy, l(0.000000, 0.000000, 0.000000, 0.000000)
lt r1.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), v0.xyzx
iadd r0.zw, r0.zzzw, -r1.xxxy
itof r0.zw, r0.zzzw
mul r0.xy, r0.xyxx, r0.zwzz
mov r0.z, cb3[0].x
mul r1.xyw, r0.xyxz, cb3[0].yyyy
movc r0.xyz, r1.zzzz, r1.xywx, r0.xyzx
mul r1.xyzw, r0.yyyy, cb1[1].xyzw
mad r1.xyzw, r0.xxxx, cb1[0].xyzw, r1.xyzw
mad r0.xyzw, r0.zzzz, cb1[2].xyzw, r1.xyzw
add r0.xyzw, r0.xyzw, cb1[3].xyzw
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
mad r0.xyzw, r0.wwww, cb0[3].xyzw, r1.xyzw
mov o0.xyzw, r0.xyzw
mul r1.xyz, r0.xywx, l(0.500000, -0.500000, 0.500000, 0.000000)
add r1.xy, r1.zzzz, r1.xyxx
mul r1.zw, r0.wwww, cb2[2].xxxy
mad o1.xy, r1.xyxx, cb2[2].zwzz, r1.zwzz
mul r1.xyzw, r0.xyww, cb0[10].xyzw
mov o2.z, r0.w
add o1.zw, r1.zzzw, r1.xxxy
mov o2.xy, cb0[9].xwxx
mov o2.w, cb0[12].x
mov o3.xyzw, cb2[1].xyzw
ret 
// Approximately 33 instruction slots used

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