// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 1452e467b8a95db6-ps.txt
// 3DMigoto: 1452e467b8a95db6 |    Unity headers extracted from Midnight Hub_Nature_Terrain PBS
//    Shader "Midnight Hub/Nature/Terrain PBS" {
//      CustomEditor "Rendering.Materials.MaterialFixer"
//      Fallback "Diffuse"
//      SubShader 1/1 {
//        Tags { "RenderType"="1500" }
//        Pass 2/4 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDADD" "RenderType"="1500" "SHADOWSUPPORT"="true" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Midnight Hub_Nature_Terrain PBS:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 156 14 5
//   undeciphered1a: 11
//   Keywords { "SPOT" "SHADOWS_DEPTH" "SHADOWS_SOFT" }
//   undeciphered2: 1 15 6 15 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1344
//   Vector 32 [_LightColor0]
//   Vector 1248 [_RoughnessMult2]
//   Vector 1264 [_RoughnessMult1]
//   Vector 1280 [_RoughnessMult0]
//   Matrix 1168 [unity_WorldToLight]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   Matrix 128 [unity_WorldToShadow0]
//   Matrix 192 [unity_WorldToShadow1]
//   Matrix 256 [unity_WorldToShadow2]
//   Matrix 320 [unity_WorldToShadow3]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_Control] 2D 5
//   SetTexture 1 [_Splat0] 2D 6
//   SetTexture 2 [_Splat1] 2D 7
//   SetTexture 3 [_Splat2] 2D 8
//   SetTexture 4 [_Normal0] 2D 9
//   SetTexture 5 [_Normal1] 2D 10
//   SetTexture 6 [_Normal2] 2D 11
//   SetTexture 7 [_Roughness0] 2D 12
//   SetTexture 8 [_Roughness1] 2D 13
//   SetTexture 9 [_Roughness2] 2D 14
//   SetTexture 10 [unity_RandomRotation16] 2D 1
//   SetTexture 11 [_LightTexture0] 2D 3
//   SetTexture 12 [_LightTextureB0] 2D 4
//   SetTexture 13 [unity_ProbeVolumeSH] 3D 0
//   SetTexture 14 [_ShadowMapTexture] 2D 2
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityProbeVolume" 5
//
// Headers extracted with DarkStarSword's extract_unity55_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sun Apr 21 17:52:14 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xy          2     NONE   float   xy
// TEXCOORD                 6     zw        2     NONE   float     zw
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xyz         4     NONE   float   xyz
// TEXCOORD                 4   xyz         5     NONE   float   xyz
// TEXCOORD                 5   xyz         6     NONE   float   xyz
// TEXCOORD                 7   xy          7     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_immediateConstantBuffer { { -0.635181785, 0.217271104, 0, 0},
                              { -0.149960607, 0.232067496, 0, 0},
                              { -0.679780, 0.688492417, 0, 0},
                              { -0.775864720, -0.253409, 0, 0},
                              { -0.473191589, -0.283272296, 0, 0},
                              { -0.333007902, 0.643005908, 0, 0},
                              { -0.138415098, -0.0983022526, 0, 0},
                              { -0.818232715, -0.564593911, 0, 0},
                              { -0.919847190, 0.0654980168, 0, 0},
                              { -0.142208502, -0.487210900, 0, 0},
                              { -0.498083293, -0.588559926, 0, 0},
                              { -0.332615912, -0.849614799, 0, 0},
                              { 0.306673586, -0.140199706, 0, 0},
                              { 0.114831701, 0.374455, 0, 0},
                              { -0.0388568006, 0.807132900, 0, 0},
                              { 0.410288513, 0.696029484, 0, 0},
                              { 0.556387722, 0.337537706, 0, 0},
                              { -0.0178657603, -0.887376487, 0, 0},
                              { 0.234991, -0.455843806, 0, 0},
                              { 0.620677471, -0.155100495, 0, 0},
                              { 0.664064229, -0.569142699, 0, 0},
                              { 0.731272578, 0.583016813, 0, 0},
                              { 0.887970686, 0.0571521297, 0, 0},
                              { 0.312829614, -0.830803, 0, 0},
                              { 0.868976414, -0.339797288, 0, 0} }
dcl_constantbuffer cb0[81], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_comparison
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, mode_default
dcl_sampler s8, mode_default
dcl_sampler s9, mode_default
dcl_sampler s10, mode_default
dcl_sampler s11, mode_default
dcl_sampler s12, mode_default
dcl_sampler s13, mode_default
dcl_sampler s14, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t11
dcl_resource_texture2d (float,float,float,float) t12
dcl_resource_texture3d (float,float,float,float) t13
dcl_resource_texture2d (float,float,float,float) t14
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xy
dcl_input_ps linear v2.zw
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps linear v5.xyz
dcl_input_ps linear v6.xyz
dcl_output o0.xyzw
dcl_temps 13
dcl_constantbuffer cb10[4], immediateIndexed

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

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


// Unity reflection/specular fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 1452e467b8a95db6-ps.txt

mul r11.w, -r11.x, r11.y
mad r12.xyz, -r11.wwww, cb10[0].xyzw, cb1[4].xyzw

