// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed c3ab4d827956b98a-ps.txt
// 3DMigoto: c3ab4d827956b98a |    Unity headers extracted from Midnight Hub_Nature_Cliff
//    Shader "Midnight Hub/Nature/Cliff" {
//      CustomEditor "Rendering.Materials.StandarMaterialEditor"
//      Fallback "Diffuse"
//      SubShader 1/1 {
//        Pass 1/5 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDBASE" "SHADOWSUPPORT"="true" }
//          ZWrite [_ZWrite]
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Midnight Hub_Nature_Cliff:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 187 9 6
//   undeciphered1a: 17
//   Keywords { "DIRECTIONAL" "DYNAMICLIGHTMAP_ON" "LOD_FADE_CROSSFADE" "INSTANCING_ON" "NORMAL_MULTIPLYER" }
//   undeciphered2: 1 11 6 10 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1248
//   Vector 16 [unity_DynamicLightmap_HDR]
//   Vector 32 [_LightColor0]
//   Float 1084 [_MetalnessMult]
//   Float 1088 [_ShininessMult]
//   Vector 1104 [_Normal_ST]
//   Vector 1136 [_Color]
//   Float 1152 [_NormalMapMultiplyer]
//   Vector 1184 [_DetailNormal_ST]
//   Float 1232 [_Cutoff]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityPerDraw" 160
//   Vector 128 [unity_LODFade]
//   ConstBuffer "UnityReflectionProbes" 128
//   Vector 0 [unity_SpecCube0_BoxMax]
//   Vector 16 [unity_SpecCube0_BoxMin]
//   Vector 32 [unity_SpecCube0_ProbePosition]
//   Vector 48 [unity_SpecCube0_HDR]
//   Vector 64 [unity_SpecCube1_BoxMax]
//   Vector 80 [unity_SpecCube1_BoxMin]
//   Vector 96 [unity_SpecCube1_ProbePosition]
//   Vector 112 [unity_SpecCube1_HDR]
//   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 4
//   SetTexture 1 [_MainTex] 2D 5
//   SetTexture 2 [_Roughness] 2D 6
//   SetTexture 3 [_DitherMaskLOD2D] 2D 3
//   SetTexture 4 [_DetailAlbedo] 2D 7
//   SetTexture 5 [_DetailNormal] 2D 8
//   SetTexture 6 [_DetailRoughness] 2D 9
//   SetTexture 7 [unity_DynamicLightmap] 2D 0
//   SetTexture 8 [unity_SpecCube0] CUBE 1
//   SetTexture 9 [unity_SpecCube1] CUBE -1
//   SetTexture 10 [unity_ProbeVolumeSH] 3D 2
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityPerDraw" 3
//   BindCB "UnityReflectionProbes" 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 18:01:36 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   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyz         5     NONE   float   xyz
// TEXCOORD                 8   xyzw        6     NONE   float     zw
// SV_InstanceID            0   x           7     NONE    uint
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[78], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[9], immediateIndexed
dcl_constantbuffer cb4[8], 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_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_texturecube (float,float,float,float) t8
dcl_resource_texturecube (float,float,float,float) t9
dcl_resource_texture3d (float,float,float,float) t10
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyz
dcl_input_ps linear v6.zw
dcl_output o0.xyzw
dcl_temps 19
dcl_constantbuffer cb10[4], immediateIndexed

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

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

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

