// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 24997dff6a065580-ps.txt
// 3DMigoto: 24997dff6a065580 |    Unity headers extracted from Standard
//    Shader "Standard" {
//      CustomEditor "StandardShaderGUI"
//      Fallback "VertexLit"
//      SubShader 1/2 {
//        LOD 300
//        Tags { "PerformanceChecks"="False" "RenderType"="Opaque" }
//        Pass 1/5 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDBASE" "PerformanceChecks"="False" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          ZWrite [_ZWrite]
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Standard:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 173 9 6
//   undeciphered1a: 14
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "_EMISSION" "_METALLICGLOSSMAP" "_NORMALMAP" "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A" }
//   undeciphered2: 1 11 7 9 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 16 [unity_DynamicLightmap_HDR]
//   Vector 32 [_LightColor0]
//   Vector 1088 [_Color]
//   Float 1152 [_BumpScale]
//   Float 1168 [_GlossMapScale]
//   Float 1172 [_OcclusionStrength]
//   Vector 1184 [_EmissionColor]
//   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 "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 [_MetallicGlossMap] 2D 5
//   SetTexture 1 [_MainTex] 2D 3
//   SetTexture 2 [_BumpMap] 2D 4
//   SetTexture 3 [_ShadowMapTexture] 2D 8
//   SetTexture 4 [_OcclusionMap] 2D 6
//   SetTexture 5 [_EmissionMap] 2D 7
//   SetTexture 6 [unity_DynamicLightmap] 2D 0
//   SetTexture 7 [unity_DynamicDirectionality] 2D -1
//   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 "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityReflectionProbes" 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 17:53:05 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xy
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float     zw
// TEXCOORD                 6   xyzw        7     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[75], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[8], 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_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_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.xyz
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.zw
dcl_input_ps linear v7.xyw
dcl_output o0.xyzw
dcl_temps 16
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r14.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 24997dff6a065580-ps.txt

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

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