add r0.xyz, -v6.xyzx, cb2[0].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r0.xyzx
add r2.xyz, -v6.xyzx, r12.xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, r2.xyzx
sample r4.xyzw, v2.zwzz, t0.xyzw, s5
dp4 r1.w, r4.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
add r4.xw, r1.wwww, l(-0.003900, 0.000000, 0.000000, 0.001000)
lt r1.w, r4.x, l(0.000000)
discard_nz r1.w
div r4.xy, r4.yzyy, r4.wwww
sample r5.xyzw, v1.xyxx, t1.xyzw, s6
sample r6.xyzw, v1.zwzz, t2.xyzw, s7
sample r7.xyzw, v2.xyxx, t3.xyzw, s8
mul r1.w, r4.x, r6.w
mad_sat r1.w, r1.w, l(10.000000), r4.x
mul r2.w, r4.y, r7.w
mad_sat r2.w, r2.w, l(10.000000), r4.y
add r4.xyz, -r5.xyzx, r6.xyzx
mad r4.xyz, r1.wwww, r4.xyzx, r5.xyzx
add r5.xyz, -r4.xyzx, r7.xyzx
mad r4.xyz, r2.wwww, r5.xyzx, r4.xyzx
sample r5.xyzw, v1.xyxx, t4.xyzw, s9
sample r6.xyzw, v1.zwzz, t5.xyzw, s10
sample r7.xyzw, v2.xyxx, t6.xyzw, s11
add r5.xz, -r5.wwyw, r6.wwyw
mad r5.xy, r1.wwww, r5.xzxx, r5.wyww
add r5.zw, -r5.xxxy, r7.wwwy
mad r5.xy, r2.wwww, r5.zwzz, r5.xyxx
mad r5.xy, r5.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r3.w, r5.xyxx, r5.xyxx
min r3.w, r3.w, l(1.000000)
add r3.w, -r3.w, l(1.000000)
sqrt r5.z, r3.w
sample r6.xyzw, v1.xyxx, t7.xyzw, s12
sample r7.xyzw, v1.zwzz, t8.xyzw, s13
sample r8.xyzw, v2.xyxx, t9.xyzw, s14
mul r6.xy, r6.xyxx, cb0[80].xyxx
mad r6.zw, r7.xxxy, cb0[79].xxxy, -r6.xxxy
mad r6.xy, r1.wwww, r6.zwzz, r6.xyxx
mad r6.zw, r8.xxxy, cb0[78].xxxy, -r6.xxxy
mad r6.xy, r2.wwww, r6.zwzz, r6.xyxx
mul r7.xyzw, v6.yyyy, cb0[74].xyzw
mad r7.xyzw, cb0[73].xyzw, v6.xxxx, r7.xyzw
mad r7.xyzw, cb0[75].xyzw, v6.zzzz, r7.xyzw
add r7.xyzw, r7.xyzw, cb0[76].xyzw
mov r8.x, cb4[9].z
mov r8.y, cb4[10].z
mov r8.z, cb4[11].z
dp3 r1.w, r2.xyzx, r8.xyzx
add r2.xyz, v6.xyzx, -cb3[25].xyzx
dp3 r2.x, r2.xyzx, r2.xyzx
sqrt r2.x, r2.x
add r2.x, -r1.w, r2.x
mad r1.w, cb3[25].w, r2.x, r1.w
mad_sat r1.w, r1.w, cb3[24].z, cb3[24].w
eq r2.x, cb5[0].x, l(1.000000)
if_nz r2.x
  eq r2.x, cb5[0].y, l(1.000000)
  mul r2.yzw, v6.yyyy, cb5[2].xxyz
  mad r2.yzw, cb5[1].xxyz, v6.xxxx, r2.yyzw
  mad r2.yzw, cb5[3].xxyz, v6.zzzz, r2.yyzw
  add r2.yzw, r2.yyzw, cb5[4].xxyz
  movc r2.xyz, r2.xxxx, r2.yzwy, v6.xyzx
  add r2.xyz, r2.xyzx, -cb5[6].xyzx
  mul r2.yzw, r2.xxyz, cb5[5].xxyz
  mad r2.y, r2.y, l(0.250000), l(0.750000)
  mad r3.w, cb5[0].z, l(0.500000), l(0.750000)
  max r2.x, r2.y, r3.w
  sample r2.xyzw, r2.xzwx, t13.xyzw, s0
else
  mov r2.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r2.x, r2.xyzw, cb2[45].xyzw
