// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 0481901188f610cc-ps.txt
// 3DMigoto: 0481901188f610cc |    Unity headers extracted from Hidden_SoftSpotLight
//    Shader "Hidden/SoftSpotLight" {
//      SubShader 1/1 {
//        Tags { "QUEUE"="Geometry-1" }
//        Pass 1/1 {
//          Tags { "QUEUE"="Geometry-1" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Hidden_SoftSpotLight:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 123 6 1
//   undeciphered1a: 8
//   Keywords { "SPOT" "SHADOWS_DEPTH" }
//   undeciphered2: 1 8 4 8 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1424
//   Vector 64 [_LightPos]
//   Vector 80 [_LightColor]
//   Float 1312 [_LightSpecStrength]
//   Vector 1328 [_AttenuationSettings]
//   Float 1412 [_ShadowOffset]
//   Matrix 112 [unity_WorldToLight]
//   Matrix 1344 [unity_WorldToShadow2]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 80 [_ProjectionParams]
//   Vector 112 [_ZBufferParams]
//   ConstBuffer "UnityPerCameraRare" 352
//   Matrix 288 [unity_CameraToWorld]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   SetTexture 0 [_CameraDepthTexture] 2D 0
//   SetTexture 1 [_LightTexture0] 2D 2
//   SetTexture 2 [_LightTextureB0] 2D 1
//   SetTexture 3 [unity_RandomRotation16] 2D 3
//   SetTexture 4 [_CameraGBufferTexture0] 2D 5
//   SetTexture 5 [_CameraGBufferTexture1] 2D 6
//   SetTexture 6 [_CameraGBufferTexture2] 2D 7
//   SetTexture 7 [_ShadowMapTexture] 2D 4
//   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) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.16 on Sun Apr 21 17:51:13 2019
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 unity_Lightmap_HDR;         // Offset:    0 Size:    16 [unused]
//   float4 unity_DynamicLightmap_HDR;  // Offset:   16 Size:    16 [unused]
//   float _LightAsQuad;                // Offset:   32 Size:     4 [unused]
//   float4 _LightDir;                  // Offset:   48 Size:    16 [unused]
//   float4 _LightPos;                  // Offset:   64 Size:    16
//   float4 _LightColor;                // Offset:   80 Size:    16
//   float4 unity_LightmapFade;         // Offset:   96 Size:    16 [unused]
//   float4x4 unity_WorldToLight;       // Offset:  112 Size:    64
//   float3 LocalPoissonDisksOffsets[64];// Offset:  176 Size:  1020 [unused]
//   float4 _ShadowOffsets[4];          // Offset: 1200 Size:    64 [unused]
//   float4 _ShadowMapTexture_TexelSize;// Offset: 1264 Size:    16 [unused]
//   float4 _LightColor0;               // Offset: 1280 Size:    16 [unused]
//   float4 _SpecColor;                 // Offset: 1296 Size:    16 [unused]
//   float _LightSpecStrength;          // Offset: 1312 Size:     4
//      = 0x3f800000
//   float4 _AttenuationSettings;       // Offset: 1328 Size:    16
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000
//   float4x4 unity_WorldToShadow2;     // Offset: 1344 Size:    64
//   float _LightRadius;                // Offset: 1408 Size:     4 [unused]
//   float _ShadowOffset;               // Offset: 1412 Size:     4
//      = 0x358637bd
//
// }
//
// cbuffer UnityPerCamera
// {
//
//   float4 _Time;                      // Offset:    0 Size:    16 [unused]
//   float4 _SinTime;                   // Offset:   16 Size:    16 [unused]
//   float4 _CosTime;                   // Offset:   32 Size:    16 [unused]
//   float4 unity_DeltaTime;            // Offset:   48 Size:    16 [unused]
//   float3 _WorldSpaceCameraPos;       // Offset:   64 Size:    12
//   float4 _ProjectionParams;          // Offset:   80 Size:    16
//   float4 _ScreenParams;              // Offset:   96 Size:    16 [unused]
//   float4 _ZBufferParams;             // Offset:  112 Size:    16
//   float4 unity_OrthoParams;          // Offset:  128 Size:    16 [unused]
//
// }
//
// cbuffer UnityPerCameraRare
// {
//
//   float4 unity_CameraWorldClipPlanes[6];// Offset:    0 Size:    96 [unused]
//   float4x4 unity_CameraProjection;   // Offset:   96 Size:    64 [unused]
//   float4x4 unity_CameraInvProjection;// Offset:  160 Size:    64 [unused]
//   float4x4 unity_WorldToCamera;      // Offset:  224 Size:    64 [unused]
//   float4x4 unity_CameraToWorld;      // Offset:  288 Size:    64
//
// }
//
// cbuffer UnityShadows
// {
//
//   float4 unity_ShadowSplitSpheres[4];// Offset:    0 Size:    64 [unused]
//   float4 unity_ShadowSplitSqRadii;   // Offset:   64 Size:    16 [unused]
//   float4 unity_LightShadowBias;      // Offset:   80 Size:    16 [unused]
//   float4 _LightSplitsNear;           // Offset:   96 Size:    16 [unused]
//   float4 _LightSplitsFar;            // Offset:  112 Size:    16 [unused]
//   float4x4 unity_WorldToShadow[4];   // Offset:  128 Size:   256 [unused]
//   float4 _LightShadowData;           // Offset:  384 Size:    16
//   float4 unity_ShadowFadeCenterAndType;// Offset:  400 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// _CameraDepthTexture               sampler      NA          NA    0        1
// _LightTextureB0                   sampler      NA          NA    1        1
// _LightTexture0                    sampler      NA          NA    2        1
// unity_RandomRotation16            sampler      NA          NA    3        1
// sampler_ShadowMapTexture        sampler_c      NA          NA    4        1
// _CameraGBufferTexture0            sampler      NA          NA    5        1
// _CameraGBufferTexture1            sampler      NA          NA    6        1
// _CameraGBufferTexture2            sampler      NA          NA    7        1
// _CameraDepthTexture               texture  float4          2d    0        1
// _LightTexture0                    texture  float4          2d    1        1
// _LightTextureB0                   texture  float4          2d    2        1
// unity_RandomRotation16            texture  float4          2d    3        1
// _CameraGBufferTexture0            texture  float4          2d    4        1
// _CameraGBufferTexture1            texture  float4          2d    5        1
// _CameraGBufferTexture2            texture  float4          2d    6        1
// _ShadowMapTexture                 texture  float4          2d    7        1
// $Globals                          cbuffer      NA          NA    0        1
// UnityPerCamera                    cbuffer      NA          NA    1        1
// UnityPerCameraRare                cbuffer      NA          NA    2        1
// UnityShadows                      cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xy w
// TEXCOORD                 1   xyz         2     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.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[89], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[22], immediateIndexed
dcl_constantbuffer cb3[25], 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_comparison
dcl_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, 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_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
dcl_input_ps linear v1.xyw
dcl_input_ps linear v2.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 0481901188f610cc-ps.txt

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

