// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 7e700e60ccb5dd3e-ps.txt
// 3DMigoto: 7e700e60ccb5dd3e |    Unity headers extracted from Midnight Hub_Standard
//    Shader "Midnight Hub/Standard" {
//      CustomEditor "Rendering.Materials.StandarMaterialEditor"
//      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_Standard:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 184 8 6
//   undeciphered1a: 16
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "LOD_FADE_CROSSFADE" "NORMAL_MULTIPLYER" }
//   undeciphered2: 1 10 8 8 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 16 [unity_DynamicLightmap_HDR]
//   Vector 32 [_LightColor0]
//   Float 1084 [_MetalnessMult]
//   Float 1088 [_ShininessMult]
//   Vector 1104 [_Normal_ST]
//   Vector 1136 [_Color]
//   Float 1152 [_NormalMapMultiplyer]
//   Float 1184 [_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 "UnityPerDraw" 160
//   Vector 128 [unity_LODFade]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   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 5
//   SetTexture 1 [_MainTex] 2D 6
//   SetTexture 2 [_Roughness] 2D 7
//   SetTexture 3 [_DitherMaskLOD2D] 2D 3
//   SetTexture 4 [_ShadowMapTexture] 2D 4
//   SetTexture 5 [unity_DynamicLightmap] 2D 0
//   SetTexture 6 [unity_DynamicDirectionality] 2D -1
//   SetTexture 7 [unity_SpecCube0] CUBE 1
//   SetTexture 8 [unity_SpecCube1] CUBE -1
//   SetTexture 9 [unity_ProbeVolumeSH] 3D 2
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerDraw" 4
//   BindCB "UnityPerFrame" 5
//   BindCB "UnityReflectionProbes" 6
//   BindCB "UnityProbeVolume" 7
//
// 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:57:51 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   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                 6   xyzw        6     NONE   float   xy w
// TEXCOORD                 7   xyzw        7     NONE   float     zw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[75], 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[8], immediateIndexed
dcl_constantbuffer cb7[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_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_texturecube (float,float,float,float) t7
dcl_resource_texturecube (float,float,float,float) t8
dcl_resource_texture3d (float,float,float,float) t9
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.xyw
dcl_input_ps linear v7.zw
dcl_output o0.xyzw
dcl_temps 18
dcl_constantbuffer cb10[4], immediateIndexed

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

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

mul r16.w, -r16.x, r16.y
mad r17.xyz, -r16.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, r17.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, s5
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, s6
sample r3.xyzw, r3.xyxx, t2.xyzw, s7
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 r6.xyz, r4.xyzx, cb0[71].xyzx
mul r1.w, r3.x, cb0[67].w
div r7.xy, v5.xyxx, v5.zzzz
frc r2.w, r7.y
mad r7.z, r2.w, l(0.062500), cb4[8].y
sample r7.xyzw, r7.xzxx, t3.xyzw, s3
add r2.w, r7.w, l(-0.500000)
lt r2.w, r2.w, l(0.000000)
discard_nz r2.w
add r2.w, -cb0[74].x, l(1.000000)
lt r2.w, r2.w, l(0.000000)
discard_nz r2.w
mov r7.x, cb5[9].z
mov r7.y, cb5[10].z
mov r7.z, cb5[11].z
dp3 r2.w, r1.xyzx, r7.xyzx
add r7.xyz, r0.xyzx, -cb3[25].xyzx
dp3 r3.x, r7.xyzx, r7.xyzx
sqrt r3.x, r3.x
add r3.x, -r2.w, r3.x
mad r2.w, cb3[25].w, r3.x, r2.w
mad_sat r2.w, r2.w, cb3[24].z, cb3[24].w
eq r3.x, cb7[0].x, l(1.000000)
if_nz r3.x
  eq r3.x, cb7[0].y, l(1.000000)
  mul r7.xyz, v3.wwww, cb7[2].xyzx
  mad r7.xyz, cb7[1].xyzx, v2.wwww, r7.xyzx
  mad r7.xyz, cb7[3].xyzx, v4.wwww, r7.xyzx
  add r7.xyz, r7.xyzx, cb7[4].xyzx
  movc r7.xyz, r3.xxxx, r7.xyzx, r0.xyzx
  add r7.xyz, r7.xyzx, -cb7[6].xyzx
  mul r7.yzw, r7.xxyz, cb7[5].xxyz
  mad r3.x, r7.y, l(0.250000), l(0.750000)
  mad r3.w, cb7[0].z, l(0.500000), l(0.750000)
  max r7.x, r3.w, r3.x
  sample r7.xyzw, r7.xzwx, t9.xyzw, s2
else
  mov r7.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r3.x, r7.xyzw, cb2[45].xyzw
div r7.xy, v6.xyxx, v6.wwww
sample r7.xyzw, r7.xyxx, t4.xyzw, s4
add r3.x, r3.x, -r7.x
mad r2.w, r2.w, r3.x, r7.x
dp3 r7.x, v2.xyzx, r5.xyzx
dp3 r7.y, v3.xyzx, r5.xyzx
dp3 r7.z, v4.xyzx, r5.xyzx
mad r3.x, -r3.y, cb0[68].x, l(1.000000)
dp3 r3.w, -r2.xyzx, r7.xyzx
add r3.w, r3.w, r3.w
mad r5.xyz, r7.xyzx, -r3.wwww, -r2.xyzx
mul r8.xyz, r2.wwww, cb0[2].xyzx
sample r9.xyzw, v7.zwzz, t5.xyzw, s0
mul r2.w, r9.w, cb0[1].x
mul r9.xyz, r9.xyzx, r2.wwww
log r9.xyz, r9.xyzx
mul r9.xyz, r9.xyzx, cb0[1].yyyy
exp r9.xyz, r9.xyzx
sample r10.xyzw, v7.zwzz, t6.xyzw, s0
add r10.xyz, r10.xyzx, l(-0.500000, -0.500000, -0.500000, 0.000000)
dp3 r2.w, r7.xyzx, r10.xyzx
add r2.w, r2.w, l(0.500000)
mul r9.xyz, r2.wwww, r9.xyzx
max r2.w, r10.w, l(0.000100)
div r9.xyz, r9.xyzx, r2.wwww
lt r2.w, l(0.000000), cb6[2].w
if_nz r2.w
  dp3 r2.w, r5.xyzx, r5.xyzx
  rsq r2.w, r2.w
  mul r10.xyz, r2.wwww, r5.xyzx
  add r11.xyz, -r0.xyzx, cb6[0].xyzx
  div r11.xyz, r11.xyzx, r10.xyzx
  add r12.xyz, -r0.xyzx, cb6[1].xyzx
  div r12.xyz, r12.xyzx, r10.xyzx
  lt r13.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r10.xyzx
  movc r11.xyz, r13.xyzx, r11.xyzx, r12.xyzx
  min r2.w, r11.y, r11.x
  min r2.w, r11.z, r2.w
  add r11.xyz, r0.xyzx, -cb6[2].xyzx
  mad r10.xyz, r10.xyzx, r2.wwww, r11.xyzx
else
  mov r10.xyz, r5.xyzx
endif
mad r2.w, -r3.x, l(0.700000), l(1.700000)
mul r2.w, r2.w, r3.x
mul r2.w, r2.w, l(6.000000)
sample_l r10.xyzw, r10.xyzx, t7.xyzw, s1, r2.w
add r3.w, r10.w, l(-1.000000)
mad r3.w, cb6[3].w, r3.w, l(1.000000)
log r3.w, r3.w
mul r3.w, r3.w, cb6[3].y
exp r3.w, r3.w
mul r3.w, r3.w, cb6[3].x
mul r11.xyz, r10.xyzx, r3.wwww
lt r4.w, cb6[1].w, l(0.999990)
if_nz r4.w
  lt r4.w, l(0.000000), cb6[6].w
  if_nz r4.w
    dp3 r4.w, r5.xyzx, r5.xyzx
    rsq r4.w, r4.w
    mul r12.xyz, r4.wwww, r5.xyzx
    add r13.xyz, -r0.xyzx, cb6[4].xyzx
    div r13.xyz, r13.xyzx, r12.xyzx
    add r14.xyz, -r0.xyzx, cb6[5].xyzx
    div r14.xyz, r14.xyzx, r12.xyzx
    lt r15.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r12.xyzx
    movc r13.xyz, r15.xyzx, r13.xyzx, r14.xyzx
    min r4.w, r13.y, r13.x
    min r4.w, r13.z, r4.w
    add r0.xyz, r0.xyzx, -cb6[6].xyzx
    mad r5.xyz, r12.xyzx, r4.wwww, r0.xyzx
  endif
  sample_l r5.xyzw, r5.xyzx, t8.xyzw, s1, r2.w
  add r0.x, r5.w, l(-1.000000)
  mad r0.x, cb6[7].w, r0.x, l(1.000000)
  log r0.x, r0.x
  mul r0.x, r0.x, cb6[7].y
  exp r0.x, r0.x
  mul r0.x, r0.x, cb6[7].x
  mul r0.xyz, r5.xyzx, r0.xxxx
  mad r5.xyz, r3.wwww, r10.xyzx, -r0.xyzx
  mad r11.xyz, cb6[1].wwww, r5.xyzx, r0.xyzx
endif
mul r0.xyz, r3.zzzz, r11.xyzx
dp3 r2.w, r7.xyzx, r7.xyzx
rsq r2.w, r2.w
mul r5.xyz, r2.wwww, r7.xyzx
mad r4.xyz, r4.xyzx, cb0[71].xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r4.xyz, r1.wwww, r4.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r1.w, -r1.w, l(0.960000), l(0.960000)
mul r6.xyz, r1.wwww, r6.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.xxxx
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.x, r3.x
mad r2.w, -r3.x, r3.x, 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, cb0[68].x, -r1.w
add_sat r1.w, r1.w, l(1.000000)
mul r2.xyw, r1.yyyy, r8.xyxz
mad r2.xyw, r9.xyxz, r3.zzzz, r2.xyxw
mul r3.xyz, r8.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