// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 026dd2811817b547-ps.txt
// 3DMigoto: 026dd2811817b547 | 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 140 5 2
//       undeciphered1a: 7
// 04:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 08:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" }
// 01:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 10:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DYNAMICLIGHTMAP_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
// 02:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DYNAMICLIGHTMAP_ON" "DIRLIGHTMAP_OFF" "LIGHTMAP_OFF" }
// 20:   Keywords { "POINT_COOKIE" "SHADOWS_CUBE" "SHADOWS_SOFT" "DYNAMICLIGHTMAP_ON" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" }
//       undeciphered2: 1 6 5 6 0 0
//       undeciphered3: 0 0
//       ConstBuffer "$Globals" 1200
//       Vector 1120 [_LightColor0]
//       Vector 1152 [_MainTex_ST]
//       Vector 1168 [_BumpMap_ST]
//       Float 1184 [_Metallic]
//       Float 1188 [_Gloss]
//       ConstBuffer "UnityPerCamera" 144
//       Vector 64 [_WorldSpaceCameraPos] 3
//       Vector 80 [_ProjectionParams]
//       ConstBuffer "UnityLighting" 752
//       Vector 0 [_WorldSpaceLightPos0]
//       Vector 16 [_LightPositionRange]
//       ConstBuffer "UnityShadows" 416
//       Vector 384 [_LightShadowData]
//       ConstBuffer "UnityPerFrame" 384
//       Matrix 272 [unity_MatrixVP]
//       SetTexture 0 [_BumpMap] 2D 5
//       SetTexture 1 [_LightTextureB0] 2D 3
//       SetTexture 2 [_LightTexture0] CUBE 2
//       SetTexture 3 [unity_RandomRotation16] 2D 0
//       SetTexture 4 [_MainTex] 2D 4
//       SetTexture 5 [_ShadowMapTexture] CUBE 1
//       BindCB "$Globals" 0
//       BindCB "UnityPerCamera" 1
//       BindCB "UnityLighting" 2
//       BindCB "UnityShadows" 3
//       BindCB "UnityPerFrame" 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:51:04 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   xyz         8     NONE   float   xyz
// TEXCOORD                 8   xyz         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_immediateConstantBuffer { { 0.123298101, -0.0392337516, -0.635181785, 0.217271104},
                              { -0.562537730, -0.360242814, -0.149960607, 0.232067496},
                              { 0.640371919, 0.0682112277, -0.679780, 0.688492417},
                              { 0.281338692, -0.588158786, -0.775864720, -0.253409},
                              { -0.573121786, 0.270057201, -0.473191589, -0.283272296},
                              { 0.203316599, 0.419773906, -0.333007902, 0.643005908},
                              { 0.846795797, -0.354558408, -0.138415098, -0.0983022526},
                              { -0.423045099, -0.797441, -0.818232715, -0.564593911},
                              { 0.719025314, 0.569357514, -0.919847190, 0.0654980168},
                              { 0.0381546803, -0.991417110, -0.142208502, -0.487210900},
                              { -0.223626494, 0.502861381, -0.498083293, -0.588559926},
                              { 0.172225401, 0.983663, -0.332615912, -0.849614799},
                              { -0.291246414, 0.898051202, 0.306673586, -0.140199706},
                              { -0.898414791, -0.0876278579, 0.114831701, 0.374455},
                              { -0.699508488, 0.673418522, -0.0388568006, 0.807132900},
                              { -0.293196, -0.0628911927, 0.410288513, 0.696029484},
                              { 0, 0, 0.556387722, 0.337537706},
                              { 0, 0, -0.0178657603, -0.887376487},
                              { 0, 0, 0.234991, -0.455843806},
                              { 0, 0, 0.620677471, -0.155100495},
                              { 0, 0, 0.664064229, -0.569142699},
                              { 0, 0, 0.731272578, 0.583016813},
                              { 0, 0, 0.887970686, 0.0571521297},
                              { 0, 0, 0.312829614, -0.830803},
                              { 0, 0, 0.868976414, -0.339797288} }