div r0.x, cb1[5].z, v2.z
mul r0.xyz, r0.xxxx, v2.xyzx
div r1.xy, v1.xyxx, v1.wwww
sample r2.xyzw, r1.xyxx, t0.xyzw, s0
mad r0.w, cb1[7].x, r2.x, cb1[7].y
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r2.xyz, r0.yyyy, cb2[19].xyzx
mad r0.xyw, cb2[18].xyxz, r0.xxxx, r2.xyxz
mad r0.xyz, cb2[20].xyzx, r0.zzzz, r0.xywx
add r0.xyz, r0.xyzx, cb2[21].xyzx
add r2.xyz, -r0.xyzx, cb0[4].xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r1.z, r0.w
mul r3.xyz, r1.zzzz, r2.xyzx
mul r4.xyz, r0.yyyy, cb0[8].xywx
mad r4.xyz, cb0[7].xywx, r0.xxxx, r4.xyzx
mad r4.xyz, cb0[9].xywx, r0.zzzz, r4.xyzx
add r4.xyz, r4.xyzx, cb0[10].xywx
add r1.w, r4.z, r4.z
div r4.xy, r4.xyxx, r1.wwww
add_sat r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
sample_b r5.xyzw, r4.xyxx, t1.xyzw, s2, l(-8.000000)
lt r1.w, l(0.000000), r4.z
and r1.w, r1.w, l(0x3f800000)
mul r1.w, r1.w, r5.w
mul r0.w, r0.w, cb0[4].w
max r0.w, r0.w, cb0[83].y
sample r4.xyzw, r0.wwww, t2.xyzw, s1
mul r0.w, r4.x, cb0[83].z
mul r0.w, r0.w, r1.w
mul r4.xyzw, r0.yyyy, cb0[85].xyzw
mad r4.xyzw, cb0[84].xyzw, r0.xxxx, r4.xyzw
mad r4.xyzw, cb0[86].xyzw, r0.zzzz, r4.xyzw
add r4.xyzw, r4.xyzw, cb0[87].xyzw
div r4.xyz, r4.xyzx, r4.wwww
mad r5.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
add r1.w, r4.z, cb0[88].y
add r5.z, -r5.y, l(1.000000)
mul r4.xy, r5.xzxx, l(10.000000, 10.000000, 0.000000, 0.000000)
sample r4.xyzw, r4.xyxx, t3.xyzw, s3
dp3 r2.w, r4.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 r4.x, r6.x, r2.w
add r2.w, -cb3[24].x, l(1.000000)
mul r2.w, r2.w, l(0.025000)
mov r3.w, l(0)
mov r4.y, l(0)
loop
  itof r4.z, r4.y
  ge r4.z, r4.z, l(25.000000)
  breakc_nz r4.z
  mul r4.zw, r6.xxxx, icb[r4.y + 0].xxxy
  mad r7.x, icb[r4.y + 0].y, r4.x, r4.z
  mad r7.y, icb[r4.y + 0].x, -r4.x, r4.w
  mad r4.zw, r7.xxxy, r2.wwww, r5.xxxz
  sample_c_lz r4.z, r4.zwzz, t7.xxxx, s4, r1.w
  add r3.w, r3.w, r4.z
  iadd r4.y, r4.y, l(1)
