// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 951b83e13c0ef272-ps.txt
// 3DMigoto: 951b83e13c0ef272 | Matched 8 variants of 1 shaders: Hidden/NGSS_Directional
//
//        Unity headers extracted from Hidden_NGSS_Directional
//        Shader "Hidden/NGSS_Directional" {
//     1:   SubShader 2/4 {
//     2:   SubShader 4/4 {
//            Tags { "ShadowmapFilter"="PCF_SOFT_FORCE_INV_PROJECTION_IN_PS" }
//            Pass 1/1 {
//              Tags { "ShadowmapFilter"="PCF_SOFT_FORCE_INV_PROJECTION_IN_PS" }
//              ZWrite Off
//              Program "fp" {
//                SubProgram "d3d11" {
//                }
//              }
//            }
//          }
//        }
//
//     Unity 5.3 headers extracted from Hidden_NGSS_Directional:
//       API d3d11
//       Shader model ps_4_0
//       undeciphered1: 201609010 94 1 3
//       undeciphered1a: 11
// 44:   Keywords { "SHADOWS_SPLIT_SPHERES" "NGSS_PCSS_FILTER_DIR" "NGSS_USE_CASCADE_BLENDING" "DIR_POISSON_32" }
// 88:   Keywords { "SHADOWS_SPLIT_SPHERES" "NGSS_PCSS_FILTER_DIR" "NGSS_USE_CASCADE_BLENDING" "NGSS_USE_BIAS_FADE_DIR" "DIR_POISSON_32" }
// 11:   Keywords { "SHADOWS_SPLIT_SPHERES" "NGSS_USE_CASCADE_BLENDING" "DIR_POISSON_32" }
// 22:   Keywords { "SHADOWS_SPLIT_SPHERES" "NGSS_USE_CASCADE_BLENDING" "NGSS_USE_BIAS_FADE_DIR" "DIR_POISSON_32" }
//       undeciphered2: 1 2 4 2 0 0
//       undeciphered3: 0 0
//       ConstBuffer "$Globals" 2144
//       Float 1088 [NGSS_CASCADE_BLEND_DISTANCE]
//       Float 1092 [NGSS_POISSON_SAMPLING_NOISE_DIR]
//       Float 1096 [NGSS_PCSS_GLOBAL_SOFTNESS]
//       ConstBuffer "UnityPerCamera" 144
//       Vector 64 [_WorldSpaceCameraPos] 3
//       ConstBuffer "UnityPerCameraRare" 352
//       Matrix 160 [unity_CameraInvProjection]
//       Matrix 288 [unity_CameraToWorld]
//       ConstBuffer "UnityShadows" 416
//       Vector 0 [unity_ShadowSplitSpheres0]
//       Vector 16 [unity_ShadowSplitSpheres1]
//       Vector 32 [unity_ShadowSplitSpheres2]
//       Vector 48 [unity_ShadowSplitSpheres3]
//       Vector 64 [unity_ShadowSplitSqRadii]
//       Vector 384 [_LightShadowData]
//       Matrix 128 [unity_WorldToShadow0]
//       Matrix 192 [unity_WorldToShadow1]
//       Matrix 256 [unity_WorldToShadow2]
//       Matrix 320 [unity_WorldToShadow3]
//       SetTexture 0 [_CameraDepthTexture] 2D 1
//       SetTexture 1 [_ShadowMapTexture] 2D 0
//       BindCB "$Globals" 0
//       BindCB "UnityPerCamera" 1
//       BindCB "UnityPerCameraRare" 2
//       BindCB "UnityShadows" 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:59:10 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyz         2     NONE   float
// TEXCOORD                 2   xyz         3     NONE   float
// TEXCOORD                 3   xyz         4     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.487390190, -0.856959879, 0, 0},
                              { 0.346373707, -0.338793904, 0, 0},
                              { 0.629005492, -0.473531395, 0, 0},
                              { 0.185585395, -0.884814203, 0, 0},
                              { 0.767791688, 0.0269116201, 0, 0},
                              { 0.300914198, -0.636587322, 0, 0},
                              { 0.426842213, -0.00613762904, 0, 0},
                              { -0.0668298230, -0.783380508, 0, 0},
                              { 0.0347262993, -0.399412394, 0, 0},
                              { 0.449469388, 0.520661414, 0, 0},
                              { 0.219377, 0.243884400, 0, 0},
                              { 0.128576502, -0.121555403, 0, 0},
                              { 0.890704870, 0.433493108, 0, 0},
                              { 0.255646914, 0.766552, 0, 0},
                              { -0.0369240604, 0.362923592, 0, 0},
                              { 0.665110290, 0.728681087, 0, 0},
                              { -0.429309, -0.228226200, 0, 0},
                              { -0.273096889, -0.468351305, 0, 0},
                              { -0.275598586, 0.732791305, 0, 0},
                              { -0.332970500, 0.175463796, 0, 0},
                              { -0.173132598, -0.108771600, 0, 0},
                              { 0.921222627, -0.371663809, 0, 0},
                              { -0.538823485, 0.460396796, 0, 0},
                              { -0.630732119, 0.761592388, 0, 0},
                              { -0.770917475, -0.0889493674, 0, 0},
                              { -0.720597088, -0.360949308, 0, 0},
                              { -0.538620174, -0.584715903, 0, 0},
                              { -0.652083397, 0.178528398, 0, 0},
                              { -0.931058228, 0.204034299, 0, 0},
                              { -0.828178, 0.555959880, 0, 0},
                              { 0.629783571, 0.294650108, 0, 0},
                              { -0.0583608411, 0.900680721, 0, 0} }
