// Fire heat-wave 

cbuffer PSCommonBuffer : register(b0)
{
  float4 g_color : packoffset(c0);
  float4 g_resolveRectUV : packoffset(c1);
  float g_ps_nearFar : packoffset(c4);
  float g_ps_nearFarDistance : packoffset(c4.y);
  float g_ps_far : packoffset(c4.z);
  float g_ps_near : packoffset(c4.w);
  float g_waveTime : packoffset(c5);
  float g_clampDistanceInverse : packoffset(c5.y);
  float g_waveStrength : packoffset(c5.z);
  float g_waveNum : packoffset(c5.w);
  float g_vNormalMapScrollDistance : packoffset(c6);
  float g_hNormalMapScrollDistance : packoffset(c6.y);
  float g_fToneMapReceiprocalExposure : packoffset(c6.z);
  float2 g_screenCenter : packoffset(c7);
  float g_radialDistance : packoffset(c7.z);
  float g_TransrancyPower : packoffset(c7.w);
  float4 g_ps_aboveShadowCascadeSwitchDist : packoffset(c8);
  float4 g_vColorScale : packoffset(c9);
  float g_specularShininessFactor : packoffset(c11);
  uint g_ps_envCbIndex : packoffset(c11.y);
  float g_specularScale : packoffset(c11.z);
  int g_flipbookBlendMode : packoffset(c11.w);
  float4 g_vLightMask : packoffset(c13);
  float4 g_vTracerParam : packoffset(c14);
  float g_Decay : packoffset(c15);
  float g_DecayWeight : packoffset(c15.y);
  float g_Dencity : packoffset(c15.z);
  float g_Exposure : packoffset(c15.w);
  float g_LightSourceScaleX : packoffset(c16);
  float g_LightSourceScaleY : packoffset(c16.y);
  int g_SampleNum : packoffset(c16.z);
  float g_LightSourceScale : packoffset(c16.w);
  float4 g_LightShaftScreenCenter : packoffset(c17);
  float4x4 g_psViewMatrix : packoffset(c18);
  float4 g_psGlowScale : packoffset(c22);
  int g_ps_TexBlendType : packoffset(c23);
  int g_ps_TexBlendType2 : packoffset(c23.y);
  int g_ps_TexBlendType3 : packoffset(c23.z);
  int g_ps_ColorBlendType : packoffset(c23.w);
  float4 g_ps_TextureColor1 : packoffset(c24);
  float4 g_ps_TextureColor2 : packoffset(c25);
  float4 g_ps_TextureColor3 : packoffset(c26);
  float g_ps_invPreExposure : packoffset(c27.y);
  int g_ps_BlendingMode : packoffset(c27.z);
  int g_ps_FogMultMode : packoffset(c27.w);
  float4 g_ps_TextureOnlyColor : packoffset(c28);
  float4 g_ps_softSpriteParam : packoffset(c29);
  float g_ps_RadialBlurSamplingLengthMaxX : packoffset(c30);
  float g_ps_RadialBlurSamplingLengthMaxY : packoffset(c30.y);
  float2 g_ps_softSpriteScaleOffset : packoffset(c30.z);
  float4 g_ps_LightShaftDir : packoffset(c31);
  float4 g_ps_LightShaftDustScaleOffset : packoffset(c32);
  float4 g_ps_LightShaftDustThreshold : packoffset(c33);
  int g_ps_bPreAlphaMult : packoffset(c34);
  int g_ps_bEnableLighting : packoffset(c34.y);
  int g_ps_bEnableFog : packoffset(c34.z);
  float g_ps_preExposure : packoffset(c34.w);
  float g_ps_BillboardShadowIntensity : packoffset(c35);
  float4 g_ps_ShadowcVolumeParam0 : packoffset(c36);
  float4 g_ps_ShadowcVolumeParam1 : packoffset(c37);
  float4x4 g_ps_invProjMatrix : packoffset(c38);
  float4x4 g_ps_shadowMatrixNarrrow : packoffset(c42);
  float4 g_ps_envCbColScale : packoffset(c47);
  float4 g_ps_VolumeFogParam[4] : packoffset(c48);
  float4x4 g_ps_projectionMatrix : packoffset(c52);
  float4x4 g_ps_shadowMatrixBroad : packoffset(c56);
}

