// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 8e233a9cd2e7db02-ps.txt
// 3DMigoto: 8e233a9cd2e7db02 |    Unity headers extracted from Double Sided
//    Shader "Double Sided" {
//      CustomEditor "StandardShaderGUI"
//      Fallback "VertexLit"
//      SubShader 1/2 {
//        LOD 300
//        Tags { "PerformanceChecks"="False" "RenderType"="Opaque" }
//        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 Double Sided:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 137 6 5
//   undeciphered1a: 8
//   Keywords { "SPOT" "SHADOWS_DEPTH" "SHADOWS_SOFT" "_NORMALMAP" }
//   undeciphered2: 1 7 6 7 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1344
//   Vector 32 [_LightColor0]
//   Vector 48 [_SpecColor]
//   Vector 1168 [_Color]
//   Float 1232 [_BumpScale]
//   Float 1244 [_Glossiness]
//   Matrix 1280 [unity_WorldToLight]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   Matrix 128 [unity_WorldToShadow0]
//   Matrix 192 [unity_WorldToShadow1]
//   Matrix 256 [unity_WorldToShadow2]
//   Matrix 320 [unity_WorldToShadow3]
//   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 3
//   SetTexture 1 [_BumpMap] 2D 4
//   SetTexture 2 [unity_RandomRotation16] 2D 1
//   SetTexture 3 [_LightTexture0] 2D 5
//   SetTexture 4 [_LightTextureB0] 2D 6
//   SetTexture 5 [unity_ProbeVolumeSH] 3D 0
//   SetTexture 6 [_ShadowMapTexture] 2D 2
//   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 17:58:48 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   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyz         6     NONE   float   xyz
// TEXCOORD                 6   xy          7     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_immediateConstantBuffer { { -0.635181785, 0.217271104, 0, 0},
                              { -0.149960607, 0.232067496, 0, 0},
                              { -0.679780, 0.688492417, 0, 0},
                              { -0.775864720, -0.253409, 0, 0},
                              { -0.473191589, -0.283272296, 0, 0},
                              { -0.333007902, 0.643005908, 0, 0},
                              { -0.138415098, -0.0983022526, 0, 0},
                              { -0.818232715, -0.564593911, 0, 0},
                              { -0.919847190, 0.0654980168, 0, 0},
                              { -0.142208502, -0.487210900, 0, 0},
                              { -0.498083293, -0.588559926, 0, 0},
                              { -0.332615912, -0.849614799, 0, 0},
                              { 0.306673586, -0.140199706, 0, 0},
                              { 0.114831701, 0.374455, 0, 0},
                              { -0.0388568006, 0.807132900, 0, 0},
                              { 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, 0, 0} }
dcl_constantbuffer cb0[84], 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_comparison
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, 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_texture3d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.xyz
dcl_output o0.xyzw
dcl_temps 10
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r8.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 8e233a9cd2e7db02-ps.txt

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

sample r0.xyzw, v1.xyxx, t0.xyzw, s3
mul r0.xyz, r0.xyzx, cb0[73].xyzx
max r0.w, cb0[3].y, cb0[3].x
max r0.w, r0.w, cb0[3].z
add r0.w, -r0.w, l(1.000000)
mul r0.xyz, r0.wwww, r0.xyzx
sample r1.xyzw, v1.xyxx, t1.xyzw, s4
mad r1.xy, r1.wyww, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r1.xy, r1.xyxx, cb0[77].xxxx
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
mul r1.yzw, r1.yyyy, v4.xxyz
mad r1.xyz, v3.xyzx, r1.xxxx, r1.yzwy
mad r1.xyz, v5.xyzx, r0.wwww, r1.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.w, v2.xyzx, v2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, v2.xyzx
mul r3.xyzw, v6.yyyy, cb0[81].xyzw
mad r3.xyzw, cb0[80].xyzw, v6.xxxx, r3.xyzw
mad r3.xyzw, cb0[82].xyzw, v6.zzzz, r3.xyzw
add r3.xyzw, r3.xyzw, cb0[83].xyzw
add r4.xyz, -v6.xyzx, r9.xyzx
mov r5.x, cb4[9].z
mov r5.y, cb4[10].z
mov r5.z, cb4[11].z
dp3 r0.w, r4.xyzx, r5.xyzx
add r4.xyz, v6.xyzx, -cb3[25].xyzx
dp3 r1.w, r4.xyzx, r4.xyzx
sqrt r1.w, r1.w
add r1.w, -r0.w, r1.w
mad r0.w, cb3[25].w, r1.w, r0.w
mad_sat r0.w, r0.w, cb3[24].z, cb3[24].w
eq r1.w, cb5[0].x, l(1.000000)
if_nz r1.w
  eq r1.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, r1.wwww, r4.xyzx, v6.xyzx
  add r4.xyz, r4.xyzx, -cb5[6].xyzx
  mul r4.yzw, r4.xxyz, cb5[5].xxyz
  mad r1.w, r4.y, l(0.250000), l(0.750000)
  mad r2.w, cb5[0].z, l(0.500000), l(0.750000)
  max r4.x, r1.w, r2.w
  sample r4.xyzw, r4.xzwx, t5.xyzw, s0
else
  mov r4.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r1.w, r4.xyzw, cb2[45].xyzw