dcl_constantbuffer cb0[69], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[22], immediateIndexed
dcl_constantbuffer cb3[25], immediateIndexed
dcl_sampler s0, mode_comparison
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xyzw
dcl_output o0.xyzw
dcl_temps 13
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r11.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 951b83e13c0ef272-ps.txt

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

sample r0.xyzw, v1.xyxx, t0.xyzw, s1
add r0.z, -r0.x, l(1.000000)
mov r0.xy, v1.zwzz
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r1.xyzw, r0.yyyy, cb2[11].xyzw
mad r1.xyzw, cb2[10].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb2[12].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb2[13].xyzw
div r0.xyz, r0.xyzx, r0.wwww
mul r1.xyzw, r0.yyyy, cb2[19].xyzw
mad r1.xyzw, cb2[18].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb2[20].xyzw, -r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb2[21].xyzw
add r1.xyz, r0.xyzx, -cb3[0].xyzx
add r2.xyz, r0.xyzx, -cb3[1].xyzx
add r3.xyz, r0.xyzx, -cb3[2].xyzx
add r4.xyz, r0.xyzx, -cb3[3].xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
dp3 r1.y, r2.xyzx, r2.xyzx
dp3 r1.z, r3.xyzx, r3.xyzx
dp3 r1.w, r4.xyzx, r4.xyzx
lt r2.xyzw, r1.xyzw, cb3[4].xyzw
and r3.xyzw, r2.xyzw, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
movc r2.xyz, r2.xyzx, l(-1.000000,-1.000000,-1.000000,0), l(-0.000000,-0.000000,-0.000000,0)
add r2.xyz, r2.xyzx, r3.yzwy
max r3.yzw, r2.xxyz, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r2.xyz, r0.yyyy, cb3[9].xyzx
mad r2.xyz, cb3[8].xyzx, r0.xxxx, r2.xyzx
mad r2.xyz, cb3[10].xyzx, r0.zzzz, r2.xyzx
mad r2.xyz, cb3[11].xyzx, r0.wwww, r2.xyzx
mul r4.xyz, r0.yyyy, cb3[13].xyzx
mad r4.xyz, cb3[12].xyzx, r0.xxxx, r4.xyzx
mad r4.xyz, cb3[14].xyzx, r0.zzzz, r4.xyzx
mad r4.xyz, cb3[15].xyzx, r0.wwww, r4.xyzx
mul r5.xyz, r0.yyyy, cb3[17].xyzx
mad r5.xyz, cb3[16].xyzx, r0.xxxx, r5.xyzx
mad r5.xyz, cb3[18].xyzx, r0.zzzz, r5.xyzx
mad r5.xyz, cb3[19].xyzx, r0.wwww, r5.xyzx
mul r6.xyz, r0.yyyy, cb3[21].xyzx
mad r6.xyz, cb3[20].xyzx, r0.xxxx, r6.xyzx
mad r6.xyz, cb3[22].xyzx, r0.zzzz, r6.xyzx
mad r6.xyz, cb3[23].xyzx, r0.wwww, r6.xyzx
mul r7.xyz, r3.yyyy, r4.xyzx
mad r2.xyz, r2.xyzx, r3.xxxx, r7.xyzx
mad r2.xyz, r5.xyzx, r3.zzzz, r2.xyzx
mad r2.xyz, r6.xyzx, r3.wwww, r2.xyzx
dp4 r0.w, r3.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
add r0.w, -r0.w, r2.z
add r0.w, r0.w, l(1.000000)
dp3 r2.z, v1.zwwz, l(12.989800, 78.233002, 45.543201, 0.000000)
sincos r2.z, null, r2.z
mul r2.z, r2.z, l(43758.546875)
frc r2.z, r2.z
mul r2.z, r2.z, cb0[68].y
mul r2.z, r2.z, l(0.050000)
sincos r7.x, r8.x, r2.z
add r2.z, cb0[68].z, l(0.001000)
mul r2.z, r2.z, l(0.150000)
mov r2.w, l(0)
mov r4.w, l(0)
loop
  itof r5.w, r4.w
  ge r5.w, r5.w, l(32.000000)
  breakc_nz r5.w
  mul r7.yz, r2.zzzz, icb[r4.w + 0].yyxy
  mul r8.yz, r7.xxxx, r7.yyzy
  mad r9.x, r7.z, r8.x, -r8.y
  mad r9.y, r7.y, r8.x, r8.z
  add r7.yz, r2.xxyx, r9.xxyx
  sample_c_lz r5.w, r7.yzyy, t1.xxxx, s0, r0.w
  add r2.w, r2.w, r5.w
  iadd r4.w, r4.w, l(1)