SamplerState g_ClampPointSampler_s : register(s7);
SamplerState g_WrapLinearSampler_s : register(s8);
SamplerState g_ClampLinearSampler_s : register(s9);
Texture2D<float4> g_frameBufferTexture : register(t0);
Texture2D<float4> g_normalTexture : register(t1);
Texture2D<float4> g_depthTexture : register(t3);


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


void main(
  float4 v0 : TEXCOORD0,
  float3 v1 : TEXCOORD1,
  float w1 : TEXCOORD5,
  float4 v2 : TEXCOORD2,
  float4 v3 : TEXCOORD3,
  float4 v4 : TEXCOORD4,
  float4 v5 : SV_POSITION0,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;
  //discard;

  r0.xy = v4.xy / v4.ww;
  r0.xy = r0.xy * float2(0.5,-0.5) + float2(0.5,0.5);
  r0.zw = float2(-0.5,-0.5) + v0.xy;
  r0.zw = abs(r0.zw) + abs(r0.zw);
  r0.z = dot(r0.zw, r0.zw);
  r0.z = sqrt(r0.z);
  r1.x = g_vNormalMapScrollDistance * g_waveTime;
  r1.y = -g_hNormalMapScrollDistance * g_waveTime;
  r1.xy = v0.xy + r1.xy;
  r1.xy = g_normalTexture.Sample(g_WrapLinearSampler_s, r1.xy).xy;
  r1.xy = r1.xy * float2(2,2) + float2(-1,-1);
  r0.z = -g_clampDistanceInverse * r0.z + 1;
  r0.z = max(0, r0.z);
  r0.z = 0.00999999978 * r0.z;
  r1.xy = g_waveStrength * r1.xy;
  r1.zw = v0.zw / v1.xx;
  r1.zw = float2(1,1) + r1.zw;
  r1.zw = float2(0.5,0.5) * r1.zw;
  r0.zw = r1.xy * r0.zz + r1.zw;
  r0.zw = max(g_resolveRectUV.xy, r0.zw);
  r0.zw = min(g_resolveRectUV.zw, r0.zw);
  r2.xyz = g_frameBufferTexture.Sample(g_ClampLinearSampler_s, r0.zw).xyz;
  r2.xyz = g_ps_invPreExposure * r2.xyz;
  r1.xyz = g_frameBufferTexture.Sample(g_ClampLinearSampler_s, r1.zw).xyz;
  r1.xyz = g_ps_invPreExposure * r1.xyz;
  r0.z = g_depthTexture.Sample(g_ClampPointSampler_s, r0.zw).x;
  r0.z = 1 + -r0.z;
  r0.z = r0.z * g_ps_nearFarDistance + -g_ps_far;
  r0.z = -g_ps_nearFar / r0.z;
  r0.z = cmp(v3.z >= r0.z);
  r1.xyz = r0.zzz ? r1.xyz : r2.xyz;
  r1.w = 1;
  
  
  
  r0.z = cmp(2 == g_ps_ColorBlendType);
  r2.xyz = cmp(r1.xyz < float3(0.5,0.5,0.5));
  r3.xyz = r1.xyz + r1.xyz;
  r3.xyz = g_color.xyz * r3.xyz;
  r4.xyz = float3(1,1,1) + -r1.xyz;
  r4.xyz = r4.xyz + r4.xyz;
  r5.xyz = -g_color.xyz + float3(1,1,1);
  r4.xyz = -r4.xyz * r5.xyz + float3(1,1,1);
  r2.xyz = r2.xyz ? r3.xyz : r4.xyz;
  r2.w = g_color.w;
  r2.xyzw = g_vColorScale.xyzw * r2.xyzw;
  r1.xyzw = g_color.xyzw * r1.xyzw;
  r1.xyzw = g_vColorScale.xyzw * r1.xyzw;
  r1.xyzw = r0.zzzz ? r2.xyzw : r1.xyzw;
  r0.z = cmp(v3.w < 9.99999975e-005);
  r0.x = g_depthTexture.Sample(g_ClampPointSampler_s, r0.xy).x;
  r0.x = 1 + -r0.x;
  r0.x = r0.x * g_ps_nearFarDistance + -g_ps_far;
  r0.x = -g_ps_nearFar / r0.x;
  r0.x = -v3.z + r0.x;
  r0.x = min(v3.w, r0.x);
  r0.x = saturate(r0.x / v3.w);
  r0.x = r0.z ? 1 : r0.x;
  r0.x = r1.w * r0.x;
  r0.yzw = max(float3(0,0,0), r1.xyz);
  r1.x = cmp(g_ps_softSpriteParam.y >= r0.x);
  r0.x = r1.x ? 0 : r0.x;
  r1.x = cmp(4 != g_ps_BlendingMode);
  r1.yzw = g_ps_preExposure * r0.yzw;
  r0.yzw = r1.xxx ? r1.yzw : r0.yzw;
  r1.x = cmp(1 < r0.x);
  if (r1.x != 0) {
    r1.xy = cmp(int2(1,2) == g_ps_BlendingMode);
    r1.x = (int)r1.y | (int)r1.x;
    r1.yzw = r0.yzw * r0.xxx;
    o0.xyz = r1.xxx ? r1.yzw : r0.yzw;
    o0.w = saturate(r0.x);
  } else {
    o0.w = max(0, r0.x);
    o0.xyz = r0.yzw;
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//   using 3Dmigoto v1.3.16 on Wed Mar 27 19:21:38 2019
//
//
// Buffer Definitions:
//
// cbuffer PSCommonBuffer
// {
//
//   float4 g_color;                    // Offset:    0 Size:    16
//   float4 g_resolveRectUV;            // Offset:   16 Size:    16
//   float g_ps_nearFar;                // Offset:   64 Size:     4
//   float g_ps_nearFarDistance;        // Offset:   68 Size:     4
//   float g_ps_far;                    // Offset:   72 Size:     4
//   float g_ps_near;                   // Offset:   76 Size:     4 [unused]
//   float g_waveTime;                  // Offset:   80 Size:     4
//   float g_clampDistanceInverse;      // Offset:   84 Size:     4
//   float g_waveStrength;              // Offset:   88 Size:     4
//   float g_waveNum;                   // Offset:   92 Size:     4 [unused]
//   float g_vNormalMapScrollDistance;  // Offset:   96 Size:     4
//   float g_hNormalMapScrollDistance;  // Offset:  100 Size:     4
//   float g_fToneMapReceiprocalExposure;// Offset:  104 Size:     4 [unused]
//   float2 g_screenCenter;             // Offset:  112 Size:     8 [unused]
//   float g_radialDistance;            // Offset:  120 Size:     4 [unused]
//   float g_TransrancyPower;           // Offset:  124 Size:     4 [unused]
//   float4 g_ps_aboveShadowCascadeSwitchDist;// Offset:  128 Size:    16 [unused]
//   float4 g_vColorScale;              // Offset:  144 Size:    16
//   float g_specularShininessFactor;   // Offset:  176 Size:     4 [unused]
//   uint g_ps_envCbIndex;              // Offset:  180 Size:     4 [unused]
//   float g_specularScale;             // Offset:  184 Size:     4 [unused]
//   int g_flipbookBlendMode;           // Offset:  188 Size:     4 [unused]
//   float4 g_vLightMask;               // Offset:  208 Size:    16 [unused]
//   float4 g_vTracerParam;             // Offset:  224 Size:    16 [unused]
//   float g_Decay;                     // Offset:  240 Size:     4 [unused]
//   float g_DecayWeight;               // Offset:  244 Size:     4 [unused]
//   float g_Dencity;                   // Offset:  248 Size:     4 [unused]
//   float g_Exposure;                  // Offset:  252 Size:     4 [unused]
//   float g_LightSourceScaleX;         // Offset:  256 Size:     4 [unused]
//   float g_LightSourceScaleY;         // Offset:  260 Size:     4 [unused]
//   int g_SampleNum;                   // Offset:  264 Size:     4 [unused]
//   float g_LightSourceScale;          // Offset:  268 Size:     4 [unused]
//   float4 g_LightShaftScreenCenter;   // Offset:  272 Size:    16 [unused]
//   float4x4 g_psViewMatrix;           // Offset:  288 Size:    64 [unused]
//   float4 g_psGlowScale;              // Offset:  352 Size:    16 [unused]
//   int g_ps_TexBlendType;             // Offset:  368 Size:     4 [unused]
//   int g_ps_TexBlendType2;            // Offset:  372 Size:     4 [unused]
//   int g_ps_TexBlendType3;            // Offset:  376 Size:     4 [unused]
//   int g_ps_ColorBlendType;           // Offset:  380 Size:     4
//   float4 g_ps_TextureColor1;         // Offset:  384 Size:    16 [unused]
//   float4 g_ps_TextureColor2;         // Offset:  400 Size:    16 [unused]
//   float4 g_ps_TextureColor3;         // Offset:  416 Size:    16 [unused]
//   float g_ps_invPreExposure;         // Offset:  436 Size:     4
//   int g_ps_BlendingMode;             // Offset:  440 Size:     4
//   int g_ps_FogMultMode;              // Offset:  444 Size:     4 [unused]
//   float4 g_ps_TextureOnlyColor;      // Offset:  448 Size:    16 [unused]
//   float4 g_ps_softSpriteParam;       // Offset:  464 Size:    16
//   float g_ps_RadialBlurSamplingLengthMaxX;// Offset:  480 Size:     4 [unused]
//   float g_ps_RadialBlurSamplingLengthMaxY;// Offset:  484 Size:     4 [unused]
//   float2 g_ps_softSpriteScaleOffset; // Offset:  488 Size:     8 [unused]
//   float4 g_ps_LightShaftDir;         // Offset:  496 Size:    16 [unused]
//   float4 g_ps_LightShaftDustScaleOffset;// Offset:  512 Size:    16 [unused]
//   float4 g_ps_LightShaftDustThreshold;// Offset:  528 Size:    16 [unused]
//   int g_ps_bPreAlphaMult;            // Offset:  544 Size:     4 [unused]
//   int g_ps_bEnableLighting;          // Offset:  548 Size:     4 [unused]
//   int g_ps_bEnableFog;               // Offset:  552 Size:     4 [unused]
//   float g_ps_preExposure;            // Offset:  556 Size:     4
//   float g_ps_BillboardShadowIntensity;// Offset:  560 Size:     4 [unused]
//   float4 g_ps_ShadowcVolumeParam0;   // Offset:  576 Size:    16 [unused]
//   float4 g_ps_ShadowcVolumeParam1;   // Offset:  592 Size:    16 [unused]
//   float4x4 g_ps_invProjMatrix;       // Offset:  608 Size:    64 [unused]
//   float4x4 g_ps_shadowMatrixNarrrow; // Offset:  672 Size:    64 [unused]
//   float4 g_ps_envCbColScale;         // Offset:  752 Size:    16 [unused]
//   float4 g_ps_VolumeFogParam[4];     // Offset:  768 Size:    64 [unused]
//   float4x4 g_ps_projectionMatrix;    // Offset:  832 Size:    64 [unused]
//   float4x4 g_ps_shadowMatrixBroad;   // Offset:  896 Size:    64 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_ClampPointSampler               sampler      NA          NA    7        1
// g_WrapLinearSampler               sampler      NA          NA    8        1
// g_ClampLinearSampler              sampler      NA          NA    9        1
// g_frameBufferTexture              texture  float4          2d    0        1
// g_normalTexture                   texture  float4          2d    1        1
// g_depthTexture                    texture  float4          2d    3        1
// PSCommonBuffer                    cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 1   xyz         1     NONE   float   x
// TEXCOORD                 5      w        1     NONE   float
// TEXCOORD                 2   xyz         2     NONE   float
// TEXCOORD                 3   xyzw        3     NONE   float     zw
// TEXCOORD                 4   xyzw        4     NONE   float   xy w
// SV_POSITION              0   xyzw        5      POS   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[35], immediateIndexed
dcl_sampler s7, mode_default
dcl_sampler s8, mode_default
dcl_sampler s9, 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) t3
dcl_input_ps linear v0.xyzw
dcl_input_ps linear v1.x
dcl_input_ps linear v3.zw
dcl_input_ps linear v4.xyw
dcl_output o0.xyzw
dcl_temps 6
div r0.xy, v4.xyxx, v4.wwww
mad r0.xy, r0.xyxx, l(0.500000, -0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
add r0.zw, v0.xxxy, l(0.000000, 0.000000, -0.500000, -0.500000)
add r0.zw, |r0.zzzw|, |r0.zzzw|
dp2 r0.z, r0.zwzz, r0.zwzz
sqrt r0.z, r0.z
mul r1.x, cb0[5].x, cb0[6].x
mul r1.y, cb0[5].x, -cb0[6].y
add r1.xy, r1.xyxx, v0.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xy, r1.xyxx, t1.xyzw, s8
mad r1.xy, r1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r0.z, -cb0[5].y, r0.z, l(1.000000)
max r0.z, r0.z, l(0.000000)
mul r0.z, r0.z, l(0.010000)
mul r1.xy, r1.xyxx, cb0[5].zzzz
div r1.zw, v0.zzzw, v1.xxxx
add r1.zw, r1.zzzw, l(0.000000, 0.000000, 1.000000, 1.000000)
mul r1.zw, r1.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000)
mad r0.zw, r1.xxxy, r0.zzzz, r1.zzzw
max r0.zw, r0.zzzw, cb0[1].xxxy
min r0.zw, r0.zzzw, cb0[1].zzzw
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r0.zwzz, t0.xyzw, s9
mul r2.xyz, r2.xyzx, cb0[27].yyyy
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.zwzz, t0.xyzw, s9
mul r1.xyz, r1.xyzx, cb0[27].yyyy
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t3.yzxw, s7
add r0.z, -r0.z, l(1.000000)
mad r0.z, r0.z, cb0[4].y, -cb0[4].z
div r0.z, -cb0[4].x, r0.z
ge r0.z, v3.z, r0.z
movc r1.xyz, r0.zzzz, r1.xyzx, r2.xyzx
mov r1.w, l(1.000000)
ieq r0.z, l(2), cb0[23].w
lt r2.xyz, r1.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000)
add r3.xyz, r1.xyzx, r1.xyzx
mul r3.xyz, r3.xyzx, cb0[0].xyzx
add r4.xyz, -r1.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
add r4.xyz, r4.xyzx, r4.xyzx
add r5.xyz, l(1.000000, 1.000000, 1.000000, 0.000000), -cb0[0].xyzx
mad r4.xyz, -r4.xyzx, r5.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
movc r2.xyz, r2.xyzx, r3.xyzx, r4.xyzx
mov r2.w, cb0[0].w
mul r2.xyzw, r2.xyzw, cb0[9].xyzw
mul r1.xyzw, r1.xyzw, cb0[0].xyzw
mul r1.xyzw, r1.xyzw, cb0[9].xyzw
movc r1.xyzw, r0.zzzz, r2.xyzw, r1.xyzw
lt r0.z, v3.w, l(0.000100)
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t3.xyzw, s7
add r0.x, -r0.x, l(1.000000)
mad r0.x, r0.x, cb0[4].y, -cb0[4].z
div r0.x, -cb0[4].x, r0.x
add r0.x, r0.x, -v3.z
min r0.x, r0.x, v3.w
div_sat r0.x, r0.x, v3.w
movc r0.x, r0.z, l(1.000000), r0.x
mul r0.x, r0.x, r1.w
max r0.yzw, r1.xxyz, l(0.000000, 0.000000, 0.000000, 0.000000)
ge r1.x, cb0[29].y, r0.x
movc r0.x, r1.x, l(0), r0.x
ine r1.x, l(4), cb0[27].z
mul r1.yzw, r0.yyzw, cb0[34].wwww
movc r0.yzw, r1.xxxx, r1.yyzw, r0.yyzw
lt r1.x, l(1.000000), r0.x
if_nz r1.x
  ieq r1.xy, l(1, 2, 0, 0), cb0[27].zzzz
  or r1.x, r1.y, r1.x
  mul r1.yzw, r0.xxxx, r0.yyzw
  movc o0.xyz, r1.xxxx, r1.yzwy, r0.yzwy
  mov_sat o0.w, r0.x
else
  max o0.w, r0.x, l(0.000000)
  mov o0.xyz, r0.yzwy
endif
ret
// Approximately 74 instruction slots used

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