// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 156172f8a5f66131-ps.txt
// 3DMigoto: 156172f8a5f66131 |    Unity headers extracted from Hidden_SoftPointLight
//    Shader "Hidden/SoftPointLight" {
//      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_SoftPointLight:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 98 5 0
//   undeciphered1a: 7
//   Keywords { "POINT" "POINT_COOKIE" }
//   undeciphered2: 1 6 3 6 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1264
//   Vector 64 [_LightPos]
//   Vector 80 [_LightColor]
//   Float 1232 [_LightSpecStrength]
//   Vector 1236 [_AttenuationPlaneNormal] 3
//   Vector 1248 [_AttenuationSettings]
//   Matrix 112 [unity_WorldToLight]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 80 [_ProjectionParams]
//   Vector 112 [_ZBufferParams]
//   ConstBuffer "UnityPerCameraRare" 352
//   Matrix 288 [unity_CameraToWorld]
//   SetTexture 0 [_CameraDepthTexture] 2D 0
//   SetTexture 1 [_LightTextureB0] 2D 1
//   SetTexture 2 [_LightTexture0] CUBE 2
//   SetTexture 3 [_CameraGBufferTexture0] 2D 3
//   SetTexture 4 [_CameraGBufferTexture1] 2D 4
//   SetTexture 5 [_CameraGBufferTexture2] 2D 5
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityPerCameraRare" 2
//
// 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:52:17 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 _LightColor0;               // Offset: 1200 Size:    16 [unused]
//   float4 _SpecColor;                 // Offset: 1216 Size:    16 [unused]
//   float _LightSpecStrength;          // Offset: 1232 Size:     4
//      = 0x3f800000
//   float3 _AttenuationPlaneNormal;    // Offset: 1236 Size:    12
//      = 0x3f800000 0x00000000 0x00000000
//   float4 _AttenuationSettings;       // Offset: 1248 Size:    16
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000
//
// }
//
// 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
//
// }
//
//
// 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
// _CameraGBufferTexture0            sampler      NA          NA    3        1
// _CameraGBufferTexture1            sampler      NA          NA    4        1
// _CameraGBufferTexture2            sampler      NA          NA    5        1
// _CameraDepthTexture               texture  float4          2d    0        1
// _LightTextureB0                   texture  float4          2d    1        1
// _LightTexture0                    texture  float4        cube    2        1
// _CameraGBufferTexture0            texture  float4          2d    3        1
// _CameraGBufferTexture1            texture  float4          2d    4        1
// _CameraGBufferTexture2            texture  float4          2d    5        1
// $Globals                          cbuffer      NA          NA    0        1
// UnityPerCamera                    cbuffer      NA          NA    1        1
// UnityPerCameraRare                cbuffer      NA          NA    2        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_constantbuffer cb0[79], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[22], 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_texture2d (float,float,float,float) t5
dcl_input_ps linear v1.xyw
dcl_input_ps linear v2.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 156172f8a5f66131-ps.txt

