// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 2a6fca0787f9afc9-ps.txt
// 3DMigoto: 2a6fca0787f9afc9 |    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 144 11 2
//   undeciphered1a: 10
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "APPLY_MOSS" }
//   undeciphered2: 1 11 6 11 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1232
//   Vector 32 [_LightColor0]
//   Float 1084 [_MetalnessMult]
//   Float 1088 [_ShininessMult]
//   Vector 1104 [_Normal_ST]
//   Vector 1136 [_Color]
//   Vector 1152 [_MossAlbedoMap_ST]
//   Vector 1168 [_DetailNormal_ST]
//   Float 1184 [_MossMetalnessMult]
//   Float 1188 [_MossShininessMult]
//   Float 1192 [_MossSpread]
//   Float 1216 [_Cutoff]
//   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]
//   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 2
//   SetTexture 1 [_MainTex] 2D 3
//   SetTexture 2 [_Roughness] 2D 4
//   SetTexture 3 [_DetailAlbedo] 2D 8
//   SetTexture 4 [_DetailNormal] 2D 9
//   SetTexture 5 [_DetailRoughness] 2D 10
//   SetTexture 6 [_MossAlbedoMap] 2D 5
//   SetTexture 7 [_MossNormalMap] 2D 6
//   SetTexture 8 [_MossRoughnessMap] 2D 7
//   SetTexture 9 [_ShadowMapTexture] 2D 1
//   SetTexture 10 [unity_ProbeVolumeSH] 3D 0
//   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:53:23 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                 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   xyzw        6     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[77], 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_default
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_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_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.xyw
dcl_output o0.xyzw
dcl_temps 12
dcl_constantbuffer cb10[4], immediateIndexed

// 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


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

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

add r0.xyz, -v5.xyzx, r11.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r0.xyzx
mad r2.xy, v1.xyxx, cb0[69].xyxx, cb0[69].zwzz
sample r3.xyzw, r2.xyxx, t0.xyzw, s2
mad r3.xy, r3.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r1.w, r3.xyxx, r3.xyxx
min r1.w, r1.w, l(1.000000)
add r1.w, -r1.w, l(1.000000)
sqrt r3.z, r1.w
sample r4.xyzw, r2.xyxx, t1.xyzw, s3
sample r2.xyzw, r2.xyxx, t2.xyzw, s4
mul r4.xyz, r4.xyzx, cb0[71].xyzx
dp3 r1.w, v3.xyzx, r3.xyzx
mad r2.zw, v1.xxxy, cb0[73].xxxy, cb0[73].zzzw
sample r5.xyzw, r2.zwzz, t3.xyzw, s8
mul r6.xyz, r4.xyzx, r5.xyzx
sample r7.xyzw, r2.zwzz, t4.xyzw, s9
mad r7.xy, r7.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r4.w, r7.xyxx, r7.xyxx
min r4.w, r4.w, l(1.000000)
add r4.w, -r4.w, l(1.000000)
sqrt r7.z, r4.w
sample r8.xyzw, r2.zwzz, t5.xyzw, s10
mul r2.z, r8.x, cb0[67].w
mad r2.x, r2.x, cb0[67].w, r2.z
mul r2.w, r8.y, cb0[68].x
mad r2.y, r2.y, cb0[68].x, r2.w
mul r2.zw, r2.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
mad r8.xy, v1.xyxx, cb0[72].xyxx, cb0[72].zwzz
sample r9.xyzw, r8.xyxx, t6.xyzw, s5
add r4.w, r9.w, l(0.500000)
mul r1.w, r1.w, r4.w
mul_sat r1.w, r1.w, cb0[74].z
mad r4.xyz, -r4.xyzx, r5.xyzx, r9.xyzx
mad r4.xyz, r1.wwww, r4.xyzx, r6.xyzx
sample r5.xyzw, r8.xyxx, t7.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 r4.w, r5.xyxx, r5.xyxx
min r4.w, r4.w, l(1.000000)
add r4.w, -r4.w, l(1.000000)
sqrt r5.z, r4.w
add r5.xyz, -r7.xyzx, r5.xyzx
mad r5.xyz, r1.wwww, r5.xyzx, r7.xyzx
dp3 r4.w, r5.xyzx, r5.xyzx
rsq r4.w, r4.w
mul r5.xyz, r4.wwww, r5.xyzx
sample r6.xyzw, r8.xyxx, t8.xyzw, s7
mul r6.zw, r1.wwww, cb0[74].xxxy
mad r1.w, -r2.x, l(0.500000), r6.x
mad r1.w, r6.z, r1.w, r2.z
mad r2.x, -r2.y, l(0.500000), r6.y
mad r2.x, r6.w, r2.x, r2.w
mov r3.w, -r3.x
mul r2.yzw, r3.xxzy, l(0.000000, 1.000000, 1.000000, -1.000000)
mul r2.yzw, r2.yyzw, r5.yyyy
mad r2.yzw, r5.xxxx, r3.zzyw, r2.yyzw
mad r2.yzw, r5.zzzz, r3.xxyz, r2.yyzw
dp3 r3.x, r2.yzwy, r2.yzwy
rsq r3.x, r3.x
mul r2.yzw, r2.yyzw, r3.xxxx
add r3.x, -cb0[76].x, l(1.000000)
lt r3.x, r3.x, l(0.000000)
discard_nz r3.x
mov r3.x, cb4[9].z
mov r3.y, cb4[10].z
mov r3.z, cb4[11].z
dp3 r3.x, r0.xyzx, r3.xyzx
add r3.yzw, v5.xxyz, -cb3[25].xxyz
dp3 r3.y, r3.yzwy, r3.yzwy
sqrt r3.y, r3.y
add r3.y, -r3.x, r3.y
mad r3.x, cb3[25].w, r3.y, r3.x
mad_sat r3.x, r3.x, cb3[24].z, cb3[24].w
eq r3.y, cb5[0].x, l(1.000000)
if_nz r3.y
  eq r3.y, cb5[0].y, l(1.000000)
  mul r5.xyz, v5.yyyy, cb5[2].xyzx
  mad r5.xyz, cb5[1].xyzx, v5.xxxx, r5.xyzx
  mad r5.xyz, cb5[3].xyzx, v5.zzzz, r5.xyzx
  add r5.xyz, r5.xyzx, cb5[4].xyzx
  movc r3.yzw, r3.yyyy, r5.xxyz, v5.xxyz
  add r3.yzw, r3.yyzw, -cb5[6].xxyz
  mul r5.yzw, r3.yyzw, cb5[5].xxyz
  mad r3.y, r5.y, l(0.250000), l(0.750000)
  mad r3.z, cb5[0].z, l(0.500000), l(0.750000)
  max r5.x, r3.z, r3.y
  sample r5.xyzw, r5.xzwx, t10.xyzw, s0
