// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 88734823e608e7f9-ps.txt
// 3DMigoto: 88734823e608e7f9 |    Unity headers extracted from Legacy Shaders_Specular
//    Shader "Legacy Shaders/Specular" {
//      Fallback "Legacy Shaders/VertexLit"
//      SubShader 1/1 {
//        LOD 300
//        Tags { "RenderType"="Opaque" }
//        Pass 2/6 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDADD" "RenderType"="Opaque" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Legacy Shaders_Specular:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 44 4 2
//   undeciphered1a: 5
//   Keywords { "POINT_COOKIE" }
//   undeciphered2: 1 4 4 4 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 32 [_LightColor0]
//   Vector 48 [_SpecColor]
//   Vector 1152 [_Color]
//   Float 1168 [_Shininess]
//   Matrix 1088 [unity_WorldToLight]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_MainTex] 2D 3
//   SetTexture 1 [_LightTextureB0] 2D 2
//   SetTexture 2 [_LightTexture0] CUBE 1
//   SetTexture 3 [unity_ProbeVolumeSH] 3D 0
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityProbeVolume" 3
//
// 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:58:26 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                 3     zw        1     NONE   float
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyz         3     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[74], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texturecube (float,float,float,float) t2
dcl_resource_texture3d (float,float,float,float) t3
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyz
dcl_output o0.xyzw
dcl_temps 7
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r5.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 88734823e608e7f9-ps.txt

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

add r0.xyz, -v3.xyzx, cb2[0].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
add r1.xyz, -v3.xyzx, r6.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
sample r2.xyzw, v1.xyxx, t0.xyzw, s3
mul r2.xyz, r2.xyzx, cb0[72].xyzx
mul r3.xyz, v3.yyyy, cb0[69].xyzx
mad r3.xyz, cb0[68].xyzx, v3.xxxx, r3.xyzx
mad r3.xyz, cb0[70].xyzx, v3.zzzz, r3.xyzx
add r3.xyz, r3.xyzx, cb0[71].xyzx
eq r1.w, cb3[0].x, l(1.000000)
if_nz r1.w
  eq r1.w, cb3[0].y, l(1.000000)
  mul r4.xyz, v3.yyyy, cb3[2].xyzx
  mad r4.xyz, cb3[1].xyzx, v3.xxxx, r4.xyzx
  mad r4.xyz, cb3[3].xyzx, v3.zzzz, r4.xyzx
  add r4.xyz, r4.xyzx, cb3[4].xyzx
  movc r4.xyz, r1.wwww, r4.xyzx, v3.xyzx
  add r4.xyz, r4.xyzx, -cb3[6].xyzx
  mul r4.yzw, r4.xxyz, cb3[5].xxyz
  mad r1.w, r4.y, l(0.250000), l(0.750000)
  mad r3.w, cb3[0].z, l(0.500000), l(0.750000)
  max r4.x, r1.w, r3.w
  sample r4.xyzw, r4.xzwx, t3.xyzw, s0
else
  mov r4.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r1.w, r4.xyzw, cb2[45].xyzw
dp3 r3.w, r3.xyzx, r3.xyzx
sample r4.xyzw, r3.wwww, t1.xyzw, s2
sample r3.xyzw, r3.xyzx, t2.xyzw, s1
mul r3.x, r3.w, r4.x
mul r1.w, r1.w, r3.x
mul r3.xyz, r1.wwww, cb0[2].xyzx
mad r1.xyz, r1.xyzx, r0.wwww, r0.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.x, v2.xyzx, r0.xyzx
dp3 r0.y, v2.xyzx, r1.xyzx
max r0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r0.z, cb0[73].x, l(128.000000)
log r0.y, r0.y
mul r0.y, r0.y, r0.z
exp r0.y, r0.y
mul r0.y, r2.w, r0.y
mul r1.xyz, r2.xyzx, r3.xyzx
mul r2.xyz, r3.xyzx, cb0[3].xyzx
mul r0.yzw, r0.yyyy, r2.xxyz
mad o0.xyz, r1.xyzx, r0.xxxx, r0.yzwy
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used