// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed f66d686ce4412cce-ps.txt
// 3DMigoto: f66d686ce4412cce |    Unity headers extracted from Midnight Hub_Nature_Cliff
//    Shader "Midnight Hub/Nature/Cliff" {
//      CustomEditor "Rendering.Materials.StandarMaterialEditor"
//      Fallback "Diffuse"
//      SubShader 1/1 {
//        Pass 2/5 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDADD" "SHADOWSUPPORT"="true" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Midnight Hub_Nature_Cliff:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 161 11 5
//   undeciphered1a: 13
//   Keywords { "SPOT" "SHADOWS_DEPTH" "SHADOWS_SOFT" "LOD_FADE_CROSSFADE" }
//   undeciphered2: 1 12 7 12 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1376
//   Vector 32 [_LightColor0]
//   Float 1232 [_MetalnessMult]
//   Float 1236 [_ShininessMult]
//   Vector 1248 [_Normal_ST]
//   Vector 1280 [_Color]
//   Vector 1312 [_DetailNormal_ST]
//   Float 1360 [_Cutoff]
//   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 "UnityPerDraw" 160
//   Vector 128 [unity_LODFade]
//   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 [_Normal] 2D 6
//   SetTexture 1 [_MainTex] 2D 7
//   SetTexture 2 [_Roughness] 2D 8
//   SetTexture 3 [_DitherMaskLOD2D] 2D 1
//   SetTexture 4 [_DetailAlbedo] 2D 9
//   SetTexture 5 [_DetailNormal] 2D 10
//   SetTexture 6 [_DetailRoughness] 2D 11
//   SetTexture 7 [unity_RandomRotation16] 2D 2
//   SetTexture 8 [_LightTexture0] 2D 4
//   SetTexture 9 [_LightTextureB0] 2D 5
//   SetTexture 10 [unity_ProbeVolumeSH] 3D 0
//   SetTexture 11 [_ShadowMapTexture] 2D 3
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerDraw" 4
//   BindCB "UnityPerFrame" 5
//   BindCB "UnityProbeVolume" 6
//
// 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 18:04:22 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float   xy
// TEXCOORD                 6     zw        1     NONE   float
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// 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
//
//
// 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[86], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[9], immediateIndexed
dcl_constantbuffer cb5[12], immediateIndexed
dcl_constantbuffer cb6[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_comparison
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_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_texture3d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t11
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
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 15
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r13.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 f66d686ce4412cce-ps.txt

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

add r0.xyz, -v5.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, -v5.xyzx, r14.xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, r2.xyzx
mad r4.xy, v1.xyxx, cb0[78].xyxx, cb0[78].zwzz
sample r5.xyzw, r4.xyxx, t0.xyzw, s6
mad r5.xy, r5.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r1.w, r5.xyxx, r5.xyxx
min r1.w, r1.w, l(1.000000)
add r1.w, -r1.w, l(1.000000)
sqrt r6.x, r1.w
sample r7.xyzw, r4.xyxx, t1.xyzw, s7
sample r4.xyzw, r4.xyxx, t2.xyzw, s8
mul r7.xyz, r7.xyzx, cb0[80].xyzx
div r8.xy, v6.xyxx, v6.zzzz
frc r1.w, r8.y
mad r8.z, r1.w, l(0.062500), cb4[8].y
sample r8.xyzw, r8.xzxx, t3.xyzw, s1
add r1.w, r8.w, l(-0.500000)
lt r1.w, r1.w, l(0.000000)
discard_nz r1.w
mad r4.zw, v1.xxxy, cb0[82].xxxy, cb0[82].zzzw
sample r8.xyzw, r4.zwzz, t4.xyzw, s9
mul r9.xyz, r7.xyzx, r8.xyzx
sample r10.xyzw, r4.zwzz, t5.xyzw, s10
mad r10.xy, r10.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r1.w, r10.xyxx, r10.xyxx
min r1.w, r1.w, l(1.000000)
add r1.w, -r1.w, l(1.000000)
sqrt r1.w, r1.w
sample r11.xyzw, r4.zwzz, t6.xyzw, s11
mul r11.xyz, r11.xyxx, cb0[77].xyxx
mad r4.xyz, r4.xyxx, cb0[77].xyxx, r11.xyzx
mul r2.w, r4.x, l(0.500000)
mul r6.yz, r5.yyxy, l(0.000000, 1.000000, -1.000000, 0.000000)
mov r5.z, r6.x
mov r5.w, -r5.y
mul r10.yzw, r5.xxzw, r10.yyyy
mad r6.xyz, r10.xxxx, r6.xyzx, r10.yzwy
mad r5.xyz, r1.wwww, r5.xyzx, r6.xyzx
dp3 r1.w, r5.xyzx, r5.xyzx
rsq r1.w, r1.w
mul r5.xyz, r1.wwww, r5.xyzx
add r1.w, -cb0[85].x, l(1.000000)
lt r1.w, r1.w, l(0.000000)
discard_nz r1.w
mul r6.xyzw, v5.yyyy, cb0[74].xyzw
mad r6.xyzw, cb0[73].xyzw, v5.xxxx, r6.xyzw
mad r6.xyzw, cb0[75].xyzw, v5.zzzz, r6.xyzw
add r6.xyzw, r6.xyzw, cb0[76].xyzw
mov r10.x, cb5[9].z
mov r10.y, cb5[10].z
mov r10.z, cb5[11].z
dp3 r1.w, r2.xyzx, r10.xyzx
add r2.xyz, v5.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, cb6[0].x, l(1.000000)
if_nz r2.x
  eq r2.x, cb6[0].y, l(1.000000)
  mul r10.xyz, v5.yyyy, cb6[2].xyzx
  mad r10.xyz, cb6[1].xyzx, v5.xxxx, r10.xyzx
  mad r10.xyz, cb6[3].xyzx, v5.zzzz, r10.xyzx
  add r10.xyz, r10.xyzx, cb6[4].xyzx
  movc r2.xyz, r2.xxxx, r10.xyzx, v5.xyzx
  add r2.xyz, r2.xyzx, -cb6[6].xyzx
  mul r10.yzw, r2.xxyz, cb6[5].xxyz
  mad r2.x, r10.y, l(0.250000), l(0.750000)
  mad r2.y, cb6[0].z, l(0.500000), l(0.750000)
  max r10.x, r2.y, r2.x
  sample r10.xyzw, r10.xzwx, t10.xyzw, s0
else
  mov r10.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r2.x, r10.xyzw, cb2[45].xyzw
lt r2.y, r1.w, l(0.990000)
if_nz r2.y
  mul r10.xyzw, v5.yyyy, cb3[9].xyzw
  mad r10.xyzw, cb3[8].xyzw, v5.xxxx, r10.xyzw
  mad r10.xyzw, cb3[10].xyzw, v5.zzzz, r10.xyzw
  add r10.xyzw, r10.xyzw, cb3[11].xyzw
  div r10.xyz, r10.xyzx, r10.wwww
  mul r2.yz, r10.xxyx, l(0.000000, 10.000000, 10.000000, 0.000000)
  sample r11.xyzw, r2.yzyy, t7.xyzw, s2
  dp3 r2.y, r11.xyzx, l(12.989800, 78.233002, 45.543201, 0.000000)
  sincos r2.y, null, r2.y
  mul r2.y, r2.y, l(43758.546875)
  frc r2.y, r2.y
  mul r2.y, r2.y, l(10.000000)
  sincos r4.x, r11.x, r2.y
  add r2.y, -cb3[24].x, l(1.000000)
  mul r2.y, r2.y, l(0.025000)
  mov r2.z, l(0)
  mov r3.w, l(0)
  loop
    itof r4.w, r3.w
    ge r4.w, r4.w, l(25.000000)
    breakc_nz r4.w
    mul r11.yz, r11.xxxx, icb[r3.w + 0].xxyx
    mad r12.x, icb[r3.w + 0].y, r4.x, r11.y
    mad r12.y, icb[r3.w + 0].x, -r4.x, r11.z
    mad r11.yz, r12.xxyx, r2.yyyy, r10.xxyx
    sample_c_lz r4.w, r11.yzyy, t11.xxxx, s3, r10.z
    add r2.z, r2.z, r4.w
    iadd r3.w, r3.w, l(1)
  endloop
  mul r2.y, r2.z, 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), r6.z