mov r0.x, v2.w
mov r0.y, v3.w
mov r0.z, v4.w
add r1.xyz, -r0.xyzx, r18.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r1.xyzx
mad r3.xy, v1.xyxx, cb0[69].xyxx, cb0[69].zwzz
sample r4.xyzw, r3.xyxx, t0.xyzw, s4
add r5.xy, r4.wyww, r4.wyww
mad r3.zw, r4.wwwy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
dp2 r1.w, r3.zwzz, r3.zwzz
min r1.w, r1.w, l(1.000000)
add r1.w, -r1.w, l(1.000000)
sqrt r5.z, r1.w
sample r4.xyzw, r3.xyxx, t1.xyzw, s5
sample r3.xyzw, r3.xyxx, t2.xyzw, s6
add r5.xyz, r5.xyzx, l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r5.xyz, cb0[72].xxxx, r5.xyzx, l(0.000000, 0.000000, 1.000000, 0.000000)
dp3 r1.w, r5.xyzx, r5.xyzx
rsq r1.w, r1.w
mul r5.xyz, r1.wwww, r5.xyzx
mul r4.xyz, r4.xyzx, cb0[71].xyzx
div r6.xy, v5.xyxx, v5.zzzz
frc r1.w, r6.y
mad r6.z, r1.w, l(0.062500), cb3[8].y
sample r6.xyzw, r6.xzxx, t3.xyzw, s3
add r1.w, r6.w, l(-0.500000)
lt r1.w, r1.w, l(0.000000)
discard_nz r1.w
mad r6.xy, v1.xyxx, cb0[74].xyxx, cb0[74].zwzz
sample r7.xyzw, r6.xyxx, t4.xyzw, s7
mul r8.xyz, r4.xyzx, r7.xyzx
sample r9.xyzw, r6.xyxx, t5.xyzw, s8
mad r6.zw, r9.wwwy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
dp2 r1.w, r6.zwzz, r6.zwzz
min r1.w, r1.w, l(1.000000)
add r1.w, -r1.w, l(1.000000)
sqrt r1.w, r1.w
sample r9.xyzw, r6.xyxx, t6.xyzw, s9
mul r2.w, r9.x, cb0[67].w
mad r2.w, r3.x, cb0[67].w, r2.w
mul r3.x, r2.w, l(0.500000)
mul r3.w, r9.y, cb0[68].x
mad r3.y, r3.y, cb0[68].x, r3.w
mov r5.w, -r5.x
mul r9.xyz, r5.xzyx, l(1.000000, 1.000000, -1.000000, 0.000000)
mul r6.xyw, r6.wwww, r9.xyxz
mad r6.xyz, r6.zzzz, r5.zywz, r6.xywx
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[77].x, l(1.000000)
lt r1.w, r1.w, l(0.000000)
discard_nz r1.w
eq r1.w, cb5[0].x, l(1.000000)
if_nz r1.w
  eq r1.w, cb5[0].y, l(1.000000)
  mul r6.xyz, v3.wwww, cb5[2].xyzx
  mad r6.xyz, cb5[1].xyzx, v2.wwww, r6.xyzx
  mad r6.xyz, cb5[3].xyzx, v4.wwww, r6.xyzx
  add r6.xyz, r6.xyzx, cb5[4].xyzx
  movc r6.xyz, r1.wwww, r6.xyzx, r0.xyzx
  add r6.xyz, r6.xyzx, -cb5[6].xyzx
  mul r6.yzw, r6.xxyz, cb5[5].xxyz
  mad r1.w, r6.y, l(0.250000), l(0.750000)
  mad r3.w, cb5[0].z, l(0.500000), l(0.750000)
  max r6.x, r1.w, r3.w
  sample r6.xyzw, r6.xzwx, t10.xyzw, s2
else
  mov r6.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r1.w, r6.xyzw, cb2[45].xyzw
dp3 r6.x, v2.xyzx, r5.xyzx
dp3 r6.y, v3.xyzx, r5.xyzx
dp3 r6.z, v4.xyzx, r5.xyzx
mad r3.w, -r3.y, l(0.500000), l(1.000000)
dp3 r4.w, -r2.xyzx, r6.xyzx
add r4.w, r4.w, r4.w
mad r5.xyz, r6.xyzx, -r4.wwww, -r2.xyzx
mul r9.xyz, r1.wwww, cb0[2].xyzx
sample r10.xyzw, v6.zwzz, t7.xyzw, s0
mul r1.w, r10.w, cb0[1].x
mul r10.xyz, r10.xyzx, r1.wwww
log r10.xyz, r10.xyzx
mul r10.xyz, r10.xyzx, cb0[1].yyyy
exp r10.xyz, r10.xyzx
lt r1.w, l(0.000000), cb4[2].w
if_nz r1.w
  dp3 r1.w, r5.xyzx, r5.xyzx
  rsq r1.w, r1.w
  mul r11.xyz, r1.wwww, r5.xyzx
  add r12.xyz, -r0.xyzx, cb4[0].xyzx
  div r12.xyz, r12.xyzx, r11.xyzx
  add r13.xyz, -r0.xyzx, cb4[1].xyzx
  div r13.xyz, r13.xyzx, r11.xyzx
  lt r14.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r11.xyzx
  movc r12.xyz, r14.xyzx, r12.xyzx, r13.xyzx
  min r1.w, r12.y, r12.x
  min r1.w, r12.z, r1.w
  add r12.xyz, r0.xyzx, -cb4[2].xyzx
  mad r11.xyz, r11.xyzx, r1.wwww, r12.xyzx
else
  mov r11.xyz, r5.xyzx
