//MGS2 plane heatwave haloing.
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v0.6.181 on Thu Nov  9 00:13:13 2023
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   row_major float4x4 gVS_Projection; // Index:  300 301 302 303    Components:    16 [unused]
//   int gPs_AlphaTestEnable;           // Index:  304.x              Components:     1
//   int gPs_AlphaTestType;             // Index:  305.x              Components:     1
//   float gPs_AlphaTestRefValue;       // Index:  306.x              Components:     1
//   float gPs_AlphaTestThreshold;      // Index:  307.x              Components:     1
//   int gPs_MultiSampleMaskEnable;     // Index:  308.x              Components:     1
//   int gPs_MultiSampleMask;           // Index:  309.x              Components:     1
//   float4 gVS_FogColor;               // Index:    0.xyzw           Components:     4 [unused]
//   float4 gVS_FogParam;               // Index:    1.xyzw           Components:     4 [unused]
//   row_major float4x4 gVS_LightDir;   // Index:    2 3 4 5          Components:    16 [unused]
//   row_major float4x4 gVS_LightCol;   // Index:    6 7 8 9          Components:    16 [unused]
//   float4 gVS_Sampler0Info;           // Index:   10.xyzw           Components:     4 [unused]
//   float4 gVS_EnvmapParams;           // Index:   11.xyzw           Components:     4 [unused]
//   row_major float4x4 gVS_Screen;     // Index:   16 17 18 19       Components:    16 [unused]
//   row_major float4x4 gVS_Pers;       // Index:   20 21 22 23       Components:    16 [unused]
//   float4 gVS_UVScaleOffset;          // Index:   24.xyzw           Components:     4 [unused]
//   row_major float4x4 g_View;         // Index:  310 311 312 313    Components:    16 [unused]
//   row_major float4x4 g_ViewProjection;// Index:  314 315 316 317    Components:    16 [unused]
//   row_major float4x4 g_World;        // Index:  318 319 320 321    Components:    16 [unused]
//   row_major float4x4 g_WorldViewProjection;// Index:  322 323 324 325    Components:    16 [unused]
//   row_major float4x3 g_JointWorld[32];// Index:  326-453.z          Components:   511 [unused]
//   float4 g_RenderTargetDimensions;   // Index:  454.xyzw           Components:     4 [unused]
//   float4 g_RenderTargetNearFar;      // Index:  455.xyzw           Components:     4 [unused]
//   float4 g_RenderTargetDepthRange;   // Index:  456.xyzw           Components:     4 [unused]
//   float4 g_AdditiveColor;            // Index:  457.xyzw           Components:     4 [unused]
//   float4 g_ModulateColor;            // Index:  458.xyzw           Components:     4 [unused]
//   float4 g_EyePosition;              // Index:  459.xyzw           Components:     4 [unused]
//   float4 g_ExternalShaderParam;      // Index:  460.xyzw           Components:     4 [unused]
//   float4 g_LightColor0;              // Index:  461.xyzw           Components:     4 [unused]
//   float4 g_LightPosition0;           // Index:  462.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation0;        // Index:  463.xyzw           Components:     4 [unused]
//   float4 g_LightColor1;              // Index:  464.xyzw           Components:     4 [unused]
//   float4 g_LightPosition1;           // Index:  465.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation1;        // Index:  466.xyzw           Components:     4 [unused]
//   float4 g_LightColor2;              // Index:  467.xyzw           Components:     4 [unused]
//   float4 g_LightPosition2;           // Index:  468.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation2;        // Index:  469.xyzw           Components:     4 [unused]
//   float4 g_LightColor3;              // Index:  470.xyzw           Components:     4 [unused]
//   float4 g_LightPosition3;           // Index:  471.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation3;        // Index:  472.xyzw           Components:     4 [unused]
//   float4 g_LightColor4;              // Index:  473.xyzw           Components:     4 [unused]
//   float4 g_LightPosition4;           // Index:  474.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation4;        // Index:  475.xyzw           Components:     4 [unused]
//   float4 g_LightColor5;              // Index:  476.xyzw           Components:     4 [unused]
//   float4 g_LightPosition5;           // Index:  477.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation5;        // Index:  478.xyzw           Components:     4 [unused]
//   float4 g_LightColor6;              // Index:  479.xyzw           Components:     4 [unused]
//   float4 g_LightPosition6;           // Index:  480.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation6;        // Index:  481.xyzw           Components:     4 [unused]
//   float4 g_LightColor7;              // Index:  482.xyzw           Components:     4 [unused]
//   float4 g_LightPosition7;           // Index:  483.xyzw           Components:     4 [unused]
//   float4 g_LightAttenuation7;        // Index:  484.xyzw           Components:     4 [unused]
//   float4 gPS_FogColor;               // Index:  485.xyzw           Components:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// sTextureSampler                   sampler      NA          NA    0        1
// tTextureSampler                   texture  float4          2d    0        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy
// TEXCOORD                 0   xyzw        1     NONE   float   xy
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
//
//
// 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[310], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyzw
dcl_output o0.xyzw
dcl_temps 31
dcl_resource_texture2d (float,float,float,float) t125
ld_indexable(texture2d)(float,float,float,float) r25.xyzw, l(0, 0, 0, 0), t125.xyzw

