// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 7fb0508f5535ec5f-ps.txt
// 3DMigoto: 7fb0508f5535ec5f | Matched 3 variants of 1 shaders: ProBuilder/Standard Vertex Color
//
//       Unity headers extracted from ProBuilder_Standard Vertex Color
//       Shader "ProBuilder/Standard Vertex Color" {
//         Fallback "Standard"
//         SubShader 1/1 {
//           Tags { "RenderType"="Opaque" }
//           Pass 1/3 {
//             Name "FORWARD"
//             Tags { "LIGHTMODE"="FORWARDBASE" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//             Program "fp" {
//               SubProgram "d3d11" {
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from ProBuilder_Standard Vertex Color:
//      API d3d11
//      Shader model ps_4_0
//      undeciphered1: 201609010 163 6 6
//      undeciphered1a: 13
// 2:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 1:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 4:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
//      undeciphered2: 1 6 5 5 0 0
//      undeciphered3: 0 0
//      ConstBuffer "$Globals" 1136
//      Vector 1056 [_LightColor0]
//      Vector 1088 [_MainTex_ST]
//      Vector 1104 [_BumpMap_ST]
//      Float 1120 [_Metallic]
//      Float 1124 [_Gloss]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 64 [_WorldSpaceCameraPos] 3
//      ConstBuffer "UnityLighting" 752
//      Vector 0 [_WorldSpaceLightPos0]
//      Vector 608 [unity_SHAr]
//      Vector 624 [unity_SHAg]
//      Vector 640 [unity_SHAb]
//      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 [_BumpMap] 2D 4
//      SetTexture 1 [_ShadowMapTexture] 2D 2
//      SetTexture 2 [_MainTex] 2D 3
//      SetTexture 3 [unity_SpecCube0] CUBE 0
//      SetTexture 4 [unity_SpecCube1] CUBE -1
//      SetTexture 5 [unity_ProbeVolumeSH] 3D 1
//      BindCB "$Globals" 0
//      BindCB "UnityPerCamera" 1
//      BindCB "UnityLighting" 2
//      BindCB "UnityReflectionProbes" 3
//      BindCB "UnityProbeVolume" 4
//
// 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:55 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     zw        1     NONE   float
// TEXCOORD                 2   xy          2     NONE   float
// TEXCOORD                 3   xyzw        3     NONE   float   xyz
// TEXCOORD                 4   xyz         4     NONE   float   xyz
// TEXCOORD                 5   xyz         5     NONE   float   xyz
// TEXCOORD                 6   xyz         6     NONE   float   xyz
// COLOR                    0   xyzw        7     NONE   float   xyz
// TEXCOORD                 7   xyzw        8     NONE   float   xy w
// TEXCOORD                10   xyzw        9     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[71], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[41], immediateIndexed
dcl_constantbuffer cb3[8], immediateIndexed
dcl_constantbuffer cb4[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_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_texturecube (float,float,float,float) t3
dcl_resource_texturecube (float,float,float,float) t4
dcl_resource_texture3d (float,float,float,float) t5
dcl_input_ps linear v1.xy
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps linear v5.xyz
dcl_input_ps linear v6.xyz
dcl_input_ps linear v7.xyz
dcl_input_ps linear v8.xyw
dcl_input_ps linear v9.xyz
dcl_output o0.xyzw
dcl_temps 15
dcl_constantbuffer cb10[4], immediateIndexed

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

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

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

dp3 r0.x, v4.xyzx, v4.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v4.xyzx
add r1.xyz, -v3.xyzx, r14.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 r3.xyzw, r3.xyxx, t0.xyzw, s4
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 r1.w, r1.w
mul r3.yzw, r3.yyyy, v6.xxyz
mad r3.xyz, r3.xxxx, v5.xyzx, r3.yzwy
mad r0.xyz, r1.wwww, r0.xyzx, r3.xyzx
dp3 r1.w, r0.xyzx, r0.xyzx
rsq r1.w, r1.w
mul r3.xyz, r0.xyzx, r1.wwww
dp3 r0.x, -r2.xyzx, r3.xyzx
add r0.x, r0.x, r0.x
mad r0.xyz, r3.xyzx, -r0.xxxx, -r2.xyzx
dp3 r1.w, cb2[0].xyzx, cb2[0].xyzx
rsq r1.w, r1.w
mul r4.xyz, r1.wwww, cb2[0].xyzx
mad r1.xyz, r1.xyzx, r0.wwww, r4.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
div r5.xy, v8.xyxx, v8.wwww
sample r5.xyzw, r5.xyxx, t1.xyzw, s2
mul r5.yzw, r5.xxxx, cb0[66].xxyz
add r0.w, -cb0[70].y, l(1.000000)
eq r1.w, cb4[0].x, l(1.000000)
if_nz r1.w
  eq r1.w, cb4[0].y, l(1.000000)
  mul r6.xyz, v3.yyyy, cb4[2].xyzx
  mad r6.xyz, cb4[1].xyzx, v3.xxxx, r6.xyzx
  mad r6.xyz, cb4[3].xyzx, v3.zzzz, r6.xyzx
  add r6.xyz, r6.xyzx, cb4[4].xyzx
  movc r6.xyz, r1.wwww, r6.xyzx, v3.xyzx
  add r6.xyz, r6.xyzx, -cb4[6].xyzx
  mul r6.yzw, r6.xxyz, cb4[5].xxyz
  mul r1.w, r6.y, l(0.250000)
  mul r2.w, cb4[0].z, l(0.500000)
  mad r4.w, -cb4[0].z, l(0.500000), l(0.250000)
  max r1.w, r1.w, r2.w
  min r6.x, r4.w, r1.w
  sample r7.xyzw, r6.xzwx, t5.xyzw, s1
  add r8.xyz, r6.xzwx, l(0.250000, 0.000000, 0.000000, 0.000000)
  sample r8.xyzw, r8.xyzx, t5.xyzw, s1
  add r6.xyz, r6.xzwx, l(0.500000, 0.000000, 0.000000, 0.000000)
  sample r6.xyzw, r6.xyzx, t5.xyzw, s1
  mov r3.w, l(1.000000)
  dp4 r7.x, r7.xyzw, r3.xyzw
  dp4 r7.y, r8.xyzw, r3.xyzw
  dp4 r7.z, r6.xyzw, r3.xyzw
else
  mov r3.w, l(1.000000)
  dp4 r7.x, cb2[38].xyzw, r3.xyzw
  dp4 r7.y, cb2[39].xyzw, r3.xyzw
  dp4 r7.z, cb2[40].xyzw, r3.xyzw
endif
add r6.xyz, r7.xyzx, v9.xyzx
max r6.xyz, r6.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
lt r1.w, l(0.000000), cb3[2].w
if_nz r1.w
  dp3 r1.w, r0.xyzx, r0.xyzx
  rsq r1.w, r1.w
  mul r7.xyz, r0.xyzx, r1.wwww
  add r8.xyz, -v3.xyzx, cb3[0].xyzx
  div r8.xyz, r8.xyzx, r7.xyzx
  add r9.xyz, -v3.xyzx, cb3[1].xyzx
  div r9.xyz, r9.xyzx, r7.xyzx
  lt r10.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r7.xyzx
  movc r8.xyz, r10.xyzx, r8.xyzx, r9.xyzx
  min r1.w, r8.y, r8.x
  min r1.w, r8.z, r1.w
  add r8.xyz, v3.xyzx, -cb3[2].xyzx
  mad r7.xyz, r7.xyzx, r1.wwww, r8.xyzx
else
  mov r7.xyz, r0.xyzx
endif
mad r1.w, -r0.w, l(0.700000), l(1.700000)
mul r1.w, r0.w, r1.w
mul r1.w, r1.w, l(6.000000)
sample_l r7.xyzw, r7.xyzx, t3.xyzw, s0, r1.w
add r2.w, r7.w, l(-1.000000)
mad r2.w, cb3[3].w, r2.w, l(1.000000)
log r2.w, r2.w
mul r2.w, r2.w, cb3[3].y
exp r2.w, r2.w
mul r2.w, r2.w, cb3[3].x
mul r8.xyz, r7.xyzx, r2.wwww
lt r3.w, cb3[1].w, l(0.999990)
if_nz r3.w
  lt r3.w, l(0.000000), cb3[6].w
  if_nz r3.w
    dp3 r3.w, r0.xyzx, r0.xyzx
    rsq r3.w, r3.w
    mul r9.xyz, r0.xyzx, r3.wwww
    add r10.xyz, -v3.xyzx, cb3[4].xyzx
    div r10.xyz, r10.xyzx, r9.xyzx
    add r11.xyz, -v3.xyzx, cb3[5].xyzx
    div r11.xyz, r11.xyzx, r9.xyzx
    lt r12.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r9.xyzx
    movc r10.xyz, r12.xyzx, r10.xyzx, r11.xyzx
    min r3.w, r10.y, r10.x
    min r3.w, r10.z, r3.w
    add r10.xyz, v3.xyzx, -cb3[6].xyzx
    mad r0.xyz, r9.xyzx, r3.wwww, r10.xyzx
  endif
  sample_l r9.xyzw, r0.xyzx, t4.xyzw, s0, r1.w
  add r0.x, r9.w, l(-1.000000)
  mad r0.x, cb3[7].w, r0.x, l(1.000000)
  log r0.x, r0.x
  mul r0.x, r0.x, cb3[7].y
  exp r0.x, r0.x
  mul r0.x, r0.x, cb3[7].x
  mul r0.xyz, r9.xyzx, r0.xxxx
  mad r7.xyz, r2.wwww, r7.xyzx, -r0.xyzx
  mad r8.xyz, cb3[1].wwww, r7.xyzx, r0.xyzx
endif
dp3 r0.x, r3.xyzx, r4.xyzx
dp3 r0.y, r4.xyzx, r1.xyzx
max r0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r4.xy, v1.xyxx, cb0[68].xyxx, cb0[68].zwzz
sample r4.xyzw, r4.xyxx, t2.xyzw, s3
mul r7.xyz, r4.xyzx, v7.xyzx
mad r4.xyz, r4.xyzx, v7.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r4.xyz, cb0[70].xxxx, r4.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r0.z, -cb0[70].x, l(0.960000), l(0.960000)
mul r7.xyz, r0.zzzz, r7.xyzx
add r0.z, -r0.z, l(1.000000)
dp3 r1.w, r3.xyzx, r2.xyzx
dp3 r1.x, r3.xyzx, r1.xyzx
max r1.xw, r1.xxxw, l(0.000000, 0.000000, 0.000000, 0.000000)
add r1.y, -r0.w, l(1.000000)
mad r1.z, r1.w, r1.y, r0.w
mad r1.y, r0.x, r1.y, r0.w
mul r1.y, r1.y, r1.w
mad r1.y, r0.x, r1.z, r1.y
add r1.y, r1.y, l(0.000010)
div r1.y, l(0.500000), r1.y
mul r1.z, r0.w, r0.w
mad r2.x, r1.x, r1.z, -r1.x
mad r1.x, r2.x, r1.x, l(1.000000)
mul r1.z, r1.z, l(0.318309873)
mad r1.x, r1.x, r1.x, l(1.000000012E-007)
div r1.x, r1.z, r1.x
mul r1.y, r0.x, r1.y
mul r1.x, r1.x, r1.y
mul r1.x, r1.x, l(0.785398185)
mul r1.x, r0.x, r1.x
max r1.x, r1.x, l(0.000000)
round_ni r1.y, r5.x
mul r2.xyz, r1.yyyy, cb0[66].xyzx
mul r1.xyz, r1.xxxx, r2.xyzx
add r2.x, -r0.y, l(1.000000)
mul r2.y, r2.x, r2.x
mul r2.y, r2.y, r2.y
mul r2.x, r2.x, r2.y
add r2.yzw, -r4.xxyz, l(0.000000, 1.000000, 1.000000, 1.000000)
mad r2.xyz, r2.yzwy, r2.xxxx, r4.xyzx
add_sat r0.z, r0.z, cb0[70].y
add r1.w, -r1.w, l(1.000000)
mul r2.w, r1.w, r1.w
mul r2.w, r2.w, r2.w
mul r1.w, r1.w, r2.w
add r3.xyz, -r4.xyzx, r0.zzzz
mad r3.xyz, r1.wwww, r3.xyzx, r4.xyzx
mul r3.xyz, r3.xyzx, r8.xyzx
mad r1.xyz, r1.xyzx, r2.xyzx, r3.xyzx
add r0.z, r0.y, r0.y
mul r0.y, r0.y, r0.z
add r0.z, -r0.x, l(1.000000)
mul r2.x, r0.z, r0.z
mul r2.x, r2.x, r2.x
mul r0.z, r0.z, r2.x
mad r0.y, r0.y, r0.w, l(-0.500000)
mad r0.z, r0.y, r0.z, l(1.000000)
mad r0.y, r0.y, r1.w, l(1.000000)
mul r0.y, r0.y, r0.z
mul r0.x, r0.x, r0.y
mad r0.xyz, r0.xxxx, r5.yzwy, r6.xyzx
mad o0.xyz, r0.xyzx, r7.xyzx, r1.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used