// Halo

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);
}

cbuffer PER_MATERIAL : register(b4)
{
  float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3 : packoffset(c2);
  float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2 : packoffset(c3);
  float4 __0VertColorMaskX__1VertColorMaskY__2VertColorMaskZ__3VertColorMaskW : packoffset(c6);
}



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


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,
  out float4 o4 : COLOR0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10;
  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;
  o1.xyzw = v1.xyxy;
  r0.yzw = v2.yxw;
  r1.x = cmp(v2.z >= 0.5);
  r1.y = r1.x ? -0.5 : -0;
  r0.x = v2.z + r1.y;
  r0.xyzw = r0.xyzw * float4(255,255,255,255) + float4(0.00196078443,0.00196078443,0.00196078443,0.00196078443);
  r0.xyzw = float4(0.0625,0.0625,0.0625,0.0625) * r0.xyzw;
  r2.xyzw = frac(r0.xyzw);
  r0.xyzw = floor(r0.xyzw);
  r0.xyzw = float4(0.25,0.25,0.25,0.25) * r0.xyzw;
  r2.xyzw = float4(4,4,4,4) * r2.xyzw;
  r3.xyzw = frac(r2.xyzw);
  r2.xyzw = floor(r2.xyzw);
  r2.xyzw = float4(0.5,0.5,0.5,0.5) * r2.xyzw;
  r3.xyzw = r3.xyzw + r3.xyzw;
  r4.x = frac(r3.x);
  r4.y = frac(r2.x);
  r5.xyzw = frac(r0.xyzw);
  r0.xyzw = floor(r0.xyzw);
  r0.xyzw = float4(0.5,0.5,0.5,0.5) * r0.xyzw;
  r5.xyzw = r5.xyzw + r5.xyzw;
  r4.z = frac(r5.x);
  r4.w = frac(r0.x);
  r4.xyzw = r4.xyzw + r4.xyzw;
  r6.xyzw = __0VertColorMaskX__1VertColorMaskY__2VertColorMaskZ__3VertColorMaskW.xyzw * float4(0.0625,0.0625,0.0625,0.0625);
  r7.xyzw = frac(r6.xyzw);
  r6.xyzw = floor(r6.xyzw);
  r6.xyzw = float4(0.25,0.25,0.25,0.25) * r6.xyzw;
  r7.xyzw = float4(4,4,4,4) * r7.xyzw;
  r8.xyzw = frac(r7.xyzw);
  r7.xyzw = floor(r7.xyzw);
  r7.xyzw = float4(0.5,0.5,0.5,0.5) * r7.xyzw;
  r8.xyzw = r8.xyzw + r8.xyzw;
  r9.x = frac(r8.x);
  r9.y = frac(r7.x);
  r10.xyzw = frac(r6.xyzw);
  r6.xyzw = floor(r6.xyzw);
  r6.xyzw = float4(0.5,0.5,0.5,0.5) * r6.xyzw;
  r10.xyzw = r10.xyzw + r10.xyzw;
  r9.z = frac(r10.x);
  r9.w = frac(r6.x);
  r4.xyzw = r9.xyzw * float4(2,2,2,2) + r4.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r1.yz = (int2)r4.zw | (int2)r4.xy;
  r1.y = (int)r1.z | (int)r1.y;
  r1.y = (int)r1.y & 1;
  r4.x = floor(r3.x);
  r4.y = floor(r2.x);
  r4.z = floor(r5.x);
  r4.w = floor(r0.x);
  r9.x = floor(r8.x);
  r9.y = floor(r7.x);
  r9.z = floor(r10.x);
  r9.w = floor(r6.x);
  r4.xyzw = r9.xyzw + r4.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r1.zw = (int2)r4.zw | (int2)r4.xy;
  r0.x = (int)r1.w | (int)r1.z;
  r0.x = (int)r0.x & 1;
  r0.x = (int)r0.x + (int)r1.y;
  r4.x = frac(r8.y);
  r4.y = frac(r7.y);
  r4.z = frac(r10.y);
  r4.w = frac(r6.y);
  r9.x = frac(r3.y);
  r9.y = frac(r2.y);
  r9.z = frac(r5.y);
  r9.w = frac(r0.y);
  r9.xyzw = r9.xyzw + r9.xyzw;
  r4.xyzw = r4.xyzw * float4(2,2,2,2) + r9.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r1.yz = (int2)r4.zw | (int2)r4.xy;
  r1.y = (int)r1.z | (int)r1.y;
  r1.y = (int)r1.y & 1;
  r0.x = (int)r0.x + (int)r1.y;
  r4.x = floor(r3.y);
  r4.y = floor(r2.y);
  r4.z = floor(r5.y);
  r4.w = floor(r0.y);
  r9.x = floor(r8.y);
  r9.y = floor(r7.y);
  r9.z = floor(r10.y);
  r9.w = floor(r6.y);
  r4.xyzw = r9.xyzw + r4.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r1.yz = (int2)r4.zw | (int2)r4.xy;
  r0.y = (int)r1.z | (int)r1.y;
  r0.y = (int)r0.y & 1;
  r0.x = (int)r0.y + (int)r0.x;
  r4.x = frac(r8.z);
  r4.y = frac(r7.z);
  r4.z = frac(r10.z);
  r4.w = frac(r6.z);
  r9.x = frac(r3.z);
  r9.y = frac(r2.z);
  r9.z = frac(r5.z);
  r9.w = frac(r0.z);
  r9.xyzw = r9.xyzw + r9.xyzw;
  r4.xyzw = r4.xyzw * float4(2,2,2,2) + r9.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r1.yz = (int2)r4.zw | (int2)r4.xy;
  r0.y = (int)r1.z | (int)r1.y;
  r0.y = (int)r0.y & 1;
  r0.x = (int)r0.y + (int)r0.x;
  r4.x = floor(r8.z);
  r4.y = floor(r7.z);
  r4.z = floor(r10.z);
  r4.w = floor(r6.z);
  r9.x = floor(r3.z);
  r9.y = floor(r2.z);
  r9.z = floor(r5.z);
  r9.w = floor(r0.z);
  r4.xyzw = r9.xyzw + r4.xyzw;
  r4.xyzw = cmp(r4.xyzw >= float4(2,2,2,2));
  r0.yz = (int2)r4.zw | (int2)r4.xy;
  r0.y = (int)r0.z | (int)r0.y;
  r0.y = (int)r0.y & 1;
  r0.x = (int)r0.y + (int)r0.x;
  r4.x = frac(r3.w);
  r3.x = floor(r3.w);
  r4.y = frac(r2.w);
  r3.y = floor(r2.w);
  r4.z = frac(r5.w);
  r3.z = floor(r5.w);
  r4.w = frac(r0.w);
  r3.w = floor(r0.w);
  r2.xyzw = r4.xyzw + r4.xyzw;
  r4.x = frac(r8.w);
  r5.x = floor(r8.w);
  r4.y = frac(r7.w);
  r5.y = floor(r7.w);
  r4.z = frac(r10.w);
  r5.z = floor(r10.w);
  r4.w = frac(r6.w);
  r5.w = floor(r6.w);
  r3.xyzw = r5.xyzw + r3.xyzw;
  r3.xyzw = cmp(r3.xyzw >= float4(2,2,2,2));
  r0.yz = (int2)r3.zw | (int2)r3.xy;
  r0.y = (int)r0.z | (int)r0.y;
  r2.xyzw = r4.xyzw * float4(2,2,2,2) + r2.xyzw;
  r2.xyzw = cmp(r2.xyzw >= float4(2,2,2,2));
  r0.zw = (int2)r2.zw | (int2)r2.xy;
  r0.z = (int)r0.w | (int)r0.z;
  r0.yz = (int2)r0.yz & int2(1,1);
  r0.x = (int)r0.z + (int)r0.x;
  r0.x = (int)r0.y + (int)r0.x;
  r0.xy = r0.xx ? float2(1,-0.5) : float2(0,0.5);
  r0.x = r1.x ? r0.y : r0.x;
  r0.y = r1.x ? 1.000000 : 0;
  r0.zw = float2(0,0);
  o4.xyzw = float4(-1,1,1,1) * r0.xyzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.2.34 on Fri Apr 29 16:30:01 2016