mov r11.xy, v1.xyxx
div r26.x, r25.y, v0.w
add r26.x, l(1.0), -r26.x
mul r26.x, r26.x, l(0.5)
mad r11.x, r25.x, r26.x, r11.x

sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r11.xyxx, t0.xyzw, s0
mul r0.w, r0.w, v2.w
mov r1.xyz, v2.xyzx
mov r1.w, l(0.500000)
mul_sat r0.xyzw, r0.xyzw, r1.xyzw
mul r1.xyzw, r0.xyzw, l(1.000000, 1.000000, 1.000000, 2.000000)
if_nz cb0[304].x
  switch cb0[305].x
    case l(0)
    mov r0.x, l(-1)
    break
    case l(1)
    add r0.y, cb0[306].x, -cb0[307].x
    lt r0.y, r1.w, r0.y
    movc r0.x, r0.y, l(1), l(-1)
    break
    case l(2)
    mad r0.y, r0.w, l(2.000000), -cb0[306].x
    lt r0.y, |r0.y|, cb0[307].x
    movc r0.x, r0.y, l(1), l(-1)
    break
    case l(3)
    add r0.y, cb0[306].x, cb0[307].x
    lt r0.y, r1.w, r0.y
    movc r0.x, r0.y, l(1), l(-1)
    break
    case l(4)
    add r0.y, cb0[306].x, cb0[307].x
    lt r0.y, r1.w, r0.y
    movc r0.x, r0.y, l(-1), l(1)
    break
    case l(5)
    mad r0.y, r0.w, l(2.000000), -cb0[306].x
    lt r0.y, |r0.y|, cb0[307].x
    movc r0.x, r0.y, l(-1), l(1)
    break
    case l(6)
    add r0.y, cb0[306].x, -cb0[307].x
    lt r0.y, r1.w, r0.y
    movc r0.x, r0.y, l(-1), l(1)
    break
    case l(7)
    mov r0.x, l(1)
    break
    default
    mov r0.x, l(1)
    break
  endswitch
else
  mov r0.x, l(1)
endif
ilt r0.x, r0.x, l(0)
discard_nz r0.x
if_nz cb0[308].x
  ine r0.x, cb0[309].x, l(-1)
  ftoi r0.yz, v0.yyxy
  and r0.yz, r0.yyzy, l(0, 1, 1, 0)
  xor r0.w, r0.z, r0.y
  ine r2.x, r0.w, l(0)
  ieq r2.yz, cb0[309].xxxx, l(0, 4080, 0x0000f00f, 0)
  ieq r0.y, r0.y, r0.z
  movc r0.zw, r0.yyyw, l(0,0,-1,-1), l(0,0,1,1)
  movc r0.z, r2.z, r0.z, l(1)
  and r0.y, r0.y, r2.z
  movc r0.z, r2.y, r0.w, r0.z
  movc r0.y, r2.y, r2.x, r0.y
  movc r0.y, r0.y, r0.z, l(1)
  movc r0.x, r0.x, r0.y, l(1)