endloop
mul r1.w, r3.w, l(0.040000)
mul r0.w, r0.w, r1.w
mul r4.xyz, r0.wwww, cb0[5].xyzx
sample r5.xyzw, r1.xyxx, t4.xyzw, s5
sample r6.xyzw, r1.xyxx, t5.xyzw, s6
sample r7.xyzw, r1.xyxx, t6.xyzw, s7
mad r1.xyw, r7.xyxz, l(2.000000, 2.000000, 0.000000, 2.000000), l(-1.000000, -1.000000, 0.000000, -1.000000)
dp3 r2.w, r1.xywx, r1.xywx
rsq r2.w, r2.w
mul r1.xyw, r1.xyxw, r2.wwww
add r0.xyz, r0.xyzx, -r9.xyzx
dp3 r2.w, r0.xyzx, r0.xyzx
rsq r2.w, r2.w
mul r0.xyz, r0.xyzx, r2.wwww
mul r6.xyz, r6.xyzx, cb0[82].xxxx
mul r7.xyz, r0.wwww, r6.xyzx
add r2.w, -r6.w, l(1.000000)
mad r2.xyz, r2.xyzx, r1.zzzz, -r0.xyzx
dp3 r1.z, r2.xyzx, r2.xyzx
max r1.z, r1.z, l(0.001000)
rsq r1.z, r1.z
mul r2.xyz, r1.zzzz, r2.xyzx
dp3 r0.x, r1.xywx, -r0.xyzx
dp3_sat r0.y, r1.xywx, r3.xyzx
dp3_sat r0.z, r1.xywx, r2.xyzx
dp3_sat r1.x, r3.xyzx, r2.xyzx
add r1.y, r1.x, r1.x
mul r1.y, r1.x, r1.y
mad r1.y, r1.y, r2.w, l(-0.500000)
add r1.z, -r0.y, l(1.000000)
mul r1.w, r1.z, r1.z
mul r1.w, r1.w, r1.w
mul r1.z, r1.z, r1.w
mad r1.z, r1.y, r1.z, l(1.000000)
add r1.w, -|r0.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 r1.y, r1.y, r1.w, l(1.000000)
mul r1.y, r1.y, r1.z
mul r1.y, r0.y, r1.y
mul r1.z, r2.w, r2.w
mad r1.w, -r2.w, r2.w, l(1.000000)
mad r2.x, |r0.x|, r1.w, r1.z
mad r1.w, r0.y, r1.w, r1.z
mul r0.x, |r0.x|, r1.w
mad r0.x, r0.y, r2.x, r0.x
add r0.x, r0.x, l(0.000010)
div r0.x, l(0.500000), r0.x
mul r1.z, r1.z, r1.z
mad r1.w, r0.z, r1.z, -r0.z
mad r0.z, r1.w, r0.z, l(1.000000)
mul r1.z, r1.z, l(0.318309873)
mad r0.z, r0.z, r0.z, l(1.000000012E-007)
div r0.z, r1.z, r0.z
mul r0.x, r0.z, r0.x
mul r0.x, r0.x, l(3.14159274)
mul r0.x, r0.y, r0.x
max r0.x, r0.x, l(0.000000)
dp3 r0.y, r7.xyzx, r7.xyzx
ne r0.y, r0.y, l(0.000000)
and r0.y, r0.y, l(0x3f800000)
mul r0.x, r0.y, r0.x
mul r1.yzw, r1.yyyy, r4.xxyz
mul r0.xyz, r4.xyzx, r0.xxxx
add r1.x, -r1.x, l(1.000000)
mul r2.x, r1.x, r1.x
mul r2.x, r2.x, r2.x
mul r1.x, r1.x, r2.x
mad r2.xyz, -r6.xyzx, r0.wwww, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r2.xyz, r2.xyzx, r1.xxxx, r7.xyzx
mul r0.xyz, r0.xyzx, r2.xyzx
mad r0.xyz, r5.xyzx, r1.yzwy, r0.xyzx
max r0.xyz, r0.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov r0.w, l(1.000000)
exp o0.xyzw, -r0.xyzw
ret
// Approximately 140 instruction slots used