and r2.x, r2.x, l(0x3f800000)
div r2.yz, r6.xxyx, r6.wwww
add r2.yz, r2.yyzy, l(0.000000, 0.500000, 0.500000, 0.000000)
sample r10.xyzw, r2.yzyy, t8.xyzw, s4
mul r2.x, r2.x, r10.w
dp3 r2.y, r6.xyzx, r6.xyzx
sample r6.xyzw, r2.yyyy, t9.xyzw, s5
mul r2.x, r2.x, r6.x
mul r1.w, r1.w, r2.x
dp3 r2.x, v2.xyzx, r5.xyzx
dp3 r2.y, v3.xyzx, r5.xyzx
dp3 r2.z, v4.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
mad r6.xyz, r7.xyzx, r8.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r6.xyz, r2.wwww, r6.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r4.xy, -r4.zyzz, l(0.480000, 0.500000, 0.000000, 0.000000), l(0.960000, 1.000000, 0.000000, 0.000000)
mul r4.xzw, r4.xxxx, r9.xxyz
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 r1.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, r4.yyyy
add r0.y, r0.y, l(-0.500000)
add r0.z, -r1.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, r4.y, r4.y
mad r1.x, -r4.y, r4.y, l(1.000000)
mad r1.y, |r0.w|, r1.x, r0.z
mad r1.x, r1.w, r1.x, r0.z
mul r0.w, |r0.w|, r1.x
mad r0.w, r1.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, r1.wwww, r0.yyzy
max r0.z, r0.z, l(0.000000)
dp3 r0.w, r6.xyzx, r6.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, -r6.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r2.xyz, r2.xyzx, r0.xxxx, r6.xyzx
mul r0.xyz, r0.yzwy, r2.xyzx
mad o0.xyz, r4.xzwx, r1.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used