// ---- Created with 3Dmigoto v1.3.16 on Sun Mar 06 17:43:20 2022

cbuffer _Globals : register(b0)
{
  float4 vEye : packoffset(c35);
  float vATest : packoffset(c0);
  float2 vSatFade : packoffset(c1) = {0,1};
  bool bSatFade : packoffset(c2) = true;
  float4 vDDot : packoffset(c34);
}

SamplerState __smpsStage0_s : register(s0);
SamplerState __smpsDepth_s : register(s3);
SamplerState __smpsRTT_s : register(s4);
Texture2D<float4> sStage0 : register(t0);
Texture2D<float4> sDepth : register(t3);
Texture2D<float4> sRTT : 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,
  float4 v4 : TEXCOORD3,
  float3 v5 : TEXCOORD4,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = sStage0.Sample(__smpsStage0_s, v5.xy).xyw;
  r0.w = -vATest + r0.z;
  r0.w = cmp(r0.w < 0);
  if (r0.w != 0) discard;
  r1.xy = v2.xy / v2.zz;
  r0.w = sDepth.Sample(__smpsDepth_s, r1.xy).x;
  r0.w = r0.w * vDDot.x + vDDot.w;
  r0.w = 1 / r0.w;
  r0.w = -v2.z + r0.w;
  r1.xyz = vEye.xyz + -v1.xyz;
  r1.x = dot(r1.xyz, r1.xyz);
  r1.x = rsqrt(r1.x);
  r1.x = v3.w * r1.x;
  r1.x = max(0.25, r1.x);
  r0.w = r1.x * r0.w;
  r0.w = saturate(v2.w * r0.w);
  r0.w = r0.w / r1.x;
  r0.z = saturate(-r0.z * v5.z + 1);
  r1.xyzw = float4(-0.5,-0.5,-0.5,-0.5) + r0.xxyy;
  r0.x = max(0.00100000005, r0.z);
  r0.x = log2(r0.x);
  r0.x = r0.x * r0.w;
  r0.x = exp2(r0.x);
  o0.w = 1 + -r0.x;
  r0.xy = v3.xy / v3.zz;
  r0.xy = -r1.xy * v4.zw + r0.xy;
  r0.xy = r1.zw * v4.xy + r0.xy;
  r0.xyz = sRTT.Sample(__smpsRTT_s, r0.xy).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:43:20 2022
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 vEye;                       // Offset:  560 Size:    16
//   float vATest;                      // Offset:    0 Size:     4
//   float2 vSatFade;                   // Offset:   16 Size:     8
//      = 0x00000000 0x3f800000
//   bool bSatFade;                     // Offset:   32 Size:     4
//      = 0xffffffff
//   float4 vDDot;                      // Offset:  544 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsStage0                      sampler      NA          NA    0        1
// __smpsDepth                       sampler      NA          NA    3        1
// __smpsRTT                         sampler      NA          NA    4        1
// sStage0                           texture  float4          2d    0        1
// sDepth                            texture  float4          2d    3        1
// sRTT                              texture  float4          2d    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   xyz
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyz         5     NONE   float   xyz
//
//
// 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[36], 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_texture2d (float,float,float,float) t4
dcl_input_ps linear v1.xyz
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyz
dcl_output o0.xyzw
dcl_temps 2
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v5.xyxx, t0.xywz, s0
add r0.w, r0.z, -cb0[0].x
lt r0.w, r0.w, l(0.000000)
discard_nz r0.w
div r1.xy, v2.xyxx, v2.zzzz
sample_indexable(texture2d)(float,float,float,float) r0.w, r1.xyxx, t3.yzwx, s3
mad r0.w, r0.w, cb0[34].x, cb0[34].w
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
add r0.w, r0.w, -v2.z
add r1.xyz, -v1.xyzx, cb0[35].xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
rsq r1.x, r1.x
mul r1.x, r1.x, v3.w
max r1.x, r1.x, l(0.250000)
mul r0.w, r0.w, r1.x
mul_sat r0.w, r0.w, v2.w
div r0.w, r0.w, r1.x
mad_sat r0.z, -r0.z, v5.z, l(1.000000)
add r1.xyzw, r0.xxyy, l(-0.500000, -0.500000, -0.500000, -0.500000)
max r0.x, r0.z, l(0.001000)
log r0.x, r0.x
mul r0.x, r0.w, r0.x
exp r0.x, r0.x
add o0.w, -r0.x, l(1.000000)
div r0.xy, v3.xyxx, v3.zzzz
mad r0.xy, -r1.xyxx, v4.zwzz, r0.xyxx
mad r0.xy, r1.zwzz, v4.xyxx, r0.xyxx
sample_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t4.xyzw, s4
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 34 instruction slots used

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