//P5S attack haloing PS. Related to 2724dfd122667f50-vs.txt
// ---- Created with 3Dmigoto v1.3.16 on Sun Mar 06 17:40:13 2022

cbuffer _Globals : register(b0)
{
  float vATest : packoffset(c0);
  float2 vSatFade : packoffset(c1) = {0,1};
  bool bSatFade : packoffset(c2) = true;
  float envscale : packoffset(c36);
}

SamplerState __smpsStage0_s : register(s0);
SamplerState __smpsRTT_s : register(s3);
SamplerState __smpsEnv_s : register(s4);
Texture2D<float4> sStage0 : register(t0);
Texture2D<float4> sRTT : register(t3);
TextureCube<float4> sEnv : register(t4);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main(
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float4 v2 : TEXCOORD1,
  float4 v3 : TEXCOORD2,
  float2 v4 : TEXCOORD3,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xyzw = sStage0.Sample(__smpsStage0_s, v4.xy).xyzw;
  r1.x = -vATest + r0.w;
  r1.x = cmp(r1.x < 0);
  if (r1.x != 0) discard;
  r1.x = cmp(0.00400000019 >= r0.w);
  r0.w = r1.x ? 0 : r0.w;
  r0.xyzw = v1.xyzw * r0.xyzw;
  o0.w = r0.w;
  r1.xyzw = sEnv.Sample(__smpsEnv_s, v3.xyz).xyzw;
  r0.w = envscale * r1.w;
  r1.xyz = r1.xyz * r0.www;
  r1.xyz = v2.www * r1.xyz;
  
  v2.x+=stereo.x*(v2.z-stereo.y*2)*0.5;
  
  r2.xy = v2.xy / v2.zz;
  r2.xyz = sRTT.Sample(__smpsRTT_s, r2.xy).xyz;
  r0.xyz = r2.xyz * r0.xyz + r1.xyz;
  r0.w = max(r0.y, r0.z);
  r0.w = max(r0.x, r0.w);
  r1.xyz = r0.www * vSatFade.yyy + -r0.xyz;
  r1.xyz = vSatFade.xxx * r1.xyz + r0.xyz;
  o0.xyz = bSatFade ? r1.xyz : r0.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Sun Mar 06 17:40:13 2022
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float vATest;                      // Offset:    0 Size:     4
//   float2 vSatFade;                   // Offset:   16 Size:     8
//      = 0x00000000 0x3f800000
//   bool bSatFade;                     // Offset:   32 Size:     4
//      = 0xffffffff
//   float envscale;                    // Offset:  576 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsStage0                      sampler      NA          NA    0        1
// __smpsRTT                         sampler      NA          NA    3        1
// __smpsEnv                         sampler      NA          NA    4        1
// sStage0                           texture  float4          2d    0        1
// sRTT                              texture  float4          2d    3        1
// sEnv                              texture  float4        cube    4        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// 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   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xy          4     NONE   float   xy
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[37], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texturecube (float,float,float,float) t4
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xy
dcl_output o0.xyzw
dcl_temps 3
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, v4.xyxx, t0.xyzw, s0
add r1.x, r0.w, -cb0[0].x
lt r1.x, r1.x, l(0.000000)
discard_nz r1.x
ge r1.x, l(0.004000), r0.w
movc r0.w, r1.x, l(0), r0.w
mul r0.xyzw, r0.xyzw, v1.xyzw
mov o0.w, r0.w
sample_indexable(texturecube)(float,float,float,float) r1.xyzw, v3.xyzx, t4.xyzw, s4
mul r0.w, r1.w, cb0[36].x
mul r1.xyz, r0.wwww, r1.xyzx
mul r1.xyz, r1.xyzx, v2.wwww
div r2.xy, v2.xyxx, v2.zzzz
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t3.xyzw, s3
mad r0.xyz, r2.xyzx, r0.xyzx, r1.xyzx
max r0.w, r0.z, r0.y
max r0.w, r0.w, r0.x
mad r1.xyz, r0.wwww, cb0[1].yyyy, -r0.xyzx
mad r1.xyz, cb0[1].xxxx, r1.xyzx, r0.xyzx
movc o0.xyz, cb0[2].xxxx, r1.xyzx, r0.xyzx
ret
// Approximately 21 instruction slots used

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