dcl_constantbuffer cb0[75], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[2], immediateIndexed
dcl_constantbuffer cb3[25], immediateIndexed
dcl_constantbuffer cb4[24], 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_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_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texturecube (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.xyz
dcl_input_ps linear v9.xyz
dcl_output o0.xyzw
dcl_temps 9
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r7.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 026dd2811817b547-ps.txt

mul r7.w, -r7.x, r7.y
mad r8.xyz, -r7.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, r8.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[73].xyxx, cb0[73].zwzz
sample r3.xyzw, r3.xyxx, t0.xyzw, s5
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
mad r3.xyz, cb2[0].wwww, -v3.xyzx, cb2[0].xyzx
dp3 r1.w, r3.xyzx, r3.xyzx
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, r3.xyzx
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.w, v8.xyzx, v8.xyzx
sample r4.xyzw, r0.wwww, t1.xyzw, s3
sample r5.xyzw, v8.xyzx, t2.xyzw, s2
mul r0.w, r4.x, r5.w
dp3 r1.w, v9.xyzx, v9.xyzx
sqrt r1.w, r1.w
mul r2.w, r1.w, cb2[1].w
add r4.xyz, v9.xyzx, cb2[1].xyzx
mul r5.xyz, r4.yyyy, cb4[18].xywx
mad r4.xyw, cb4[17].xyxw, r4.xxxx, r5.xyxz
mad r4.xyz, cb4[19].xywx, r4.zzzz, r4.xywx
add r4.xyz, r4.xyzx, cb4[20].xywx
mul r5.xz, r4.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
mul r3.w, r4.y, cb1[5].x
mul r5.w, r3.w, l(0.500000)
add r4.xy, r5.zzzz, r5.xwxx
div r4.xy, r4.xyxx, r4.zzzz
sample r4.xyzw, r4.xyxx, t3.xyzw, s0
mul r5.xyz, r4.xyzx, l(45.543201, 12.989800, 78.233002, 0.000000)
mad r4.xyz, r4.zxyz, l(12.989800, 78.233002, 45.543201, 0.000000), -r5.xyzx
sincos r4.xyz, null, r4.xyzx
mul r4.xyz, r4.xyzx, l(43758.546875, 43758.546875, 43758.546875, 0.000000)
frc r4.xyz, r4.xyzx
mad r4.xyz, r4.xyzx, l(10.000000, 10.000000, 10.000000, 0.000000), l(0.000100, 0.000100, 0.000100, 0.000000)
mul r5.xyz, r4.xyzx, v9.zxyz
mad r4.xyz, v9.yzxy, r4.yzxy, -r5.xyzx
dp3 r3.w, r4.xyzx, r4.xyzx
rsq r3.w, r3.w
mul r4.xyz, r3.wwww, r4.xyzx
mul r5.xyz, r4.yzxy, v9.zxyz
mad r5.xyz, v9.yzxy, r4.zxyz, -r5.xyzx
dp3 r3.w, r5.xyzx, r5.xyzx
rsq r3.w, r3.w
mul r5.xyz, r3.wwww, r5.xyzx
add r3.w, -cb3[24].x, l(1.000000)
mul r3.w, r3.w, l(0.500000)
mul r4.xyz, r3.wwww, r4.xyzx
mul r5.xyz, r3.wwww, r5.xyzx
mov r3.w, l(0)
mov r4.w, l(0)
loop
  ige r5.w, r4.w, l(16)
  breakc_nz r5.w
  mul r6.xyz, r5.xyzx, icb[r4.w + 0].yyyy
  mad r6.xyz, r4.xyzx, icb[r4.w + 0].xxxx, r6.xyzx
  add r6.xyz, r6.xyzx, v9.xyzx
  sample_l r6.xyzw, r6.xyzx, t5.xyzw, s1, l(0.000000)
  add r3.w, r3.w, r6.x
  iadd r4.w, r4.w, l(1)
endloop
mad r3.w, -r3.w, l(0.062500), r2.w
div r2.w, r3.w, r2.w
mul r3.w, cb2[1].w, l(0.015000)
mov r4.w, l(0)
mov r5.w, l(0)
loop
  itof r6.x, r5.w
  ge r6.x, r6.x, l(25.000000)
  breakc_nz r6.x
  mul r6.xyz, r5.xyzx, icb[r5.w + 0].wwww
  mad r6.xyz, r4.xyzx, icb[r5.w + 0].zzzz, r6.xyzx
  mad r6.xyz, r6.xyzx, r2.wwww, v9.xyzx
  sample_l r6.xyzw, r6.xyzx, t5.xyzw, s1, l(0.000000)
  mad r6.x, r1.w, cb2[1].w, -r6.x
  div_sat r6.x, r6.x, r3.w
  add r6.x, -r6.x, l(1.000000)
  add r4.w, r4.w, r6.x
  iadd r5.w, r5.w, l(1)
endloop
mul r1.w, r4.w, l(0.040000)
mul r0.w, r0.w, r1.w
mul r4.xyz, r0.wwww, cb0[70].xyzx
dp3 r0.w, r0.xyzx, r3.xyzx
dp3 r1.w, r3.xyzx, r1.xyzx
max r1.w, r1.w, l(0.000000)
mad r3.xy, v1.xyxx, cb0[72].xyxx, cb0[72].zwzz
sample r3.xyzw, r3.xyxx, t4.xyzw, s4
mul r5.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[74].xxxx, r3.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r2.w, -cb0[74].x, l(0.960000), l(0.960000)
mul r5.xyz, r2.wwww, r5.xyzx
dp3 r2.x, r0.xyzx, r2.xyzx
max r2.x, r2.x, l(0.000000)
dp3 r0.x, r0.xyzx, r1.xyzx
max r0.xw, r0.xxxw, l(0.000000, 0.000000, 0.000000, 0.000000)
add r0.y, -cb0[74].y, l(1.000000)
add r0.z, -r0.y, l(1.000000)
mad r1.x, r2.x, r0.z, r0.y
mad r0.z, r0.w, r0.z, r0.y
mul r0.z, r0.z, r2.x
mad r0.z, r0.w, r1.x, r0.z
add r0.z, r0.z, l(0.000010)
div r0.z, l(0.500000), r0.z
mul r1.x, r0.y, r0.y
mad r1.y, r0.x, r1.x, -r0.x
mad r0.x, r1.y, r0.x, l(1.000000)
mul r1.x, r1.x, l(0.318309873)
mad r0.x, r0.x, r0.x, l(1.000000012E-007)
div r0.x, r1.x, r0.x
mul r0.z, r0.z, r0.w
mul r0.x, r0.x, r0.z
mul r0.x, r0.x, l(0.785398185)
mul r0.x, r0.w, r0.x
max r0.x, r0.x, l(0.000000)
mul r1.xyz, r0.xxxx, r4.xyzx
add r0.x, -r1.w, l(1.000000)
mul r0.z, r0.x, r0.x
mul r0.z, r0.z, r0.z
mul r0.x, r0.x, r0.z
add r2.yzw, -r3.xxyz, l(0.000000, 1.000000, 1.000000, 1.000000)
mad r2.yzw, r2.yyzw, r0.xxxx, r3.xxyz
mul r1.xyz, r1.xyzx, r2.yzwy
add r0.x, r1.w, r1.w
mul r0.x, r1.w, r0.x
add r0.z, -r0.w, l(1.000000)
mul r1.w, r0.z, r0.z
mul r1.w, r1.w, r1.w
mul r0.z, r0.z, r1.w
add r1.w, -r2.x, l(1.000000)
mul r2.x, r1.w, r1.w
mul r2.x, r2.x, r2.x
mul r1.w, r1.w, r2.x
mad r0.x, r0.x, r0.y, l(-0.500000)
mad r0.y, r0.x, r0.z, l(1.000000)
mad r0.x, r0.x, r1.w, l(1.000000)
mul r0.x, r0.x, r0.y
mul r0.x, r0.w, r0.x
mul r0.xyz, r4.xyzx, r0.xxxx
mad o0.xyz, r0.xyzx, r5.xyzx, r1.xyzx
mov o0.w, l(0)
ret
// Approximately 0 instruction slots used