// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 5f35e714144f5a52-ps.txt
// 3DMigoto: 5f35e714144f5a52 | 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 2/3 {
//              Name "FORWARD_DELTA"
//              Tags { "LIGHTMODE"="FORWARDADD" "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 86 3 0
//       undeciphered1a: 6
// 04:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 08:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" }
// 01:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 10:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
// 02:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_ON" "DIRLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 20:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
//       undeciphered2: 1 3 3 3 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]
//       SetTexture 0 [_BumpMap] 2D 2
//       SetTexture 1 [_ShadowMapTexture] 2D 0
//       SetTexture 2 [_MainTex] 2D 1
//       BindCB "$Globals" 0
//       BindCB "UnityPerCamera" 1
//       BindCB "UnityLighting" 2
//
// 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:56:16 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
//
//
// 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_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, 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_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_output o0.xyzw
dcl_temps 8
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r6.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 5f35e714144f5a52-ps.txt

mul r6.w, -r6.x, r6.y
mad r7.xyz, -r6.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
mad r1.xy, v1.xyxx, cb0[69].xyxx, cb0[69].zwzz
sample r1.xyzw, r1.xyxx, t0.xyzw, s2
mad r1.xy, r1.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r2.xyz, r1.yyyy, v6.xyzx
mad r2.xyz, r1.xxxx, v5.xyzx, r2.xyzx
dp2 r0.w, r1.xyxx, r1.xyxx
min r0.w, r0.w, l(1.000000)
add r0.w, -r0.w, l(1.000000)
sqrt r0.w, r0.w
mad r0.xyz, r0.wwww, r0.xyzx, r2.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, r7.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r1.xyzx
dp3 r1.w, r0.xyzx, r2.xyzx
max r1.w, r1.w, l(0.000000)
add r2.x, -cb0[70].y, l(1.000000)
add r2.y, -r2.x, l(1.000000)
mad r2.z, r1.w, r2.y, r2.x
mad r3.xyz, cb2[0].wwww, -v3.xyzx, cb2[0].xyzx
dp3 r2.w, r3.xyzx, r3.xyzx
rsq r2.w, r2.w
mul r3.xyz, r2.wwww, r3.xyzx
dp3 r2.w, r0.xyzx, r3.xyzx
max r2.w, r2.w, l(0.000000)
mad r2.y, r2.w, r2.y, r2.x
mul r2.y, r1.w, r2.y
add r1.w, -r1.w, l(1.000000)
mad r2.y, r2.w, r2.z, r2.y
add r2.y, r2.y, l(0.000010)
div r2.y, l(0.500000), r2.y
mul r2.y, r2.y, r2.w
mad r1.xyz, r1.xyzx, r0.wwww, r3.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.x, r0.xyzx, r1.xyzx
dp3 r0.y, r3.xyzx, r1.xyzx
max r0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r0.z, r2.x, r2.x
mad r0.w, r0.x, r0.z, -r0.x
mad r0.x, r0.w, r0.x, l(1.000000)
mad r0.x, r0.x, r0.x, l(1.000000012E-007)
mul r0.z, r0.z, l(0.318309873)
div r0.x, r0.z, r0.x
mul r0.x, r0.x, r2.y
mul r0.x, r0.x, l(0.785398185)
mul r0.x, r2.w, r0.x
max r0.x, r0.x, l(0.000000)
div r0.zw, v8.xxxy, v8.wwww
sample r3.xyzw, r0.zwzz, t1.xyzw, s0
mul r1.xyz, r3.xxxx, cb0[66].xyzx
mul r0.xzw, r0.xxxx, r1.xxyz
add r2.y, -r0.y, l(1.000000)
mul r2.z, r2.y, r2.y
mul r2.z, r2.z, r2.z
mul r2.y, r2.y, r2.z
mad r3.xy, v1.xyxx, cb0[68].xyxx, cb0[68].zwzz
sample r3.xyzw, r3.xyxx, t2.xyzw, s1
mad r4.xyz, r3.xyzx, v7.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mul r3.xyz, r3.xyzx, v7.xyzx
mad r4.xyz, cb0[70].xxxx, r4.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
add r5.xyz, -r4.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r4.xyz, r5.xyzx, r2.yyyy, r4.xyzx
mul r0.xzw, r0.xxzw, r4.xxyz
add r2.y, r0.y, r0.y
mul r0.y, r0.y, r2.y
mad r0.y, r0.y, r2.x, l(-0.500000)
mul r2.x, r1.w, r1.w
mul r2.x, r2.x, r2.x
mul r1.w, r1.w, r2.x
mad r1.w, r0.y, r1.w, l(1.000000)
add r2.x, -r2.w, l(1.000000)
mul r2.y, r2.x, r2.x
mul r2.y, r2.y, r2.y
mul r2.x, r2.x, r2.y
mad r0.y, r0.y, r2.x, l(1.000000)
mul r0.y, r1.w, r0.y
mul r0.y, r2.w, r0.y
mul r1.xyz, r1.xyzx, r0.yyyy
mad r0.y, -cb0[70].x, l(0.960000), l(0.960000)
mul r2.xyz, r0.yyyy, r3.xyzx
mad o0.xyz, r1.xyzx, r2.xyzx, r0.xzwx
mov o0.w, l(0)
ret
// Approximately 0 instruction slots used