//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.31 on Wed Mar 02 08:07:15 2016
//
//
// Buffer Definitions: 
//
// cbuffer CViewportShaderParameterProvider
// {
//
//   float4x4 InvProjectionMatrix;      // Offset:    0 Size:    64 [unused]
//   float4x4 InvViewMatrix;            // Offset:   64 Size:    64 [unused]
//   float4x4 ProjectionMatrix;         // Offset:  128 Size:    64 [unused]
//   float4x4 ViewMatrix;               // Offset:  192 Size:    64 [unused]
//   float4x4 ViewProjectionMatrix;     // Offset:  256 Size:    64 [unused]
//   float4x4 ViewRotProjectionMatrix;  // Offset:  320 Size:    64
//   float4x4 ViewRotProjectionMatrix_Previous;// Offset:  384 Size:    64 [unused]
//   float4 AmbientSHR;                 // Offset:  448 Size:    16 [unused]
//   float4 AmbientSHG;                 // Offset:  464 Size:    16 [unused]
//   float4 AmbientSHB;                 // Offset:  480 Size:    16 [unused]
//   float4 CameraDistances;            // Offset:  496 Size:    16
//   float4 CameraNearPlaneSize;        // Offset:  512 Size:    16 [unused]
//   float4 DepthScale;                 // Offset:  528 Size:    16 [unused]
//   float4 DepthTextureScaleOffset;    // Offset:  544 Size:    16
//   float4 FogParams;                  // Offset:  560 Size:    16
//   float4 FogSHB;                     // Offset:  576 Size:    16
//   float4 FogSHG;                     // Offset:  592 Size:    16
//   float4 FogSHR;                     // Offset:  608 Size:    16
//   float4 HeightFogParams;            // Offset:  624 Size:    16
//   float4 ViewportSize;               // Offset:  640 Size:    16 [unused]
//   float3 ViewPoint;                  // Offset:  656 Size:    12 [unused]
//   float3 CameraPosition;             // Offset:  672 Size:    12
//   float3 CameraPosition_Previous;    // Offset:  688 Size:    12 [unused]
//   float3 CameraPositionFractions;    // Offset:  704 Size:    12 [unused]
//   float3 CameraPositionFractions_Previous;// Offset:  720 Size:    12 [unused]
//   float3 CameraRight;                // Offset:  736 Size:    12 [unused]
//   float3 CameraUp;                   // Offset:  752 Size:    12 [unused]
//   float3 CameraDirection;            // Offset:  768 Size:    12
//   float3 EnvironmentMapColorOffset;  // Offset:  784 Size:    12 [unused]
//   float3 EnvironmentMapColorScale;   // Offset:  800 Size:    12 [unused]
//   float3 AmbientOcclusionRanges;     // Offset:  816 Size:    12 [unused]
//   float3 DepthTextureRcpSize;        // Offset:  832 Size:    12 [unused]
//   float2 MotionVectorOffsets;        // Offset:  848 Size:     8 [unused]
//   float2 DepthRangeCompression;      // Offset:  856 Size:     8
//   float ShadowProjDepthMinValue;     // Offset:  864 Size:     4 [unused]
//   float DistanceScale;               // Offset:  868 Size:     4 [unused]
//   float WorldSpaceZOffset;           // Offset:  872 Size:     4
//   float WorldSpaceZOffset_Previous;  // Offset:  876 Size:     4 [unused]
//   float CameraFOVDeg;                // Offset:  880 Size:     4 [unused]
//   float EffectsEmissiveEVBias;       // Offset:  884 Size:     4 [unused]
//   float ShadowCSMLastSliceIndex;     // Offset:  888 Size:     4 [unused]
//   float UseNormalization;            // Offset:  892 Size:     4 [unused]
//   float FogUndergroundColorScale;    // Offset:  896 Size:     4
//
// }
//
// cbuffer CUserClipPlaneParameterProvider
// {
//
//   float4 UserClipPlane;              // Offset:    0 Size:    16
//
// }
//
// cbuffer CSceneTerrainSkyOcclusionAtlasPrivateData
// {
//
//   float4 SectorOcclusion_OffsetScale;// Offset:    0 Size:    16
//   float3 SectorOcclusion_DistanceFade;// Offset:   16 Size:    12
//   float2 SectorOcclusion_HeightOffsetScale;// Offset:   32 Size:     8
//
// }
//
// cbuffer CAmbientProvider
// {
//
//   float4 CascadeDistanceScales[5];   // Offset:    0 Size:    80 [unused]
//   float4 CascadeNearFarSnappedOffsetCamera[5];// Offset:   80 Size:    80 [unused]
//   float4 CascadeNearFarRcpUVSize[5]; // Offset:  160 Size:    80 [unused]
//   float4 UndergroundSHR;             // Offset:  240 Size:    16
//   float4 UndergroundSHG;             // Offset:  256 Size:    16
//   float4 UndergroundSHB;             // Offset:  272 Size:    16
//   float InvUndergroundBlendEndHeight;// Offset:  288 Size:     4
//   float IndirectLightingScale;       // Offset:  292 Size:     4 [unused]
//
// }
//
// cbuffer CWaterCameraPlaneParameterProvider
// {
//
//   float4 QuadParams;                 // Offset:    0 Size:    16 [unused]
//   float4 UnderwaterCaustics;         // Offset:   16 Size:    16 [unused]
//   float4 UnderwaterExtinctions;      // Offset:   32 Size:    16
//   float3 UnderwaterColorDeep;        // Offset:   48 Size:    12
//   float3 UnderwaterColorShallow;     // Offset:   64 Size:    12
//   float CausticsIntensity;           // Offset:   76 Size:     4 [unused]
//   float WaterLevel;                  // Offset:   80 Size:     4
//
// }
//
// cbuffer CSceneParticleEmitterRendererParameterProvider
// {
//
//   float4 DebugColor;                 // Offset:    0 Size:    16 [unused]
//   float4 FarSoftDistanceRange_oneOverSoftRange;// Offset:   16 Size:    16 [unused]
//   float4 NearFadeDistanceParams;     // Offset:   32 Size:    16 [unused]
//   float4 SHCoeffB;                   // Offset:   48 Size:    16 [unused]
//   float4 SHCoeffG;                   // Offset:   64 Size:    16 [unused]
//   float4 SHCoeffR;                   // Offset:   80 Size:    16 [unused]
//   float4 SoftClipPlane;              // Offset:   96 Size:    16 [unused]
//   float2 EmitterAttributes;          // Offset:  112 Size:     8
//   float2 UVNormalScale;              // Offset:  120 Size:     8 [unused]
//   float3 EmitterWorldPos;            // Offset:  128 Size:    12
//   bool AlphaInRedChannel;            // Offset:  140 Size:     4 [unused]
//   float3 LightColorUpNormalUnderwater;// Offset:  144 Size:    12
//
// }
//
// cbuffer CSceneParticleAttributesParameterProvider
// {
//
//   float4 DistortionSpeedTiling;      // Offset:    0 Size:    16 [unused]
//   float4 ParticleAttributes0;        // Offset:   16 Size:    16
//   float ForwardScattering;           // Offset:   32 Size:     4
//   float BackScattering;              // Offset:   36 Size:     4 [unused]
//   float Smoothness;                  // Offset:   40 Size:     4 [unused]
//   float Metallic;                    // Offset:   44 Size:     4 [unused]
//   float Reflectance;                 // Offset:   48 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SectorHemiMapSamplerStateLinear    sampler      NA          NA    0        1
// SectorOcclusion_HeightTexture__TexObj__    texture  float4          2d    0        1
// CViewportShaderParameterProvider    cbuffer      NA          NA    0        1
// CUserClipPlaneParameterProvider    cbuffer      NA          NA    1        1
// CSceneTerrainSkyOcclusionAtlasPrivateData    cbuffer      NA          NA    2        1
// CAmbientProvider                  cbuffer      NA          NA    3        1
// CWaterCameraPlaneParameterProvider    cbuffer      NA          NA    4        1
// CSceneParticleEmitterRendererParameterProvider    cbuffer      NA          NA    5        1
// CSceneParticleAttributesParameterProvider    cbuffer      NA          NA    6        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// position                 0   xyzw        0     NONE   float   xyz 
// color                    0   xyzw        1     NONE   float   xyzw
// texcoord                 0   xy          2     NONE   float   xy  
// texcoord                 1   x           3     NONE   float   x   
// blendweight              0   xyzw        4     NONE   float   xyz 
// normal                   0   xyzw        5     NONE   float   xyzw
// fog                      0   xyzw        6     NONE   float   xyz 
// psize                    0   xyzw        7     NONE   float   xyz 
// blendindices             0   xyzw        8     NONE   float   xyz 
// texcoord                 2   x           9     NONE   float   x   
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// SV_ClipDistance          0   x           1  CLIPDST   float   x   
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float   xyzw
// TEXCOORD                 3   xyzw        5     NONE   float   xyzw
// TEXCOORD                 4   xyzw        6     NONE   float   xyzw
// TEXCOORD                 5   xyzw        7     NONE   float   xyzw
// TEXCOORD                 6   xyzw        8     NONE   float   xyzw
// TEXCOORD                 7   xyzw        9     NONE   float   xyzw
// TEXCOORD                 8   xyz        10     NONE   float   xyz 
// TEXCOORD                 9   xyz        11     NONE   float   xyz 
// TEXCOORD                10   xyz        12     NONE   float   xyz 
// TEXCOORD                11   xyzw       13     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[57], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_constantbuffer cb3[19], immediateIndexed
dcl_constantbuffer cb4[6], immediateIndexed
dcl_constantbuffer cb5[10], immediateIndexed
dcl_constantbuffer cb6[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xy
dcl_input v3.x
dcl_input v4.xyz
dcl_input v5.xyzw
dcl_input v6.xyz
dcl_input v7.xyz
dcl_input v8.xyz
dcl_input v9.x
dcl_output_siv o0.xyzw, position
dcl_output_siv o1.x, clip_distance
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output o8.xyzw
dcl_output o9.xyzw
dcl_output o10.xyz
dcl_output o11.xyz
dcl_output o12.xyz
dcl_output o13.xyzw
dcl_temps 7

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

ld_indexable(texture2d)(float,float,float,float) r6.xyzw, l(0, 0, 0, 0), t125.xyzw

add r0.xyz, -v0.xyzx, cb0[42].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r0.w, r0.w
div r0.xyz, r0.xyzx, r0.wwww
add r0.w, r0.w, l(-2000.000000)
mul_sat r0.w, r0.w, l(0.000333333330)
mul r0.w, r0.w, l(250.000000)
mad r0.xyz, r0.xyzx, r0.wwww, v0.xyzx
add r1.xyz, r0.xyzx, -cb0[42].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
mad r0.xyz, r1.xyzx, cb0[54].zzzz, r0.xyzx
add r0.xyz, r0.xyzx, -cb0[42].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r1.x, r0.w
add r1.y, r1.x, -cb0[53].z
max r1.y, r1.y, l(0.000000)
add r1.x, -r1.y, r1.x
mad r1.x, r1.y, cb0[53].w, r1.x
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r2.xyz, r1.xxxx, r0.xyzx
mad r0.xyz, r0.xyzx, r1.xxxx, cb0[42].xyzx
mov r2.w, l(1.000000)
dp4 r1.x, r2.xyzw, cb0[20].xyzw
dp4 r1.y, r2.xyzw, cb0[21].xyzw
dp4 o0.z, r2.xyzw, cb0[22].xyzw
dp4 r1.w, r2.xyzw, cb0[23].xyzw
mad o7.xyz, v5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
lt r3.xy, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[39].zwzz
and r1.z, r3.y, r3.x
if_nz r1.z
  mov o2.xyzw, l(0,0,0,0)
else 
  dp3 r1.z, r2.xyzx, r2.xyzx
  rsq r2.w, r1.z
  mul r3.yzw, r2.wwww, r2.yyzx
  mov r3.x, l(1.000000)
  dp4 r4.x, cb0[38].xyzw, r3.xyzw
  dp4 r4.y, cb0[37].xyzw, r3.xyzw
  dp4 r4.z, cb0[36].xyzw, r3.xyzw
  max r4.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  mad r5.xy, r0.yxyy, cb2[0].yxyy, cb2[0].wzww
  sample_l_indexable(texture2d)(float,float,float,float) r2.w, r5.xyxx, t0.xzwy, s0, l(0.000000)
  mad r2.w, r2.w, cb2[2].x, cb2[2].y
  add r2.w, r0.z, -r2.w
  mul_sat r2.w, -r2.w, cb3[18].x
  sqrt r2.w, r2.w
  dp2 r4.w, r2.xyxx, r2.xyxx
  mad r4.w, cb2[1].x, r4.w, cb2[1].y
  mul_sat r4.w, r4.w, l(3.000000)
  mul r2.w, r2.w, r4.w
  dp4 r5.x, cb3[15].xyzw, r3.xyzw
  dp4 r5.y, cb3[16].xyzw, r3.xyzw
  dp4 r5.z, cb3[17].xyzw, r3.xyzw
  max r3.xyz, r5.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  mad r3.xyz, r3.xyzx, cb0[56].xxxx, -r4.xyzx
  mad r3.xyz, r2.wwww, r3.xyzx, r4.xyzx
  sqrt r1.z, r1.z
  mad_sat r1.z, r1.z, cb0[35].y, cb0[35].x
  mul r2.w, r2.z, cb0[39].y
  max r2.w, r2.w, l(-125.000000)
  lt r3.w, l(0.000001), |r2.w|
  exp r4.x, -r2.w
  add r4.x, -r4.x, l(1.000000)
  div r2.w, r4.x, r2.w
  movc r2.w, r3.w, r2.w, l(1.000000)
  mad r2.w, r2.w, cb0[39].x, cb0[35].w
  mul r1.z, r1.z, r2.w
  mul r1.z, r1.z, -cb0[35].z
  exp r1.z, r1.z
  mad o2.xyz, -r3.xyzx, r1.zzzz, r3.xyzx
  mov o2.w, r1.z
endif 

// Relocated to here with asmtool.py
mov o0.xyw, r1.xyxw

// Automatic vertex shader halo fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -i --auto-fix-vertex-halo --only-autofixed c2b2f619ad936b5c-vs.txt
ne r6.w, r1.w, l(1.0)
if_nz r6.w
  add r6.w, r1.w, -r6.y
  mad r1.x, r6.w, r6.x, r1.x
endif

mul r3.xyzw, r1.xyww, cb0[34].xyzw
add o6.xy, r3.zwzz, r3.xyxx
dp3 r1.z, cb0[48].xyzx, r2.xyzx
mul o7.w, r1.z, cb0[31].w
mul o3.w, v1.w, v5.w
mad o9.xyz, v6.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r1.z, -cb6[2].x, l(0.512821138), l(1.02564228)
add r3.xyz, r0.xyzx, -cb5[8].xyzx
dp3 r2.w, r3.xyzx, r3.xyzx
sqrt r2.w, r2.w
mul_sat r2.w, r2.w, cb6[1].z
add r2.w, -r2.w, l(1.000000)
mul o4.x, r2.w, l(0.886227608)
mul o4.yzw, r1.zzzz, r2.wwww
mov r0.w, l(1.000000)
dp4 o1.x, cb1[0].xyzw, r0.xyzw
mul o10.xyz, v8.xyzx, cb5[7].xxxx
dp3 r0.w, r2.xyzx, r2.xyzx
sqrt r0.w, r0.w
mul r1.z, r0.w, -cb4[2].z
exp r1.z, r1.z
add r2.z, -r0.z, cb4[5].x
mul r2.z, r2.z, -cb4[2].w
exp r2.z, r2.z
min r2.z, r2.z, l(1.000000)
mul o9.w, r1.z, r2.z
mul r0.w, r0.w, l(-0.0432808511)
exp r0.w, r0.w
add r0.w, -r0.w, l(1.000000)
add r3.xyz, cb4[3].xyzx, -cb4[4].xyzx
mad o11.xyz, r0.wwww, r3.xyzx, cb4[4].xyzx
mad r2.zw, r0.yyyx, cb2[0].yyyx, cb2[0].wwwz
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r2.zwzz, t0.xzwy, s0, l(0.000000)
mad r0.w, r0.w, cb2[2].x, cb2[2].y
add r0.w, -r0.w, r0.z
mul_sat r0.w, -r0.w, cb3[18].x
sqrt r0.w, r0.w
dp2 r1.z, r2.xyxx, r2.xyxx
mad r1.z, cb2[1].x, r1.z, cb2[1].y
mul_sat r1.z, r1.z, l(3.000000)
mad r0.w, -r1.z, r0.w, l(1.000000)
mul o12.xyz, r0.wwww, cb5[9].xyzx

// mov o0.xyw, r1.xyxw // Relocated from here with asmtool.py

mov o3.xyz, v1.xyzx
mov o5.xyz, r0.xyzx
mov o5.w, v3.x
mov o6.z, r1.w
mov o6.w, v4.z
mad o8.xyz, v7.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mov o8.w, v9.x
mov o13.xy, v2.xyxx
mov o13.zw, v4.xxxy
ret 
// Approximately 128 instruction slots used