mul r7.w, -r7.x, r7.y
mad r8.xyz, -r7.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, -r8.xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
add r3.xyz, r0.xyzx, -cb0[4].xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r1.z, r0.w
mad r4.xyz, -r3.xyzx, r1.zzzz, -r2.xyzx
mul r3.xyz, r1.zzzz, r3.xyzx
dp3 r1.z, r4.xyzx, r4.xyzx
max r1.z, r1.z, l(0.001000)
rsq r1.z, r1.z
mul r4.xyz, r1.zzzz, r4.xyzx
sample r5.xyzw, r1.xyxx, t5.xyzw, s5
mad r5.xyz, r5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r1.z, r5.xyzx, r5.xyzx
rsq r1.z, r1.z
mul r5.xyz, r1.zzzz, r5.xyzx
dp3_sat r1.z, r5.xyzx, r4.xyzx
dp3_sat r1.w, -r3.xyzx, r4.xyzx
sample r4.xyzw, r1.xyxx, t4.xyzw, s4
sample r6.xyzw, r1.xyxx, t3.xyzw, s3
add r1.x, -r4.w, l(1.000000)
mul r4.xyz, r4.xyzx, cb0[77].xxxx
mul r1.y, r1.x, r1.x
mul r2.w, r1.y, r1.y
mad r3.w, r1.z, r2.w, -r1.z
mad r1.z, r3.w, r1.z, l(1.000000)
mad r1.z, r1.z, r1.z, l(1.000000012E-007)
mul r2.w, r2.w, l(0.318309873)
div r1.z, r2.w, r1.z
dp3 r2.x, r5.xyzx, -r2.xyzx
dp3_sat r2.y, r5.xyzx, -r3.xyzx
dp3 r2.z, r3.xyzx, cb0[77].yzwy
mad r2.w, -r1.x, r1.x, l(1.000000)
mad r3.x, |r2.x|, r2.w, r1.y
mad r1.y, r2.y, r2.w, r1.y
mul r1.y, r1.y, |r2.x|
add r2.x, -|r2.x|, l(1.000000)
mad r1.y, r2.y, r3.x, r1.y
add r1.y, r1.y, l(0.000010)
div r1.y, l(0.500000), r1.y
mul r1.y, r1.z, r1.y
mul r1.y, r1.y, l(3.14159274)
mul r1.y, r2.y, r1.y
max r1.y, r1.y, l(0.000000)
mul r3.xyz, r0.yyyy, cb0[8].xyzx
mad r3.xyz, cb0[7].xyzx, r0.xxxx, r3.xyzx
mad r0.xyz, cb0[9].xyzx, r0.zzzz, r3.xyzx
add r0.xyz, r0.xyzx, cb0[10].xyzx
sample_b r3.xyzw, r0.xyzx, t2.xyzw, s2, l(-8.000000)
sqrt r0.x, r0.w
mul r0.y, r0.w, cb0[4].w
max r0.y, r0.y, cb0[78].y
sample r5.xyzw, r0.yyyy, t1.xyzw, s1
mul r0.y, r5.x, cb0[78].z
div r0.z, -cb0[78].x, r2.z
lt r0.w, l(0.010000), r2.z
lt r0.x, -r0.z, r0.x
movc r0.x, r0.x, l(0), r0.y
movc r0.x, r0.w, r0.x, r0.y
lt r0.z, l(0.000000), cb0[78].x
movc r0.x, r0.z, r0.x, r0.y
mul r0.x, r3.w, r0.x
mul r0.yzw, r0.xxxx, r4.xxyz
mad r3.xyz, -r4.xyzx, r0.xxxx, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r4.xyz, r0.xxxx, cb0[5].xyzx
dp3 r0.x, r0.yzwy, r0.yzwy
ne r0.x, r0.x, l(0.000000)
and r0.x, r0.x, l(0x3f800000)
mul r0.x, r0.x, r1.y
mul r5.xyz, r4.xyzx, r0.xxxx
add r0.x, -r1.w, l(1.000000)
mul r1.y, r1.w, r1.w
dp2 r1.x, r1.yyyy, r1.xxxx
add r1.x, r1.x, l(-0.500000)
mul r1.y, r0.x, r0.x
mul r1.y, r1.y, r1.y
mul r0.x, r0.x, r1.y
mad r0.xyz, r3.xyzx, r0.xxxx, r0.yzwy
mul r0.xyz, r0.xyzx, r5.xyzx
mul r0.w, r2.x, r2.x
mul r0.w, r0.w, r0.w
mul r0.w, r2.x, r0.w
mad r0.w, r1.x, r0.w, l(1.000000)
add r1.y, -r2.y, l(1.000000)
mul r1.z, r1.y, r1.y
mul r1.z, r1.z, r1.z
mul r1.y, r1.y, r1.z
mad r1.x, r1.x, r1.y, l(1.000000)
mul r0.w, r0.w, r1.x
mul r0.w, r2.y, r0.w
mul r1.xyz, r0.wwww, r4.xyzx
mad r0.xyz, r6.xyzx, r1.xyzx, 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 109 instruction slots used