lt r2.w, r0.w, l(0.990000)
if_nz r2.w
  mul r4.xyzw, v6.yyyy, cb3[9].xyzw
  mad r4.xyzw, cb3[8].xyzw, v6.xxxx, r4.xyzw
  mad r4.xyzw, cb3[10].xyzw, v6.zzzz, r4.xyzw
  add r4.xyzw, r4.xyzw, cb3[11].xyzw
  div r4.xyz, r4.xyzx, r4.wwww
  mul r5.xy, r4.xyxx, l(10.000000, 10.000000, 0.000000, 0.000000)
  sample r5.xyzw, r5.xyxx, t2.xyzw, s1
  dp3 r2.w, r5.xyzx, l(12.989800, 78.233002, 45.543201, 0.000000)
  sincos r2.w, null, r2.w
  mul r2.w, r2.w, l(43758.546875)
  frc r2.w, r2.w
  mul r2.w, r2.w, l(10.000000)
  sincos r5.x, r6.x, r2.w
  add r2.w, -cb3[24].x, l(1.000000)
  mul r2.w, r2.w, l(0.025000)
  mov r4.w, l(0)
  mov r5.y, l(0)
  loop
    itof r5.z, r5.y
    ge r5.z, r5.z, l(25.000000)
    breakc_nz r5.z
    mul r5.zw, r6.xxxx, icb[r5.y + 0].xxxy
    mad r7.x, icb[r5.y + 0].y, r5.x, r5.z
    mad r7.y, icb[r5.y + 0].x, -r5.x, r5.w
    mad r5.zw, r7.xxxy, r2.wwww, r4.xxxy
    sample_c_lz r5.z, r5.zwzz, t6.xxxx, s2, r4.z
    add r4.w, r4.w, r5.z
    iadd r5.y, r5.y, l(1)
  endloop
  mul r2.w, r4.w, l(0.040000)
else
  mov r2.w, l(1.000000)
endif
add r1.w, r1.w, -r2.w
mad r0.w, r0.w, r1.w, r2.w
lt r1.w, l(0.000000), r3.z
and r1.w, r1.w, l(0x3f800000)
div r4.xy, r3.xyxx, r3.wwww
add r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
sample r4.xyzw, r4.xyxx, t3.xyzw, s5
mul r1.w, r1.w, r4.w
dp3 r2.w, r3.xyzx, r3.xyzx
sample r3.xyzw, r2.wwww, t4.xyzw, s6
mul r1.w, r1.w, r3.x
mul r0.w, r0.w, r1.w
mov r3.x, v3.w
mov r3.y, v4.w
mov r3.z, v5.w
dp3 r1.w, r3.xyzx, r3.xyzx
rsq r1.w, r1.w
mul r4.xyz, r1.wwww, r3.xyzx
mul r5.xyz, r0.wwww, cb0[2].xyzx
add r0.w, -cb0[77].w, l(1.000000)
mad r3.xyz, r3.xyzx, r1.wwww, -r2.xyzx
dp3 r1.w, r3.xyzx, r3.xyzx
max r1.w, r1.w, l(0.001000)
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, r3.xyzx
dp3 r1.w, r1.xyzx, -r2.xyzx
dp3_sat r2.x, r1.xyzx, r4.xyzx
dp3_sat r1.x, r1.xyzx, r3.xyzx
dp3_sat r1.y, r4.xyzx, r3.xyzx
mul r1.z, r1.y, r1.y
dp2 r1.z, r1.zzzz, r0.wwww
add r1.z, r1.z, l(-0.500000)
add r2.y, -r2.x, 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 r2.y, r1.z, r2.y, l(1.000000)
add r2.z, -|r1.w|, l(1.000000)
mul r2.w, r2.z, r2.z
mul r2.w, r2.w, r2.w
mul r2.z, r2.z, r2.w
mad r1.z, r1.z, r2.z, l(1.000000)
mul r1.z, r1.z, r2.y
mul r1.z, r2.x, r1.z
mul r2.y, r0.w, r0.w
mad r0.w, -r0.w, r0.w, l(1.000000)
mad r2.z, |r1.w|, r0.w, r2.y
mad r0.w, r2.x, r0.w, r2.y
mul r0.w, r0.w, |r1.w|
mad r0.w, r2.x, r2.z, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r1.w, r2.y, r2.y
mad r2.y, r1.x, r1.w, -r1.x
mad r1.x, r2.y, r1.x, l(1.000000)
mul r1.w, r1.w, l(0.318309873)
mad r1.x, r1.x, r1.x, l(1.000000012E-007)
div r1.x, r1.w, r1.x
mul r0.w, r0.w, r1.x
mul r0.w, r0.w, l(3.14159274)
mul r0.w, r2.x, r0.w
max r0.w, r0.w, l(0.000000)
dp3 r1.x, cb0[3].xyzx, cb0[3].xyzx
ne r1.x, r1.x, l(0.000000)
and r1.x, r1.x, l(0x3f800000)
mul r0.w, r0.w, r1.x
mul r1.xzw, r1.zzzz, r5.xxyz
mul r2.xyz, r5.xyzx, r0.wwww
add r0.w, -r1.y, l(1.000000)
mul r1.y, r0.w, r0.w
mul r1.y, r1.y, r1.y
mul r0.w, r0.w, r1.y
add r3.xyz, -cb0[3].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r3.xyz, r3.xyzx, r0.wwww, cb0[3].xyzx
mul r2.xyz, r2.xyzx, r3.xyzx
mad o0.xyz, r0.xyzx, r1.xzwx, r2.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used