lt r2.y, r1.w, l(0.990000)
if_nz r2.y
  mul r8.xyzw, v6.yyyy, cb3[9].xyzw
  mad r8.xyzw, cb3[8].xyzw, v6.xxxx, r8.xyzw
  mad r8.xyzw, cb3[10].xyzw, v6.zzzz, r8.xyzw
  add r8.xyzw, r8.xyzw, cb3[11].xyzw
  div r2.yzw, r8.xxyz, r8.wwww
  mul r6.zw, r2.yyyz, l(0.000000, 0.000000, 10.000000, 10.000000)
  sample r8.xyzw, r6.zwzz, t10.xyzw, s1
  dp3 r3.w, r8.xyzx, l(12.989800, 78.233002, 45.543201, 0.000000)
  sincos r3.w, null, r3.w
  mul r3.w, r3.w, l(43758.546875)
  frc r3.w, r3.w
  mul r3.w, r3.w, l(10.000000)
  sincos r8.x, r9.x, r3.w
  add r3.w, -cb3[24].x, l(1.000000)
  mul r3.w, r3.w, l(0.025000)
  mov r4.w, l(0)
  mov r5.w, l(0)
  loop
    itof r6.z, r5.w
    ge r6.z, r6.z, l(25.000000)
    breakc_nz r6.z
    mul r6.zw, r9.xxxx, icb[r5.w + 0].xxxy
    mad r10.x, icb[r5.w + 0].y, r8.x, r6.z
    mad r10.y, icb[r5.w + 0].x, -r8.x, r6.w
    mad r6.zw, r10.xxxy, r3.wwww, r2.yyyz
    sample_c_lz r6.z, r6.zwzz, t14.xxxx, s2, r2.w
    add r4.w, r4.w, r6.z
    iadd r5.w, r5.w, l(1)
  endloop
  mul r2.y, r4.w, l(0.040000)
else
  mov r2.y, l(1.000000)
endif
add r2.x, -r2.y, r2.x
mad r1.w, r1.w, r2.x, r2.y
lt r2.x, l(0.000000), r7.z
and r2.x, r2.x, l(0x3f800000)
div r2.yz, r7.xxyx, r7.wwww
add r2.yz, r2.yyzy, l(0.000000, 0.500000, 0.500000, 0.000000)
sample r8.xyzw, r2.yzyy, t11.xyzw, s3
mul r2.x, r2.x, r8.w
dp3 r2.y, r7.xyzx, r7.xyzx
sample r7.xyzw, r2.yyyy, t12.xyzw, s4
mul r2.x, r2.x, r7.x
mul r1.w, r1.w, r2.x
dp3 r2.x, v3.xyzx, r5.xyzx
dp3 r2.y, v4.xyzx, r5.xyzx
dp3 r2.z, v5.xyzx, r5.xyzx
mul r5.xyz, r1.wwww, cb0[2].xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r2.xyzx
add r7.xyz, r4.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r7.xyz, r6.xxxx, r7.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r1.w, -r6.x, l(0.960000), l(0.960000)
mul r4.xyz, r1.wwww, r4.xyzx
add r1.w, -r6.y, l(1.000000)
mad r0.xyz, r0.xyzx, r0.wwww, r3.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
max r0.w, r0.w, l(0.001000)
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r0.w, r2.xyzx, r3.xyzx
dp3_sat r2.w, r2.xyzx, r1.xyzx
dp3_sat r2.x, r2.xyzx, r0.xyzx
dp3_sat r0.x, r1.xyzx, r0.xyzx
mul r0.y, r0.x, r0.x
dp2 r0.y, r0.yyyy, r1.wwww
add r0.y, r0.y, l(-0.500000)
add r0.z, -r2.w, l(1.000000)
mul r1.x, r0.z, r0.z
mul r1.x, r1.x, r1.x
mul r0.z, r0.z, r1.x
mad r0.z, r0.y, r0.z, l(1.000000)
add r1.x, -|r0.w|, l(1.000000)
mul r1.y, r1.x, r1.x
mul r1.y, r1.y, r1.y
mul r1.x, r1.x, r1.y
mad r0.y, r0.y, r1.x, l(1.000000)
mul r0.y, r0.y, r0.z
mul r0.z, r1.w, r1.w
mad r1.x, -r1.w, r1.w, l(1.000000)
mad r1.y, |r0.w|, r1.x, r0.z
mad r1.x, r2.w, r1.x, r0.z
mul r0.w, |r0.w|, r1.x
mad r0.w, r2.w, r1.y, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r0.z, r0.z, r0.z
mad r1.x, r2.x, r0.z, -r2.x
mad r1.x, r1.x, r2.x, l(1.000000)
mul r0.z, r0.z, l(0.318309873)
mad r1.x, r1.x, r1.x, l(1.000000012E-007)
div r0.z, r0.z, r1.x
mul r0.z, r0.z, r0.w
mul r0.z, r0.z, l(3.14159274)
mul r0.yz, r2.wwww, r0.yyzy
max r0.z, r0.z, l(0.000000)
dp3 r0.w, r7.xyzx, r7.xyzx
ne r0.w, r0.w, l(0.000000)
and r0.w, r0.w, l(0x3f800000)
mul r0.z, r0.w, r0.z
mul r1.xyz, r0.yyyy, r5.xyzx
mul r0.yzw, r5.xxyz, r0.zzzz
add r0.x, -r0.x, l(1.000000)
mul r1.w, r0.x, r0.x
mul r1.w, r1.w, r1.w
mul r0.x, r0.x, r1.w
add r2.xyz, -r7.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r2.xyz, r2.xyzx, r0.xxxx, r7.xyzx
mul r0.xyz, r0.yzwy, r2.xyzx
mad o0.xyz, r4.xyzx, r1.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used