// Icon: Frame and dots

cbuffer _Globals : register(b0)
{
  float4x4 ViewProj : packoffset(c0);
  float4x4 IView : packoffset(c4);
  float4 Aspect : packoffset(c8);
  float4 IData[48] : packoffset(c9);
}

// constant buffer injected by 3dmigoto
cbuffer _Globals : register(b12)
{
  float4 g_vCamPos1 : packoffset(c37);
}

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

// 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 : COLOR0,
  out float2 o2 : TEXCOORD0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

float zoomFactor = IniParams.Load(0).w; // zoom factor
float FovXshift = IniParams.Load(int2(6, 0)).x;
float zoomShift = IniParams.Load(int2(6, 0)).y;


 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.zw = float2(1,1);
  r0.x = (uint)v0.w;
  sincos(IData[r0.x].w, r1.x, r2.x);
  r0.yz = v0.yx * r1.xx;
  r0.y = v0.x * r2.x + -r0.y;
  r0.z = v0.y * r2.x + r0.z;
  r0.yz = IData[r0.x].zz * r0.yz;
  r0.xw = IData[r0.x].xy * float2(2,2) + float2(-1,-1);
  o0.x = (r0.y * Aspect.x + r0.x) * zoomFactor + FovXshift;
  o0.y = (r0.z * Aspect.y + -r0.w) * zoomFactor;
  r0.xy = float2(1,2) + v0.ww;
  r0.xy = (uint2)r0.xy;
  o1.xyzw = IData[r0.y].xyzw;
  r0.yz = saturate(v0.xy);
  r0.z = 1 + -r0.z;
  o2.x = r0.y * IData[r0.x].x + IData[r0.x].z;
  o2.y = r0.z * IData[r0.x].y + IData[r0.x].w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.57 on Sun May 07 14:48:05 2017
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4x4 ViewProj;                 // Offset:    0 Size:    64 [unused]
//   float4x4 IView;                    // Offset:   64 Size:    64 [unused]
//   float4 Aspect;                     // Offset:  128 Size:    16
//   float4 IData[48];                  // Offset:  144 Size:   768
//
// }
//
//
// 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   xyzw        0     NONE   float   xy w
//
//
// 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   xy          2     NONE   float   xy  
//
vs_4_0
dcl_constantbuffer cb0[57], dynamicIndexed
dcl_input v0.xyw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 3
mov o0.zw, l(0,0,1.000000,1.000000)
ftou r0.x, v0.w
sincos r1.x, r2.x, cb0[r0.x + 9].w
mul r0.yz, r1.xxxx, v0.yyxy
mad r0.y, v0.x, r2.x, -r0.y
mad r0.z, v0.y, r2.x, r0.z
mul r0.yz, r0.yyzy, cb0[r0.x + 9].zzzz
mad r0.xw, cb0[r0.x + 9].xxxy, l(2.000000, 0.000000, 0.000000, 2.000000), l(-1.000000, 0.000000, 0.000000, -1.000000)
mad o0.x, r0.y, cb0[8].x, r0.x
mad o0.y, r0.z, cb0[8].y, -r0.w
add r0.xy, v0.wwww, l(1.000000, 2.000000, 0.000000, 0.000000)
ftou r0.xy, r0.xyxx
mov o1.xyzw, cb0[r0.y + 9].xyzw
mov_sat r0.yz, v0.xxyx
add r0.z, -r0.z, l(1.000000)
mad o2.x, r0.y, cb0[r0.x + 9].x, cb0[r0.x + 9].z
mad o2.y, r0.z, cb0[r0.x + 9].y, cb0[r0.x + 9].w
ret 
// Approximately 18 instruction slots used

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