// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed b290700e0218ffa8-ps.txt
// 3DMigoto: b290700e0218ffa8 |    Unity headers extracted from Standard
//    Shader "Standard" {
//      CustomEditor "StandardShaderGUI"
//      Fallback "VertexLit"
// 1:   SubShader 1/2 {
// 2:   SubShader 2/2 {
// 2:     LOD 150
// 1:     LOD 300
//        Tags { "PerformanceChecks"="False" "RenderType"="Opaque" }
// 2:     Pass 2/4 {
// 1:     Pass 2/5 {
//          Name "FORWARD_DELTA"
//          Tags { "LIGHTMODE"="FORWARDADD" "PerformanceChecks"="False" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Standard:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 92 4 2
//   undeciphered1a: 7
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "_METALLICGLOSSMAP" }
//   undeciphered2: 1 4 6 4 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 32 [_LightColor0]
//   Vector 1088 [_Color]
//   Float 1168 [_GlossMapScale]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_MainTex] 2D 1
//   SetTexture 1 [_MetallicGlossMap] 2D 2
//   SetTexture 2 [_ShadowMapTexture] 2D 3
//   SetTexture 3 [unity_ProbeVolumeSH] 3D 0
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityProbeVolume" 5
//
// 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 18:00:41 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      w
// TEXCOORD                 3   xyzw        4     NONE   float      w
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyz         6     NONE   float   xyz
// 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[74], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, 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_texture3d (float,float,float,float) t3
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.w
dcl_input_ps linear v4.w
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.xyz
dcl_input_ps linear v7.xyw
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 b290700e0218ffa8-ps.txt

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

sample r0.xyzw, v1.xyxx, t1.xyzw, s2
sample r1.xyzw, v1.xyxx, t0.xyzw, s1
mul r2.xyz, r1.xyzx, cb0[68].xyzx
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.xyz, r0.xxxx, r2.xyzx
dp3 r1.w, v5.xyzx, v5.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, v5.xyzx
dp3 r1.w, v2.xyzx, v2.xyzx
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, v2.xyzx
add r4.xyz, -v6.xyzx, r8.xyzx
mov r5.x, cb4[9].z
mov r5.y, cb4[10].z
mov r5.z, cb4[11].z
dp3 r2.w, r4.xyzx, r5.xyzx
add r4.xyz, v6.xyzx, -cb3[25].xyzx
dp3 r3.w, r4.xyzx, r4.xyzx
sqrt r3.w, r3.w
add r3.w, -r2.w, r3.w
mad r2.w, cb3[25].w, r3.w, r2.w
mad_sat r2.w, r2.w, cb3[24].z, cb3[24].w
eq r3.w, cb5[0].x, l(1.000000)
if_nz r3.w
  eq r3.w, cb5[0].y, l(1.000000)
  mul r4.xyz, v6.yyyy, cb5[2].xyzx
  mad r4.xyz, cb5[1].xyzx, v6.xxxx, r4.xyzx
  mad r4.xyz, cb5[3].xyzx, v6.zzzz, r4.xyzx
  add r4.xyz, r4.xyzx, cb5[4].xyzx
  movc r4.xyz, r3.wwww, r4.xyzx, v6.xyzx
  add r4.xyz, r4.xyzx, -cb5[6].xyzx
  mul r4.yzw, r4.xxyz, cb5[5].xxyz
  mad r3.w, r4.y, l(0.250000), l(0.750000)
  mad r4.y, cb5[0].z, l(0.500000), l(0.750000)
  max r4.x, r3.w, r4.y
  sample r4.xyzw, r4.xzwx, t3.xyzw, s0
else
  mov r4.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r3.w, r4.xyzw, cb2[45].xyzw
div r4.xy, v7.xyxx, v7.wwww
sample r4.xyzw, r4.xyxx, t2.xyzw, s3
add r3.w, r3.w, -r4.x
mad r2.w, r2.w, r3.w, r4.x
mul r4.xyz, r2.wwww, cb0[2].xyzx
mad r0.w, -r0.w, cb0[73].x, l(1.000000)
mov r5.x, v3.w
mov r5.y, v4.w
mov r5.z, v5.w
mad r6.xyz, -v2.xyzx, r1.wwww, r5.xyzx
dp3 r1.w, r6.xyzx, r6.xyzx
max r1.w, r1.w, l(0.001000)
rsq r1.w, r1.w
mul r6.xyz, r1.wwww, r6.xyzx
dp3 r1.w, r2.xyzx, -r3.xyzx
dp3_sat r2.w, r2.xyzx, r5.xyzx
dp3_sat r2.x, r2.xyzx, r6.xyzx
dp3_sat r2.y, r5.xyzx, r6.xyzx
mul r2.z, r2.y, r2.y
dp2 r2.z, r2.zzzz, r0.wwww
add r2.z, r2.z, l(-0.500000)
add r3.x, -r2.w, l(1.000000)
mul r3.y, r3.x, r3.x
mul r3.y, r3.y, r3.y
mul r3.x, r3.x, r3.y
mad r3.x, r2.z, r3.x, l(1.000000)
add r3.y, -|r1.w|, 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 r2.z, r2.z, r3.y, l(1.000000)
mul r2.z, r2.z, r3.x
mul r2.z, r2.w, r2.z
mul r3.x, r0.w, r0.w
mad r0.w, -r0.w, r0.w, l(1.000000)
mad r3.y, |r1.w|, r0.w, r3.x
mad r0.w, r2.w, r0.w, r3.x
mul r0.w, r0.w, |r1.w|
mad r0.w, r2.w, r3.y, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r1.w, r3.x, r3.x
mad r3.x, r2.x, r1.w, -r2.x
mad r2.x, r3.x, r2.x, l(1.000000)
mul r1.w, r1.w, l(0.318309873)
mad r2.x, r2.x, r2.x, l(1.000000012E-007)
div r1.w, r1.w, r2.x
mul r0.w, r0.w, r1.w
mul r0.w, r0.w, l(3.14159274)
mul r0.w, r2.w, r0.w
max r0.w, r0.w, l(0.000000)
dp3 r1.w, r1.xyzx, r1.xyzx
ne r1.w, r1.w, l(0.000000)
and r1.w, r1.w, l(0x3f800000)
mul r0.w, r0.w, r1.w
mul r2.xzw, r2.zzzz, r4.xxyz
mul r3.xyz, r4.xyzx, r0.wwww
add r0.w, -r2.y, l(1.000000)
mul r1.w, r0.w, r0.w
mul r1.w, r1.w, r1.w
mul r0.w, r0.w, r1.w
add r4.xyz, -r1.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r1.xyz, r4.xyzx, r0.wwww, r1.xyzx
mul r1.xyz, r1.xyzx, r3.xyzx
mad o0.xyz, r0.xyzx, r2.xzwx, r1.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used