// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 1dd27c7ab4a57efa-ps.txt
// 3DMigoto: 1dd27c7ab4a57efa | Matched 6 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 152 5 4
//       undeciphered1a: 13
// 01:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 02:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "DIRLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 10:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
// 04:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 20:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
// 08:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" }
//       undeciphered2: 1 7 4 5 0 0
//       undeciphered3: 0 0
//       ConstBuffer "$Globals" 1136
//       Vector 16 [unity_DynamicLightmap_HDR]
//       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]
//       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]
//       SetTexture 0 [_BumpMap] 2D 4
//       SetTexture 1 [_ShadowMapTexture] 2D 2
//       SetTexture 2 [_MainTex] 2D 3
//       SetTexture 3 [unity_DynamicLightmap] 2D 0
//       SetTexture 4 [unity_DynamicDirectionality] 2D -1
//       SetTexture 5 [unity_SpecCube0] CUBE 1
//       SetTexture 6 [unity_SpecCube1] CUBE -1
//       BindCB "$Globals" 0
//       BindCB "UnityPerCamera" 1
//       BindCB "UnityLighting" 2
//       BindCB "UnityReflectionProbes" 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:52:41 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     zw
//
//
// 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[1], immediateIndexed
dcl_constantbuffer cb3[8], 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_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texturecube (float,float,float,float) t5
dcl_resource_texturecube (float,float,float,float) t6
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.zw
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 1dd27c7ab4a57efa-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 r0.xyz, r0.xyzx, r1.wwww
dp3 r1.w, -r2.xyzx, r0.xyzx
add r1.w, r1.w, r1.w
mad r3.xyz, r0.xyzx, -r1.wwww, -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)
sample r6.xyzw, v9.zwzz, t3.xyzw, s0
mul r1.w, r6.w, cb0[1].x
mul r6.xyz, r6.xyzx, r1.wwww
log r6.xyz, r6.xyzx
mul r6.xyz, r6.xyzx, cb0[1].yyyy
exp r6.xyz, r6.xyzx
sample r7.xyzw, v9.zwzz, t4.xyzw, s0
add r7.xyz, r7.xyzx, l(-0.500000, -0.500000, -0.500000, 0.000000)
dp3 r1.w, r0.xyzx, r7.xyzx
add r1.w, r1.w, l(0.500000)
mul r6.xyz, r1.wwww, r6.xyzx
max r1.w, r7.w, l(0.000100)
div r6.xyz, r6.xyzx, r1.wwww
lt r1.w, l(0.000000), cb3[2].w
if_nz r1.w
  dp3 r1.w, r3.xyzx, r3.xyzx
  rsq r1.w, r1.w
  mul r7.xyz, r1.wwww, r3.xyzx
  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, r3.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, t5.xyzw, s1, 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, r3.xyzx, r3.xyzx
    rsq r3.w, r3.w
    mul r9.xyz, r3.wwww, r3.xyzx
    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 r3.xyz, r9.xyzx, r3.wwww, r10.xyzx
  endif
  sample_l r3.xyzw, r3.xyzx, t6.xyzw, s1, r1.w
  add r1.w, r3.w, l(-1.000000)
  mad r1.w, cb3[7].w, r1.w, l(1.000000)
  log r1.w, r1.w
  mul r1.w, r1.w, cb3[7].y
  exp r1.w, r1.w
  mul r1.w, r1.w, cb3[7].x
  mul r3.xyz, r3.xyzx, r1.wwww
  mad r7.xyz, r2.wwww, r7.xyzx, -r3.xyzx
  mad r8.xyz, cb3[1].wwww, r7.xyzx, r3.xyzx
endif
dp3 r1.w, r0.xyzx, r4.xyzx
max r1.w, r1.w, l(0.000000)
dp3 r2.w, r4.xyzx, r1.xyzx
mad r3.xy, v1.xyxx, cb0[68].xyxx, cb0[68].zwzz
sample r3.xyzw, r3.xyxx, t2.xyzw, s3
mul r4.xyz, r3.xyzx, v7.xyzx
mad r3.xyz, r3.xyzx, v7.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r3.xyz, cb0[70].xxxx, r3.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r3.w, -cb0[70].x, l(0.960000), l(0.960000)
mul r4.xyz, r3.wwww, r4.xyzx
add r3.w, -r3.w, l(1.000000)
dp3 r2.x, r0.xyzx, r2.xyzx
max r2.xw, r2.xxxw, l(0.000000, 0.000000, 0.000000, 0.000000)
dp3 r0.x, r0.xyzx, r1.xyzx
max r0.x, r0.x, l(0.000000)
add r0.y, -r0.w, l(1.000000)
mad r0.z, r2.x, r0.y, r0.w
mad r0.y, r1.w, r0.y, r0.w
mul r0.y, r0.y, r2.x
mad r0.y, r1.w, r0.z, r0.y
add r0.y, r0.y, l(0.000010)
div r0.y, l(0.500000), r0.y
mul r0.z, r0.w, r0.w
mad r1.x, r0.x, r0.z, -r0.x
mad r0.x, r1.x, r0.x, l(1.000000)
mul r0.z, r0.z, l(0.318309873)
mad r0.x, r0.x, r0.x, l(1.000000012E-007)
div r0.x, r0.z, r0.x
mul r0.y, r0.y, r1.w
mul r0.x, r0.x, r0.y
mul r0.x, r0.x, l(0.785398185)
mul r0.x, r1.w, r0.x
max r0.x, r0.x, l(0.000000)
round_ni r0.y, r5.x
mul r1.xyz, r0.yyyy, cb0[66].xyzx
mul r0.xyz, r0.xxxx, r1.xyzx
add r1.x, -r2.w, l(1.000000)
mul r1.y, r1.x, r1.x
mul r1.y, r1.y, r1.y
mul r1.x, r1.x, r1.y
add r7.xyz, -r3.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r1.xyz, r7.xyzx, r1.xxxx, r3.xyzx
add_sat r2.y, r3.w, cb0[70].y
add r2.x, -r2.x, l(1.000000)
mul r2.z, r2.x, r2.x
mul r2.z, r2.z, r2.z
mul r2.x, r2.x, r2.z
add r7.xyz, -r3.xyzx, r2.yyyy
mad r3.xyz, r2.xxxx, r7.xyzx, r3.xyzx
mul r3.xyz, r3.xyzx, r8.xyzx
mad r0.xyz, r0.xyzx, r1.xyzx, r3.xyzx
add r1.x, r2.w, r2.w
mul r1.x, r2.w, r1.x
add r1.y, -r1.w, l(1.000000)
mul r1.z, r1.y, r1.y
mul r1.z, r1.z, r1.z
mul r1.y, r1.y, r1.z
mad r0.w, r1.x, r0.w, l(-0.500000)
mad r1.x, r0.w, r1.y, l(1.000000)
mad r0.w, r0.w, r2.x, l(1.000000)
mul r0.w, r0.w, r1.x
mul r0.w, r1.w, r0.w
mad r1.xyz, r0.wwww, r5.yzwy, r6.xyzx
mad o0.xyz, r1.xyzx, r4.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used