else
  mov r0.x, l(1)
endif
ilt r0.x, r0.x, l(0)
discard_nz r0.x
mov o0.xyzw, r1.xyzw
ret
// Approximately 75 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v0.6.181 on Thu Nov  9 00:13:13 2023
//
// cbuffer _Globals : register(b0)
// {
//   row_major float4x4 gVS_Projection : packoffset(c300);
//   int gPs_AlphaTestEnable : packoffset(c304);
//   int gPs_AlphaTestType : packoffset(c305);
//   float gPs_AlphaTestRefValue : packoffset(c306);
//   float gPs_AlphaTestThreshold : packoffset(c307);
//   int gPs_MultiSampleMaskEnable : packoffset(c308);
//   int gPs_MultiSampleMask : packoffset(c309);
//   float4 gVS_FogColor : packoffset(c0);
//   float4 gVS_FogParam : packoffset(c1);
//   row_major float4x4 gVS_LightDir : packoffset(c2);
//   row_major float4x4 gVS_LightCol : packoffset(c6);
//   float4 gVS_Sampler0Info : packoffset(c10);
//   float4 gVS_EnvmapParams : packoffset(c11);
//   row_major float4x4 gVS_Screen : packoffset(c16);
//   row_major float4x4 gVS_Pers : packoffset(c20);
//   float4 gVS_UVScaleOffset : packoffset(c24);
//   row_major float4x4 g_View : packoffset(c310);
//   row_major float4x4 g_ViewProjection : packoffset(c314);
//   row_major float4x4 g_World : packoffset(c318);
//   row_major float4x4 g_WorldViewProjection : packoffset(c322);
//   row_major float4x3 g_JointWorld[32] : packoffset(c326);
//   float4 g_RenderTargetDimensions : packoffset(c454);
//   float4 g_RenderTargetNearFar : packoffset(c455);
//   float4 g_RenderTargetDepthRange : packoffset(c456);
//   float4 g_AdditiveColor : packoffset(c457);
//   float4 g_ModulateColor : packoffset(c458);
//   float4 g_EyePosition : packoffset(c459);
//   float4 g_ExternalShaderParam : packoffset(c460);
//   float4 g_LightColor0 : packoffset(c461);
//   float4 g_LightPosition0 : packoffset(c462);
//   float4 g_LightAttenuation0 : packoffset(c463);
//   float4 g_LightColor1 : packoffset(c464);
//   float4 g_LightPosition1 : packoffset(c465);
//   float4 g_LightAttenuation1 : packoffset(c466);
//   float4 g_LightColor2 : packoffset(c467);
//   float4 g_LightPosition2 : packoffset(c468);
//   float4 g_LightAttenuation2 : packoffset(c469);
//   float4 g_LightColor3 : packoffset(c470);
//   float4 g_LightPosition3 : packoffset(c471);
//   float4 g_LightAttenuation3 : packoffset(c472);
//   float4 g_LightColor4 : packoffset(c473);
//   float4 g_LightPosition4 : packoffset(c474);
//   float4 g_LightAttenuation4 : packoffset(c475);
//   float4 g_LightColor5 : packoffset(c476);
//   float4 g_LightPosition5 : packoffset(c477);
//   float4 g_LightAttenuation5 : packoffset(c478);
//   float4 g_LightColor6 : packoffset(c479);
//   float4 g_LightPosition6 : packoffset(c480);
//   float4 g_LightAttenuation6 : packoffset(c481);
//   float4 g_LightColor7 : packoffset(c482);
//   float4 g_LightPosition7 : packoffset(c483);
//   float4 g_LightAttenuation7 : packoffset(c484);
//   float4 gPS_FogColor : packoffset(c485);
// }
//
// SamplerState sTextureSampler_s : register(s0);
// Texture2D<float4> tTextureSampler : register(t0);
//
//
// // 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,
//   out float4 o0 : SV_TARGET0)
// {
//   float4 r0,r1,r2;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
//   r0.xyzw = tTextureSampler.Sample(sTextureSampler_s, v1.xy).xyzw;
//   r0.w = v2.w * r0.w;
//   r1.xyz = v2.xyz;
//   r1.w = 0.5;
//   r0.xyzw = saturate(r1.xyzw * r0.xyzw);
//   r1.xyzw = float4(1,1,1,2) * r0.xyzw;
//   if (gPs_AlphaTestEnable != 0) {
//     switch (cb0[305].x) {
//       case 0 :      r0.x = -1;
//       break;
//       case 1 :      r0.y = -gPs_AlphaTestThreshold + gPs_AlphaTestRefValue;
//       r0.y = cmp(r1.w < r0.y);
//       r0.x = r0.y ? 1 : -1;
//       break;
//       case 2 :      r0.y = r0.w * 2 + -gPs_AlphaTestRefValue;
//       r0.y = cmp(abs(r0.y) < gPs_AlphaTestThreshold);
//       r0.x = r0.y ? 1 : -1;
//       break;
//       case 3 :      r0.y = gPs_AlphaTestThreshold + gPs_AlphaTestRefValue;
//       r0.y = cmp(r1.w < r0.y);
//       r0.x = r0.y ? 1 : -1;
//       break;
//       case 4 :      r0.y = gPs_AlphaTestThreshold + gPs_AlphaTestRefValue;
//       r0.y = cmp(r1.w < r0.y);
//       r0.x = r0.y ? -1 : 1;
//       break;
//       case 5 :      r0.y = r0.w * 2 + -gPs_AlphaTestRefValue;
//       r0.y = cmp(abs(r0.y) < gPs_AlphaTestThreshold);
//       r0.x = r0.y ? -1 : 1;
//       break;
//       case 6 :      r0.y = -gPs_AlphaTestThreshold + gPs_AlphaTestRefValue;
//       r0.y = cmp(r1.w < r0.y);
//       r0.x = r0.y ? -1 : 1;
//       break;
//       case 7 :      r0.x = 1;
//       break;
//       default :
//       r0.x = 1;
//       break;
//     }
//   } else {
//     r0.x = 1;
//   }
//   r0.x = cmp((int)r0.x < 0);
//   if (r0.x != 0) discard;
//   if (gPs_MultiSampleMaskEnable != 0) {
//     r0.x = cmp(gPs_MultiSampleMask != -1);
//     r0.yz = (int2)v0.yx;
//     r0.yz = (int2)r0.yz & int2(1,1);
//     r0.w = (int)r0.z ^ (int)r0.y;
//     r2.x = cmp((int)r0.w != 0);
//     r2.yz = cmp(gPs_MultiSampleMask == int2(4080,0xf00f));
//     r0.y = cmp((int)r0.y == (int)r0.z);
//     r0.zw = r0.yw ? float2(-nan,-nan) : float2(1.40129846e-45,1.40129846e-45);
//     r0.z = r2.z ? r0.z : 1;
//     r0.y = r0.y ? r2.z : 0;
//     r0.z = r2.y ? r0.w : r0.z;
//     r0.y = r2.y ? r2.x : r0.y;
//     r0.y = r0.y ? r0.z : 1;
//     r0.x = r0.x ? r0.y : 1;
//   } else {
//     r0.x = 1;
//   }
//   r0.x = cmp((int)r0.x < 0);
//   if (r0.x != 0) discard;
//   o0.xyzw = r1.xyzw;
//   return;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// H:\SteamLibrary\steamapps\common\MGS2\ShaderFixes\3bacce023e02f100-ps_replace.txt(87,13-15): error X3004: undeclared identifier 'cb0'
/////////////////////////////////////////////////////////////////////////////
