//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.31 on Wed Mar 02 08:06:56 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
//   float4 CascadeNearFarSnappedOffsetCamera[5];// Offset:   80 Size:    80
//   float4 CascadeNearFarRcpUVSize[5]; // Offset:  160 Size:    80
//   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 CSceneParticleEmitterRendererParameterProvider
// {
//
//   float4 DebugColor;                 // Offset:    0 Size:    16 [unused]
//   float4 FarSoftDistanceRange_oneOverSoftRange;// Offset:   16 Size:    16 [unused]
//   float4 NearFadeDistanceParams;     // Offset:   32 Size:    16
//   float4 SHCoeffB;                   // Offset:   48 Size:    16
//   float4 SHCoeffG;                   // Offset:   64 Size:    16
//   float4 SHCoeffR;                   // Offset:   80 Size:    16
//   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 [unused]
//
// }
//
// 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
//   float Smoothness;                  // Offset:   40 Size:     4 [unused]
//   float Metallic;                    // Offset:   44 Size:     4 [unused]
//   float Reflectance;                 // Offset:   48 Size:     4 [unused]
//
// }
//
// Resource bind info for SkyParamBuffer
// {
//
//   struct ComputedSkyParameters
//   {
//       
//       float r[9];                    // Offset:    0
//       float g[9];                    // Offset:   36
//       float b[9];                    // Offset:   72
//       float3 sunColor;               // Offset:  108
//       float3 moonColor;              // Offset:  120
//
//   } $Element;                        // Offset:    0 Size:   132
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// LinearVolumeSamplerState          sampler      NA          NA    0        1
// SectorHemiMapSamplerStateLinear    sampler      NA          NA    1        1
// SHOccTextureR                     texture  float4          3d    0        1
// SHOccTextureG                     texture  float4          3d    1        1
// SHOccTextureB                     texture  float4          3d    2        1
// SkyParamBuffer                    texture  struct         r/o    3        1
// SectorOcclusion_HeightTexture__TexObj__    texture  float4          2d    4        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
// CSceneParticleEmitterRendererParameterProvider    cbuffer      NA          NA    4        1
// CSceneParticleAttributesParameterProvider    cbuffer      NA          NA    5        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   
// normal                   0   xyzw        4     NONE   float   xyzw
// blendindices             0   xyzw        5     NONE   float   xyz 
// texcoord                 2   x           6     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   xyz         9     NONE   float   xyz 
// TEXCOORD                 8   xyz        10     NONE   float   xyz 
// TEXCOORD                 9   xy         11     NONE   float   xy  
//
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], dynamicIndexed
dcl_constantbuffer cb4[9], immediateIndexed
dcl_constantbuffer cb5[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture3d (float,float,float,float) t0
dcl_resource_texture3d (float,float,float,float) t1
dcl_resource_texture3d (float,float,float,float) t2
dcl_resource_structured t3, 132 
dcl_resource_texture2d (float,float,float,float) t4
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xy
dcl_input v3.x
dcl_input v4.xyzw
dcl_input v5.xyz
dcl_input v6.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.xyz
dcl_output o10.xyz
dcl_output o11.xy
dcl_temps 11

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

ld_indexable(texture2d)(float,float,float,float) r10.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 r1.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 r1.xyz, r1.xyzx, r0.wwww, v0.xyzx
add r2.xyz, r1.xyzx, -cb0[42].xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
mad r1.xyz, r2.xyzx, cb0[54].zzzz, r1.xyzx
add r1.xyz, r1.xyzx, -cb0[42].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
sqrt r1.w, r0.w
add r2.x, r1.w, -cb0[53].z
max r2.x, r2.x, l(0.000000)
add r1.w, r1.w, -r2.x
mad r1.w, r2.x, cb0[53].w, r1.w
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
mul r2.xyz, r1.wwww, r1.xyzx
mad r1.xyz, r1.xyzx, r1.wwww, cb0[42].xyzx
mov r2.w, l(1.000000)
dp4 r3.x, r2.xyzw, cb0[20].xyzw
dp4 r3.y, r2.xyzw, cb0[21].xyzw
dp4 o0.z, r2.xyzw, cb0[22].xyzw
dp4 r3.w, r2.xyzw, cb0[23].xyzw
dp3 r0.x, r0.xyzx, -cb0[48].xyzx
add r0.x, r0.x, -cb0[31].x
add r0.xy, r0.xxxx, -cb4[2].xzxx
div_sat r0.xy, r0.xyxx, cb4[2].ywyy
add o6.w, -r0.y, l(1.000000)
lt r0.yz, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[39].zzwz
and r0.y, r0.z, r0.y
if_nz r0.y
  mov o2.xyzw, l(0,0,0,0)
else 
  dp3 r0.y, r2.xyzx, r2.xyzx
  rsq r0.z, r0.y
  mul r4.yzw, r0.zzzz, r2.yyzx
  mov r4.x, l(1.000000)
  dp4 r5.x, cb0[38].xyzw, r4.xyzw
  dp4 r5.y, cb0[37].xyzw, r4.xyzw
  dp4 r5.z, cb0[36].xyzw, r4.xyzw
  max r5.xyz, r5.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  mad r0.zw, r1.yyyx, cb2[0].yyyx, cb2[0].wwwz
  sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t4.xzyw, s1, l(0.000000)
  mad r0.z, r0.z, cb2[2].x, cb2[2].y
  add r0.z, -r0.z, r1.z
  mul_sat r0.z, -r0.z, cb3[18].x
  sqrt r0.z, r0.z
  dp2 r0.w, r2.xyxx, r2.xyxx
  mad r0.w, cb2[1].x, r0.w, cb2[1].y
  mul_sat r0.w, r0.w, l(3.000000)
  mul r0.z, r0.z, r0.w
  dp4 r6.x, cb3[15].xyzw, r4.xyzw
  dp4 r6.y, cb3[16].xyzw, r4.xyzw
  dp4 r6.z, cb3[17].xyzw, r4.xyzw
  max r4.xyz, r6.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  mad r4.xyz, r4.xyzx, cb0[56].xxxx, -r5.xyzx
  mad r4.xyz, r0.zzzz, r4.xyzx, r5.xyzx
  sqrt r0.y, r0.y
  mad_sat r0.y, r0.y, cb0[35].y, cb0[35].x
  mul r0.z, r2.z, cb0[39].y
  max r0.z, r0.z, l(-125.000000)
  lt r0.w, l(0.000001), |r0.z|
  exp r2.w, -r0.z
  add r2.w, -r2.w, l(1.000000)
  div r0.z, r2.w, r0.z
  movc r0.z, r0.w, r0.z, l(1.000000)
  mad r0.z, r0.z, cb0[39].x, cb0[35].w
  mul r0.y, r0.z, r0.y
  mul r0.y, r0.y, -cb0[35].z
  exp r0.y, r0.y
  mad o2.xyz, -r4.xyzx, r0.yyyy, r4.xyzx
  mov o2.w, r0.y
endif 

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

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

mul r4.xyzw, r3.xyww, cb0[34].xyzw
add o5.xy, r4.zwzz, r4.xyxx
dp3 r0.y, cb0[48].xyzx, r2.xyzx
mul o7.w, r0.y, cb0[31].w
mul o3.w, v1.w, v4.w
mad r0.y, -cb5[2].x, l(0.512821138), l(1.02564228)
add r4.xyz, r1.xyzx, -cb4[8].xyzx
dp3 r0.z, r4.xyzx, r4.xyzx
sqrt r0.z, r0.z
mul_sat r0.z, r0.z, cb5[1].z
add r0.z, -r0.z, l(1.000000)
mul r4.x, r0.z, l(0.886227608)
mul r4.yzw, r0.zzzz, r0.yyyy
mul r5.xyzw, r4.xwww, cb4[5].xyzw
mul r6.xyzw, r4.xwww, cb4[4].xyzw
mul r4.xyzw, r4.xyzw, cb4[3].xyzw
mov r7.x, l(1.000000)
mad r7.yzw, v4.yyzx, l(0.000000, 2.000000, 2.000000, 2.000000), l(0.000000, -1.000000, -1.000000, -1.000000)
dp4 r8.x, r5.xyzw, r7.xyzw
dp4 r8.y, r6.xyzw, r7.xyzw
dp4 r8.z, r4.xyzw, r7.xyzw
max o7.xyz, r8.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov r8.x, l(1.000000)
mad r8.yzw, v4.yyzx, l(0.000000, -2.000000, -2.000000, -2.000000), l(0.000000, 1.000000, 1.000000, 1.000000)
dp4 r5.x, r5.xyzw, r8.xyzw
dp4 r5.y, r6.xyzw, r8.xyzw
dp4 r5.z, r4.xyzw, r8.xyzw
max r0.yzw, r5.xxyz, l(0.000000, 0.000000, 0.000000, 0.000000)
mul o8.xyz, r0.yzwy, cb5[2].yyyy
dp2 r0.y, r2.xyxx, r2.xyxx
sqrt r0.z, r0.y
lt r0.w, r0.z, cb3[2].y
movc r0.w, r0.w, l(2), l(3)
lt r2.x, r0.z, cb3[1].y
movc r0.w, r2.x, l(1), r0.w
lt r2.x, r0.z, cb3[0].y
movc r0.w, r2.x, l(0), r0.w
add r2.xyzw, r1.xyxy, -cb3[r0.w + 5].xyzw
mul r2.xyzw, r2.xyzw, cb3[r0.w + 10].xxyy
utof r3.z, r0.w
add r4.xy, r3.zzzz, l(0.500000, 1.500000, 0.000000, 0.000000)
mul r4.xz, r4.xxyx, l(0.200000, 0.000000, 0.200000, 0.000000)
mov r4.yw, r2.xxxy
sample_l_indexable(texture3d)(float,float,float,float) r5.xyzw, r4.ywxy, t0.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r6.xyzw, r4.ywxy, t1.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r8.xyzw, r4.ywxy, t2.xyzw, s0, l(0.000000)
mov r4.xy, r2.zwzz
sample_l_indexable(texture3d)(float,float,float,float) r2.xyzw, r4.xyzx, t0.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r9.xyzw, r4.xyzx, t1.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r4.xyzw, r4.xyzx, t2.xyzw, s0, l(0.000000)
mad_sat r0.z, r0.z, cb3[r0.w + 0].z, cb3[r0.w + 0].w
add r2.xyzw, -r5.xyzw, r2.xyzw
mad r2.xyzw, r0.zzzz, r2.xyzw, r5.xyzw
add r5.xyzw, -r6.xyzw, r9.xyzw
mad r5.xyzw, r0.zzzz, r5.xyzw, r6.xyzw
add r4.xyzw, -r8.xyzw, r4.xyzw
mad r4.xyzw, r0.zzzz, r4.xyzw, r8.xyzw
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r6.xyzw, l(0), l(108), t3.xywz
dp3 r0.z, r6.xywx, l(0.212600, 0.715200, 0.072200, 0.000000)
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r6.xy, l(0), l(124), t3.xyxx
dp3 r0.w, r6.zxyz, l(0.212600, 0.715200, 0.072200, 0.000000)
max r0.z, r0.w, r0.z
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r0.w, l(0), l(0), t3.xxxx
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r3.z, l(0), l(36), t3.xxxx
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r6.x, l(0), l(72), t3.xxxx
max r3.z, r3.z, r6.x
max r0.w, r0.w, r3.z
add r0.z, r0.w, r0.z
mul r2.xyzw, r0.zzzz, r2.xyzw
mul r5.xyzw, r0.zzzz, r5.xyzw
mul r4.xyzw, r0.zzzz, r4.xyzw
mul r6.xyzw, r7.xyzw, l(0.282094806, 0.488602519, 0.488602519, 0.488602519)
dp4 r2.x, r2.xyzw, r6.xyzw
dp4 r2.y, r5.xyzw, r6.xyzw
dp4 r2.z, r4.xyzw, r6.xyzw
max r2.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
dp4 r4.x, cb3[15].xyzw, r6.xyzw
dp4 r4.y, cb3[16].xyzw, r6.xyzw
dp4 r4.z, cb3[17].xyzw, r6.xyzw
max r4.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r0.zw, r1.yyyx, cb2[0].yyyx, cb2[0].wwwz
sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t4.xzyw, s1, l(0.000000)
mad r0.z, r0.z, cb2[2].x, cb2[2].y
add r0.z, -r0.z, r1.z
mul_sat r0.z, -r0.z, cb3[18].x
sqrt r0.z, r0.z
mad r0.y, cb2[1].x, r0.y, cb2[1].y
mul_sat r0.y, r0.y, l(3.000000)
mul r0.y, r0.z, r0.y
add r4.xyz, -r2.xyzx, r4.xyzx
mad o9.xyz, r0.yyyy, r4.xyzx, r2.xyzx
mov r1.w, l(1.000000)
dp4 o1.x, cb1[0].xyzw, r1.xyzw
mul o10.xyz, v5.xyzx, cb4[7].xxxx

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

mov o3.xyz, v1.xyzx
mov o4.xyz, r1.xyzx
mov o4.w, v3.x
mov o5.z, r3.w
mov o5.w, r0.x
mad o6.xyz, v4.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mov o8.w, v6.x
mov o11.xy, v2.xyxx
ret 
// Approximately 183 instruction slots used