else
  mov r5.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r3.y, r5.xyzw, cb2[45].xyzw
div r3.zw, v6.xxxy, v6.wwww
sample r5.xyzw, r3.zwzz, t9.xyzw, s1
add r3.y, r3.y, -r5.x
mad r3.x, r3.x, r3.y, r5.x
dp3 r5.x, v2.xyzx, r2.yzwy
dp3 r5.y, v3.xyzx, r2.yzwy
dp3 r5.z, v4.xyzx, r2.yzwy
mul r2.yzw, r3.xxxx, cb0[2].xxyz
dp3 r3.x, r5.xyzx, r5.xyzx
rsq r3.x, r3.x
mul r3.xyz, r3.xxxx, r5.xyzx
add r5.xyz, r4.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r5.xyz, r1.wwww, r5.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r1.w, -r1.w, l(0.960000), l(0.960000)
mul r4.xyz, r1.wwww, r4.xyzx
add r1.w, -r2.x, l(1.000000)
mad r0.xyz, r0.xyzx, r0.wwww, cb2[0].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, r3.xyzx, r1.xyzx
dp3_sat r1.x, r3.xyzx, cb2[0].xyzx
dp3_sat r1.y, r3.xyzx, r0.xyzx
dp3_sat r0.x, cb2[0].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, -r1.x, l(1.000000)
mul r1.z, r0.z, r0.z
mul r1.z, r1.z, r1.z
mul r0.z, r0.z, r1.z
mad r0.z, r0.y, r0.z, l(1.000000)
add r1.z, -|r0.w|, l(1.000000)
mul r2.x, r1.z, r1.z
mul r2.x, r2.x, r2.x
mul r1.z, r1.z, r2.x
mad r0.y, r0.y, r1.z, l(1.000000)
mul r0.y, r0.y, r0.z
mul r0.z, r1.w, r1.w
mad r1.z, -r1.w, r1.w, l(1.000000)
mad r1.w, |r0.w|, r1.z, r0.z
mad r1.z, r1.x, r1.z, r0.z
mul r0.w, |r0.w|, r1.z
mad r0.w, r1.x, r1.w, 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.z, r1.y, r0.z, -r1.y
mad r1.y, r1.z, r1.y, l(1.000000)
mul r0.z, r0.z, l(0.318309873)
mad r1.y, r1.y, r1.y, l(1.000000012E-007)
div r0.z, r0.z, r1.y
mul r0.z, r0.z, r0.w
mul r0.z, r0.z, l(3.14159274)
mul r0.yz, r1.xxxx, r0.yyzy
max r0.z, r0.z, l(0.000000)
dp3 r0.w, r5.xyzx, r5.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, r2.yzwy
mul r0.yzw, r2.yyzw, 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, -r5.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r2.xyz, r2.xyzx, r0.xxxx, r5.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