//Halo
cbuffer PER_INSTANCE : register(b1)
{
  row_major float4x4 _TCMMatrixDif : packoffset(c0);
  row_major float4x4 _TCMMatrixGloss : packoffset(c4);
  row_major float4x4 _TCGMatrixDif : packoffset(c8);
  row_major float4x4 _TCMMatrixBump : packoffset(c12);
  row_major float4x4 _TCGMatrixEnv : packoffset(c16);
  row_major float4x4 _TCMMatrixEnv : packoffset(c20);
  row_major float4x4 _TCGMatrixBump : packoffset(c24);
  row_major float4x4 _TCGMatrixGloss : packoffset(c28);
}

cbuffer STATIC_INSTANCE : register(b2)
{
  row_major float3x4 ObjWorldMatrix : packoffset(c0);
  float4 BendInfo : packoffset(c3);
  float4 AmbientOp : packoffset(c5);
}

cbuffer PER_FRAME : register(b3)
{
  row_major float4x4 g_VS_ViewProjMatr : packoffset(c0);
  float4 g_VS_WorldViewPos : packoffset(c6);
  float4 g_VS_AnimGenParams : packoffset(c8);
  row_major float4x4 g_VS_ViewProjZeroMatr : packoffset(c10);
}

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

void main( 
  float4 v0 : POSITION0,
  float4 v1 : TEXCOORD0,
  float4 v2 : COLOR0,
  float4 v3 : TANGENT0,
  float4 v4 : BINORMAL0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.w = -g_VS_WorldViewPos.x + ObjWorldMatrix._m03;
  r0.xyz = ObjWorldMatrix._m00_m01_m02;
  r1.xyz = v0.xyz;
  r1.w = 1;
  r0.x = dot(r0.xyzw, r1.xyzw);
  r2.w = -g_VS_WorldViewPos.y + ObjWorldMatrix._m13;
  r2.xyz = ObjWorldMatrix._m10_m11_m12;
  r0.y = dot(r2.xyzw, r1.xyzw);
  r2.w = -g_VS_WorldViewPos.z + ObjWorldMatrix._m23;
  r2.xyz = ObjWorldMatrix._m20_m21_m22;
  r0.z = dot(r2.xyzw, r1.xyzw);
  r0.w = 1;
  r1.x = dot(g_VS_ViewProjZeroMatr._m00_m01_m02_m03, r0.xyzw);
  r1.y = dot(g_VS_ViewProjZeroMatr._m10_m11_m12_m13, r0.xyzw);
  r1.z = dot(g_VS_ViewProjZeroMatr._m20_m21_m22_m23, r0.xyzw);
  r1.w = dot(g_VS_ViewProjZeroMatr._m30_m31_m32_m33, r0.xyzw);
  o2.xyzw = r0.xyzw;
  o0.xyzw = r1.xyzw;
  
    float4 stereo = StereoParams.Load(0);
  r1.x += stereo.x * (r1.w - stereo.y);
  
  r0.xy = r1.xy * float2(1,-1) + r1.ww;
  o3.zw = r1.zw;
  o3.xy = float2(0.5,0.5) * r0.xy;
  r0.xy = _TCMMatrixDif._m10_m11 * v1.yy;
  r0.xy = v1.xx * _TCMMatrixDif._m00_m01 + r0.xy;
  r0.xy = v1.zz * _TCMMatrixDif._m20_m21 + r0.xy;
  o1.xy = v1.ww * _TCMMatrixDif._m30_m31 + r0.xy;
  o1.zw = v1.xy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//   using 3Dmigoto v1.1.34 on Sun Aug 09 08:50:31 2015
//
//
// Buffer Definitions: 
//
// cbuffer PER_INSTANCE
// {
//
//   row_major float4x4 _TCMMatrixDif;  // Offset:    0 Size:    64
//   row_major float4x4 _TCMMatrixGloss;// Offset:   64 Size:    64 [unused]
//   row_major float4x4 _TCGMatrixDif;  // Offset:  128 Size:    64 [unused]
//   row_major float4x4 _TCMMatrixBump; // Offset:  192 Size:    64 [unused]
//   row_major float4x4 _TCGMatrixEnv;  // Offset:  256 Size:    64 [unused]
//   row_major float4x4 _TCMMatrixEnv;  // Offset:  320 Size:    64 [unused]
//   row_major float4x4 _TCGMatrixBump; // Offset:  384 Size:    64 [unused]
//   row_major float4x4 _TCGMatrixGloss;// Offset:  448 Size:    64 [unused]
//
// }
//
// cbuffer STATIC_INSTANCE
// {
//
//   row_major float3x4 ObjWorldMatrix; // Offset:    0 Size:    48
//   float4 BendInfo;                   // Offset:   48 Size:    16 [unused]
//   float4 AmbientOp;                  // Offset:   80 Size:    16 [unused]
//
// }
//
// cbuffer PER_FRAME
// {
//
//   row_major float4x4 g_VS_ViewProjMatr;// Offset:    0 Size:    64 [unused]
//   float4 g_VS_WorldViewPos;          // Offset:   96 Size:    16
//   float4 g_VS_AnimGenParams;         // Offset:  128 Size:    16 [unused]
//   row_major float4x4 g_VS_ViewProjZeroMatr;// Offset:  160 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PER_INSTANCE                      cbuffer      NA          NA    1        1
// STATIC_INSTANCE                   cbuffer      NA          NA    2        1
// PER_FRAME                         cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// COLOR                    0   xyzw        2     NONE   float       
// TANGENT                  0   xyzw        3     NONE   float       
// BINORMAL                 0   xyzw        4     NONE   float       
//
//
// 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 cb1[4], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_constantbuffer cb3[14], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_temps 3
add r0.w, cb2[0].w, -cb3[6].x
mov r0.xyz, cb2[0].xyzx
mov r1.xyz, v0.xyzx
mov r1.w, l(1.000000)
dp4 r0.x, r0.xyzw, r1.xyzw
add r2.w, cb2[1].w, -cb3[6].y
mov r2.xyz, cb2[1].xyzx
dp4 r0.y, r2.xyzw, r1.xyzw
add r2.w, cb2[2].w, -cb3[6].z
mov r2.xyz, cb2[2].xyzx
dp4 r0.z, r2.xyzw, r1.xyzw
mov r0.w, l(1.000000)
dp4 r1.x, cb3[10].xyzw, r0.xyzw
dp4 r1.y, cb3[11].xyzw, r0.xyzw
dp4 r1.z, cb3[12].xyzw, r0.xyzw
dp4 r1.w, cb3[13].xyzw, r0.xyzw
mov o2.xyzw, r0.xyzw
mov o0.xyzw, r1.xyzw
mad r0.xy, r1.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), r1.wwww
mov o3.zw, r1.zzzw
mul o3.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mul r0.xy, v1.yyyy, cb1[1].xyxx
mad r0.xy, v1.xxxx, cb1[0].xyxx, r0.xyxx
mad r0.xy, v1.zzzz, cb1[2].xyxx, r0.xyxx
mad o1.xy, v1.wwww, cb1[3].xyxx, r0.xyxx
mov o1.zw, v1.xxxy
ret 
// Approximately 27 instruction slots used

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