//
//
// Buffer Definitions: 
//
// 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
//
// }
//
// cbuffer PER_MATERIAL
// {
//
//   float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3;// Offset:   32 Size:    12 [unused]
//   float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2;// Offset:   48 Size:    16 [unused]
//   float4 __0VertColorMaskX__1VertColorMaskY__2VertColorMaskZ__3VertColorMaskW;// Offset:   96 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// STATIC_INSTANCE                   cbuffer      NA          NA    2        1
// PER_FRAME                         cbuffer      NA          NA    3        1
// PER_MATERIAL                      cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// TEXCOORD                 0   xyzw        1     NONE   float   xy  
// COLOR                    0   xyzw        2     NONE   float   xyzw
// 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
// COLOR                    0   xyzw        4     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_constantbuffer cb3[14], immediateIndexed
dcl_constantbuffer cb4[7], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xy
dcl_input v2.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_temps 11
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)
mov o1.xyzw, v1.xyxy
mov r0.yzw, v2.yyxw
ge r1.x, v2.z, l(0.500000)
movc r1.y, r1.x, l(-0.500000), l(-0.000000)
add r0.x, r1.y, v2.z
mad r0.xyzw, r0.xyzw, l(255.000000, 255.000000, 255.000000, 255.000000), l(0.00196078443, 0.00196078443, 0.00196078443, 0.00196078443)
mul r0.xyzw, r0.xyzw, l(0.062500, 0.062500, 0.062500, 0.062500)
frc r2.xyzw, r0.xyzw
round_ni r0.xyzw, r0.xyzw
mul r0.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000)
mul r2.xyzw, r2.xyzw, l(4.000000, 4.000000, 4.000000, 4.000000)
frc r3.xyzw, r2.xyzw
round_ni r2.xyzw, r2.xyzw
mul r2.xyzw, r2.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000)
add r3.xyzw, r3.xyzw, r3.xyzw
frc r4.x, r3.x
frc r4.y, r2.x
frc r5.xyzw, r0.xyzw
round_ni r0.xyzw, r0.xyzw
mul r0.xyzw, r0.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000)
add r5.xyzw, r5.xyzw, r5.xyzw
frc r4.z, r5.x
frc r4.w, r0.x
add r4.xyzw, r4.xyzw, r4.xyzw
mul r6.xyzw, l(0.062500, 0.062500, 0.062500, 0.062500), cb4[6].xyzw
frc r7.xyzw, r6.xyzw
round_ni r6.xyzw, r6.xyzw
mul r6.xyzw, r6.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000)
mul r7.xyzw, r7.xyzw, l(4.000000, 4.000000, 4.000000, 4.000000)
frc r8.xyzw, r7.xyzw
round_ni r7.xyzw, r7.xyzw
mul r7.xyzw, r7.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000)
add r8.xyzw, r8.xyzw, r8.xyzw
frc r9.x, r8.x
frc r9.y, r7.x
frc r10.xyzw, r6.xyzw
round_ni r6.xyzw, r6.xyzw
mul r6.xyzw, r6.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000)
add r10.xyzw, r10.xyzw, r10.xyzw
frc r9.z, r10.x
frc r9.w, r6.x
mad r4.xyzw, r9.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), r4.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r1.yz, r4.zzwz, r4.xxyx
or r1.y, r1.z, r1.y
and r1.y, r1.y, l(1)
round_ni r4.x, r3.x
round_ni r4.y, r2.x
round_ni r4.z, r5.x
round_ni r4.w, r0.x
round_ni r9.x, r8.x
round_ni r9.y, r7.x
round_ni r9.z, r10.x
round_ni r9.w, r6.x
add r4.xyzw, r4.xyzw, r9.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r1.zw, r4.zzzw, r4.xxxy
or r0.x, r1.w, r1.z
and r0.x, r0.x, l(1)
iadd r0.x, r0.x, r1.y
frc r4.x, r8.y
frc r4.y, r7.y
frc r4.z, r10.y
frc r4.w, r6.y
frc r9.x, r3.y
frc r9.y, r2.y
frc r9.z, r5.y
frc r9.w, r0.y
add r9.xyzw, r9.xyzw, r9.xyzw
mad r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), r9.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r1.yz, r4.zzwz, r4.xxyx
or r1.y, r1.z, r1.y
and r1.y, r1.y, l(1)
iadd r0.x, r0.x, r1.y
round_ni r4.x, r3.y
round_ni r4.y, r2.y
round_ni r4.z, r5.y
round_ni r4.w, r0.y
round_ni r9.x, r8.y
round_ni r9.y, r7.y
round_ni r9.z, r10.y
round_ni r9.w, r6.y
add r4.xyzw, r4.xyzw, r9.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r1.yz, r4.zzwz, r4.xxyx
or r0.y, r1.z, r1.y
and r0.y, r0.y, l(1)
iadd r0.x, r0.y, r0.x
frc r4.x, r8.z
frc r4.y, r7.z
frc r4.z, r10.z
frc r4.w, r6.z
frc r9.x, r3.z
frc r9.y, r2.z
frc r9.z, r5.z
frc r9.w, r0.z
add r9.xyzw, r9.xyzw, r9.xyzw
mad r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), r9.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r1.yz, r4.zzwz, r4.xxyx
or r0.y, r1.z, r1.y
and r0.y, r0.y, l(1)
iadd r0.x, r0.y, r0.x
round_ni r4.x, r8.z
round_ni r4.y, r7.z
round_ni r4.z, r10.z
round_ni r4.w, r6.z
round_ni r9.x, r3.z
round_ni r9.y, r2.z
round_ni r9.z, r5.z
round_ni r9.w, r0.z
add r4.xyzw, r4.xyzw, r9.xyzw
ge r4.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r0.yz, r4.zzwz, r4.xxyx
or r0.y, r0.z, r0.y
and r0.y, r0.y, l(1)
iadd r0.x, r0.y, r0.x
frc r4.x, r3.w
round_ni r3.x, r3.w
frc r4.y, r2.w
round_ni r3.y, r2.w
frc r4.z, r5.w
round_ni r3.z, r5.w
frc r4.w, r0.w
round_ni r3.w, r0.w
add r2.xyzw, r4.xyzw, r4.xyzw
frc r4.x, r8.w
round_ni r5.x, r8.w
frc r4.y, r7.w
round_ni r5.y, r7.w
frc r4.z, r10.w
round_ni r5.z, r10.w
frc r4.w, r6.w
round_ni r5.w, r6.w
add r3.xyzw, r3.xyzw, r5.xyzw
ge r3.xyzw, r3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r0.yz, r3.zzwz, r3.xxyx
or r0.y, r0.z, r0.y
mad r2.xyzw, r4.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), r2.xyzw
ge r2.xyzw, r2.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000)
or r0.zw, r2.zzzw, r2.xxxy
or r0.z, r0.w, r0.z
and r0.yz, r0.yyzy, l(0, 1, 1, 0)
iadd r0.x, r0.z, r0.x
iadd r0.x, r0.y, r0.x
movc r0.xy, r0.xxxx, l(1.000000,-0.500000,0,0), l(0,0.500000,0,0)
movc r0.x, r1.x, r0.y, r0.x
and r0.y, r1.x, l(0x3f800000)
mov r0.zw, l(0,0,0,0)
mul o4.xyzw, r0.xyzw, l(-1.000000, 1.000000, 1.000000, 1.000000)
ret 
// Approximately 173 instruction slots used

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