// VS to be used for global image deformation (zoom, ratio H/V,...) 

cbuffer _Globals : register(b0)
{
  float4 lightCount : packoffset(c0);
  float4 ambient : packoffset(c1);
  float4 lightInfo[4] : packoffset(c2);
  float4 g_vAmbientSettings : packoffset(c6) = {0,0,0,0};
  float4 g_vScreenDepthRect : packoffset(c7);
  float4 g_vDitherSettings : packoffset(c8);
  float4 g_ColorK : packoffset(c9) = {0.270000011,0.670000017,0.0599999987,0};
  float4 LevelMin : packoffset(c10) = {0.100000001,0.100000001,0.100000001,0};
  float4 LevelMax : packoffset(c11) = {0.800000012,0.800000012,0.800000012,0};
  float4 MaxAdd : packoffset(c12) = {0.100000001,0.100000001,0.100000001,0};
  float4 MinSub : packoffset(c13) = {0.0199999996,0.0199999996,0.0199999996,0};
  float4 Color : packoffset(c14);
  float4 Settings : packoffset(c15);
  float4 Settings2 : packoffset(c16);
  float4 Settings3 : packoffset(c17);
  float4 Settings4 : packoffset(c18);
  float4 Transform : packoffset(c19);
  float4 g_vDepthCoordsClamp : packoffset(c20);
  float4 CamPos : packoffset(c21);
  float4 g_vCenterOffs : packoffset(c22);
  float4 g_vHFrustrum : packoffset(c23);
  float4 g_vVFrustrum : packoffset(c24);
  float4 g_avNoise[8] : packoffset(c25);
  float4x4 g_mView : packoffset(c33);
  float4 g_PixelsDir[8] : packoffset(c37);
}
// constant buffer injected by 3dmigoto
cbuffer _Globals : register(b12)
{
  float4 g_vCamPos1 : packoffset(c37);
}

cbuffer _Globals : register(b13)
{
  float4 g_vCamPos2 : packoffset(c37);
}

Texture1D<float4> IniParams : register(t120);

void main( 
  float2 v0 : POSITION0,
  out float4 o0 : SV_Position0,
  out float2 o1 : TEXCOORD0,
  out float2 p1 : TEXCOORD1)
{
  float4 r0;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  
float FovXshift = IniParams.Load(int2(6, 0)).x;
float zoomShift = IniParams.Load(int2(6, 0)).y;
float rightShift = IniParams.Load(int2(7, 0)).x;

 if ((g_vCamPos2.x + g_vCamPos2.y + g_vCamPos2.z) != (g_vCamPos1.x + g_vCamPos1.y + g_vCamPos1.z)) {
	// Right Eye
	FovXshift += zoomShift;
	}
	else  {
	// Left eye
	FovXshift = -FovXshift;
	FovXshift -= zoomShift;
	}

o0.xy = v0.xy + float2(FovXshift,0);

  o0.zw = float2(0,1);
  r0.z = saturate(v0.x);
  o1.x = r0.z * Transform.z + Transform.x;
  r0.w = saturate(-v0.y);
  o1.y = r0.w * Transform.w + Transform.y;
  p1.xy = r0.zw;
    
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.50 on Wed Apr 12 17:36:51 2017
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4 lightCount;                 // Offset:    0 Size:    16 [unused]
//   float4 ambient;                    // Offset:   16 Size:    16 [unused]
//   float4 lightInfo[4];               // Offset:   32 Size:    64 [unused]
//   float4 g_vAmbientSettings;         // Offset:   96 Size:    16 [unused]
//      = 0x00000000 0x00000000 0x00000000 0x00000000 
//   float4 g_vScreenDepthRect;         // Offset:  112 Size:    16 [unused]
//   float4 g_vDitherSettings;          // Offset:  128 Size:    16 [unused]
//   float4 g_ColorK;                   // Offset:  144 Size:    16 [unused]
//      = 0x3e8a3d71 0x3f2b851f 0x3d75c28f 0x00000000 
//   float4 LevelMin;                   // Offset:  160 Size:    16 [unused]
//      = 0x3dcccccd 0x3dcccccd 0x3dcccccd 0x00000000 
//   float4 LevelMax;                   // Offset:  176 Size:    16 [unused]
//      = 0x3f4ccccd 0x3f4ccccd 0x3f4ccccd 0x00000000 
//   float4 MaxAdd;                     // Offset:  192 Size:    16 [unused]
//      = 0x3dcccccd 0x3dcccccd 0x3dcccccd 0x00000000 
//   float4 MinSub;                     // Offset:  208 Size:    16 [unused]
//      = 0x3ca3d70a 0x3ca3d70a 0x3ca3d70a 0x00000000 
//   float4 Color;                      // Offset:  224 Size:    16 [unused]
//   float4 Settings;                   // Offset:  240 Size:    16 [unused]
//   float4 Settings2;                  // Offset:  256 Size:    16 [unused]
//   float4 Settings3;                  // Offset:  272 Size:    16 [unused]
//   float4 Settings4;                  // Offset:  288 Size:    16 [unused]
//   float4 Transform;                  // Offset:  304 Size:    16
//   float4 g_vDepthCoordsClamp;        // Offset:  320 Size:    16 [unused]
//   float4 CamPos;                     // Offset:  336 Size:    16 [unused]
//   float4 g_vCenterOffs;              // Offset:  352 Size:    16 [unused]
//   float4 g_vHFrustrum;               // Offset:  368 Size:    16 [unused]
//   float4 g_vVFrustrum;               // Offset:  384 Size:    16 [unused]
//   float4 g_avNoise[8];               // Offset:  400 Size:   128 [unused]
//   float4x4 g_mView;                  // Offset:  528 Size:    64 [unused]
//   float4 g_PixelsDir[8];             // Offset:  592 Size:   128 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xy          0     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy  
// TEXCOORD                 1     zw        1     NONE   float     zw
//
vs_4_0
dcl_constantbuffer cb0[20], immediateIndexed
dcl_input v0.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o1.zw
dcl_temps 1
mov o0.xy, v0.xyxx
mov o0.zw, l(0,0,0,1.000000)
mov_sat r0.z, v0.x
mad o1.x, r0.z, cb0[19].z, cb0[19].x
mov_sat r0.w, -v0.y
mad o1.y, r0.w, cb0[19].w, cb0[19].y
mov o1.zw, r0.zzzw
ret 
// Approximately 8 instruction slots used

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