//Sun - Hazy 2D Light ?? Not sure
cbuffer cbPass : register(b0)
{
  row_major float4x4 g_mProj : packoffset(c0);
  row_major float4x4 g_mViewProj : packoffset(c4);
  row_major float4x4 g_mViewProjInv : packoffset(c8);
  float2 g_vBufferSize : packoffset(c12);
  float2 g_vBufferSize_Inv : packoffset(c12.z);
  float2 g_vViewportSize : packoffset(c13);
  float2 g_vViewportSize_Inv : packoffset(c13.z);
  float3 g_vEyePosition : packoffset(c14);
  float g_fResMultiplier : packoffset(c14.w);
  float3 g_vAirScatter : packoffset(c15);
  uint g_uiSampleCount : packoffset(c15.w);
  float3 g_vFwdScatter : packoffset(c16);
  float g_fFwdScatterPhase : packoffset(c16.w);
  float3 g_vBackScatter : packoffset(c17);
  float g_fBackScatterPhase : packoffset(c17.w);
  float3 g_vSigmaAbsorption : packoffset(c18);
  float g_fDistanceScale : packoffset(c18.w);
  float3 g_vSigmaScatter : packoffset(c19);
  float g_fZNear : packoffset(c20);
  float g_fZFar : packoffset(c20.y);
}

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main( 
  uint v0 : SV_VERTEXID0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float2 o2 : TEXCOORD1)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  o0.zw = float2(1,1);
  bitmask.x = ((~(-1 << 1)) << 1) & 0xffffffff;
  r0.x = (((uint)v0.x << 1) & bitmask.x) | ((uint)0 & ~bitmask.x);
  r0.z = (int)v0.x & 2;
  r0.xy = (uint2)r0.xz;
  r0.zw = r0.xy * float2(2,-2) + float2(-1,1);
  o2.xy = r0.xy;
  o0.xy = r0.zw;
  r1.xyzw = g_mViewProjInv._m10_m11_m12_m13 * r0.wwww;
  r0.xyzw = r0.zzzz * g_mViewProjInv._m00_m01_m02_m03 + r1.xyzw;
  r0.xyzw = g_mViewProjInv._m20_m21_m22_m23 + r0.xyzw;
  r0.xyzw = g_mViewProjInv._m30_m31_m32_m33 + r0.xyzw;
  r1.x = 1 / r0.w;
  o1.xyzw = r1.xxxx * r0.xyzw;  //WORLD COORD
  
  
float4 r20, r21;
r20.xyzw = o1.xyzw;
r20.w = 1;

r21.xyzw = g_mViewProj._m10_m11_m12_m13 * r20.yyyy;
r21.xyzw = r20.xxxx * g_mViewProj._m00_m01_m02_m03 + r21.xyzw;
r21.xyzw = r20.zzzz * g_mViewProj._m20_m21_m22_m23 + r21.xyzw;
r21.xyzw = r20.wwww * g_mViewProj._m30_m31_m32_m33 + r21.xyzw;
  
float4 stereo = StereoParams.Load(0);
r21.x -= stereo.x * (r21.w - stereo.y);

r20.xyzw = g_mViewProjInv._m10_m11_m12_m13 * r21.yyyy;
r20.xyzw = r21.xxxx * g_mViewProjInv._m00_m01_m02_m03 + r20.xyzw;
r20.xyzw = r21.zzzz * g_mViewProjInv._m20_m21_m22_m23 + r20.xyzw;
r20.xyzw = r21.wwww * g_mViewProjInv._m30_m31_m32_m33 + r20.xyzw;

o1.xyzw = r20.xyzw / r20.wwww;
  
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
//
//   using 3Dmigoto v1.2.9 on Wed Nov 18 23:17:39 2015
//
//
// Buffer Definitions: 
//
// cbuffer cbPass
// {
//
//   row_major float4x4 g_mProj;        // Offset:    0 Size:    64 [unused]
//   row_major float4x4 g_mViewProj;    // Offset:   64 Size:    64 [unused]
//   row_major float4x4 g_mViewProjInv; // Offset:  128 Size:    64
//   float2 g_vBufferSize;              // Offset:  192 Size:     8 [unused]
//   float2 g_vBufferSize_Inv;          // Offset:  200 Size:     8 [unused]
//   float2 g_vViewportSize;            // Offset:  208 Size:     8 [unused]
//   float2 g_vViewportSize_Inv;        // Offset:  216 Size:     8 [unused]
//   float3 g_vEyePosition;             // Offset:  224 Size:    12 [unused]
//   float g_fResMultiplier;            // Offset:  236 Size:     4 [unused]
//   float3 g_vAirScatter;              // Offset:  240 Size:    12 [unused]
//   uint g_uiSampleCount;              // Offset:  252 Size:     4 [unused]
//   float3 g_vFwdScatter;              // Offset:  256 Size:    12 [unused]
//   float g_fFwdScatterPhase;          // Offset:  268 Size:     4 [unused]
//   float3 g_vBackScatter;             // Offset:  272 Size:    12 [unused]
//   float g_fBackScatterPhase;         // Offset:  284 Size:     4 [unused]
//   float3 g_vSigmaAbsorption;         // Offset:  288 Size:    12 [unused]
//   float g_fDistanceScale;            // Offset:  300 Size:     4 [unused]
//   float3 g_vSigmaScatter;            // Offset:  304 Size:    12 [unused]
//   float g_fZNear;                    // Offset:  320 Size:     4 [unused]
//   float g_fZFar;                     // Offset:  324 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// cbPass                            cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VERTEXID              0   x           0   VERTID    uint   x   
//
//
// 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  
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[12], immediateIndexed
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 2
mov o0.zw, l(0,0,1.000000,1.000000)
bfi r0.x, l(1), l(1), v0.x, l(0)
and r0.z, v0.x, l(2)
utof r0.xy, r0.xzxx
mad r0.zw, r0.xxxy, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000)
mov o2.xy, r0.xyxx
mov o0.xy, r0.zwzz
mul r1.xyzw, r0.wwww, cb0[9].xyzw
mad r0.xyzw, r0.zzzz, cb0[8].xyzw, r1.xyzw
add r0.xyzw, r0.xyzw, cb0[10].xyzw
add r0.xyzw, r0.xyzw, cb0[11].xyzw
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
mul o1.xyzw, r0.xyzw, r1.xxxx
ret 
// Approximately 14 instruction slots used

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