endloop
mul r0.w, r2.w, l(0.031250)
add r0.xyz, r0.xyzx, -r12.xyzx
div r9.xyzw, r1.xyzw, cb3[4].xyzw
lt r10.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000), cb3[4].xyzw
and r9.xyzw, r9.xyzw, r10.xyzw
dp3 r0.x, r0.xyzx, r0.xyzx
lt r1.xyzw, r1.xyzw, r0.xxxx
and r1.xyzw, r1.xyzw, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
mul r1.xyzw, r1.xyzw, r9.xyzw
mul r1.xyzw, r3.xyzw, r1.xyzw
dp4 r0.x, r1.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
add r0.y, -cb0[68].x, l(1.000000)
lt r0.z, r0.y, r0.x
if_nz r0.z
  add r0.x, -r0.y, r0.x
  div r0.x, r0.x, cb0[68].x
  mul r1.xyz, r3.yyyy, r5.xyzx
  mad r1.xyz, r4.xyzx, r3.xxxx, r1.xyzx
  mad r1.xyz, r6.xyzx, r3.zzzz, r1.xyzx
  dp3 r0.y, r3.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  add r0.y, -r0.y, r1.z
  add r0.y, r0.y, l(1.000000)
  mov r0.z, l(0)
  mov r1.z, l(0)
  loop
    itof r1.w, r1.z
    ge r1.w, r1.w, l(32.000000)
    breakc_nz r1.w
    mul r2.xy, r2.zzzz, icb[r1.z + 0].yxyy
    mul r3.xy, r7.xxxx, r2.xyxx
    mad r4.x, r2.y, r8.x, -r3.x
    mad r4.y, r2.x, r8.x, r3.y
    add r2.xy, r1.xyxx, r4.xyxx
    sample_c_lz r1.w, r2.xyxx, t1.xxxx, s0, r0.y
    add r0.z, r0.z, r1.w
    iadd r1.z, r1.z, l(1)
  endloop
  mad r0.y, r0.z, l(0.031250), -r0.w
  mad r0.w, r0.x, r0.y, r0.w
endif
add o0.xyzw, r0.wwww, cb3[24].xxxx
ret
// Approximately 0 instruction slots used