endif
mad r1.w, -r3.w, l(0.700000), l(1.700000)
mul r1.w, r1.w, r3.w
mul r1.w, r1.w, l(6.000000)
sample_l r11.xyzw, r11.xyzx, t8.xyzw, s1, r1.w
add r4.w, r11.w, l(-1.000000)
mad r4.w, cb4[3].w, r4.w, l(1.000000)
log r4.w, r4.w
mul r4.w, r4.w, cb4[3].y
exp r4.w, r4.w
mul r4.w, r4.w, cb4[3].x
mul r12.xyz, r11.xyzx, r4.wwww
lt r5.w, cb4[1].w, l(0.999990)
if_nz r5.w
  lt r5.w, l(0.000000), cb4[6].w
  if_nz r5.w
    dp3 r5.w, r5.xyzx, r5.xyzx
    rsq r5.w, r5.w
    mul r13.xyz, r5.wwww, r5.xyzx
    add r14.xyz, -r0.xyzx, cb4[4].xyzx
    div r14.xyz, r14.xyzx, r13.xyzx
    add r15.xyz, -r0.xyzx, cb4[5].xyzx
    div r15.xyz, r15.xyzx, r13.xyzx
    lt r16.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r13.xyzx
    movc r14.xyz, r16.xyzx, r14.xyzx, r15.xyzx
    min r5.w, r14.y, r14.x
    min r5.w, r14.z, r5.w
    add r0.xyz, r0.xyzx, -cb4[6].xyzx
    mad r5.xyz, r13.xyzx, r5.wwww, r0.xyzx
  endif
  sample_l r5.xyzw, r5.xyzx, t9.xyzw, s1, r1.w
  add r0.x, r5.w, l(-1.000000)
  mad r0.x, cb4[7].w, r0.x, l(1.000000)
  log r0.x, r0.x
  mul r0.x, r0.x, cb4[7].y
  exp r0.x, r0.x
  mul r0.x, r0.x, cb4[7].x
  mul r0.xyz, r5.xyzx, r0.xxxx
  mad r5.xyz, r4.wwww, r11.xyzx, -r0.xyzx
  mad r12.xyz, cb4[1].wwww, r5.xyzx, r0.xyzx
endif
mul r0.xyz, r3.zzzz, r12.xyzx
dp3 r1.w, r6.xyzx, r6.xyzx
rsq r1.w, r1.w
mul r5.xyz, r1.wwww, r6.xyzx
mad r4.xyz, r4.xyzx, r7.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r4.xyz, r3.xxxx, r4.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r1.w, -r2.w, l(0.480000), l(0.960000)
mul r6.xyz, r1.wwww, r8.xyzx
mad r1.xyz, r1.xyzx, r0.wwww, cb2[0].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
max r0.w, r0.w, l(0.001000)
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.w, r5.xyzx, r2.xyzx
dp3_sat r2.x, r5.xyzx, cb2[0].xyzx
dp3_sat r2.y, r5.xyzx, r1.xyzx
dp3_sat r1.x, cb2[0].xyzx, r1.xyzx
mul r1.y, r1.x, r1.x
dp2 r1.y, r1.yyyy, r3.wwww
add r1.y, r1.y, l(-0.500000)
add r1.z, -r2.x, l(1.000000)
mul r2.z, r1.z, r1.z
mul r2.z, r2.z, r2.z
mul r1.z, r1.z, r2.z
mad r1.z, r1.y, r1.z, l(1.000000)
add r2.z, -|r0.w|, l(1.000000)
mul r2.w, r2.z, r2.z
mul r2.w, r2.w, r2.w
mul r2.z, r2.z, r2.w
mad r1.y, r1.y, r2.z, l(1.000000)
mul r1.y, r1.y, r1.z
mul r1.y, r2.x, r1.y
mul r1.z, r3.w, r3.w
mad r2.w, -r3.w, r3.w, l(1.000000)
mad r3.x, |r0.w|, r2.w, r1.z
mad r2.w, r2.x, r2.w, r1.z
mul r0.w, |r0.w|, r2.w
mad r0.w, r2.x, r3.x, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r2.w, r1.z, r1.z
mad r3.x, r2.y, r2.w, -r2.y
mad r2.y, r3.x, r2.y, l(1.000000)
mul r2.w, r2.w, l(0.318309873)
mad r2.y, r2.y, r2.y, l(1.000000012E-007)
div r2.y, r2.w, r2.y
mul r0.w, r0.w, r2.y
mul r0.w, r0.w, l(3.14159274)
mul r0.w, r2.x, r0.w
max r0.w, r0.w, l(0.000000)
mad r1.z, r1.z, r1.z, l(1.000000)
div r1.z, l(1.000000, 1.000000, 1.000000, 1.000000), r1.z
dp3 r2.x, r4.xyzx, r4.xyzx
ne r2.x, r2.x, l(0.000000)
and r2.x, r2.x, l(0x3f800000)
mul r0.w, r0.w, r2.x
mad r1.w, r3.y, l(0.500000), -r1.w
add_sat r1.w, r1.w, l(1.000000)
mul r2.xyw, r1.yyyy, r9.xyxz
mad r2.xyw, r10.xyxz, r3.zzzz, r2.xyxw
mul r3.xyz, r9.xyzx, r0.wwww
add r0.w, -r1.x, l(1.000000)
mul r1.x, r0.w, r0.w
mul r1.x, r1.x, r1.x
mul r0.xyzw, r0.xyzw, r1.zzzx
add r5.xyz, -r4.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r5.xyz, r5.xyzx, r0.wwww, r4.xyzx
mul r3.xyz, r3.xyzx, r5.xyzx
mad r2.xyw, r6.xyxz, r2.xyxw, r3.xyxz
add r1.xyz, -r4.xyzx, r1.wwww
mad r1.xyz, r2.zzzz, r1.xyzx, r4.xyzx
mad o0.xyz, r0.xyzx, r1.xyzx, r2.xywx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used