//Distortion PS.
// ---- Created with 3Dmigoto v1.3.16 on Sat Mar 06 22:42:21 2021

cbuffer RadialBlurCB : register(b3)
{
  float4 g_cbScreenSize : packoffset(c0);
  float4 g_cbRadialBlurCenter : packoffset(c1);
  uint g_cbRadialBlurSampCount : packoffset(c2);
  float g_cbRadialBlurAlpha : packoffset(c2.y);
}

SamplerState sampleLinear_s : register(s7);
Texture2D<float3> g_InRadialBlurSrc : register(t0);


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


void main(
  float4 v0 : SV_Position0,
  float4 v1 : COLOR0,
  float2 v2 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xy = g_cbRadialBlurCenter.xy + -v2.xy;
  
  r0.x+=stereo.x*0.5;
  
  r0.xy = g_cbRadialBlurCenter.ww * r0.xy;
  r0.xy = r0.xy / g_cbScreenSize.yy;
  r0.z = g_cbRadialBlurSampCount;
  r0.xy = r0.xy / r0.zz;
  r0.z = g_cbRadialBlurSampCount + -1;
  r1.xyz = float3(0,0,0);
  r0.w = 1;
  r1.w = r0.z;
  while (true) {
    r2.x = cmp((int)r1.w < 0);
    if (r2.x != 0) break;
    r2.x = (int)r1.w;
    r2.xy = r0.xy * r2.xx + v2.xy;
    r2.xyz = g_InRadialBlurSrc.SampleLevel(sampleLinear_s, r2.xy, 0).xyz;
    r2.xyz = g_cbRadialBlurCenter.zzz * r2.xyz;
    r1.xyz = r2.xyz * r0.www + r1.xyz;
    r0.w = 1 + r0.w;
    r1.w = (int)r1.w + -1;
  }
  o0.xyz = r1.xyz;
  o0.w = g_cbRadialBlurAlpha;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.3.16 on Sat Mar 06 22:42:21 2021
//
//
// Buffer Definitions:
//
// cbuffer RadialBlurCB
// {
//
//   float4 g_cbScreenSize;             // Offset:    0 Size:    16
//   float4 g_cbRadialBlurCenter;       // Offset:   16 Size:    16
//   uint g_cbRadialBlurSampCount;      // Offset:   32 Size:     4
//   float g_cbRadialBlurAlpha;         // Offset:   36 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// sampleLinear                      sampler      NA          NA    7        1
// g_InRadialBlurSrc                 texture  float3          2d    0        1
// RadialBlurCB                      cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// COLOR                    0   xyzw        1     NONE   float
// TEXCOORD                 0   xy          2     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 cb3[3], immediateIndexed
dcl_sampler s7, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 3
add r0.xy, -v2.xyxx, cb3[1].xyxx
mul r0.xy, r0.xyxx, cb3[1].wwww
div r0.xy, r0.xyxx, cb3[0].yyyy
utof r0.z, cb3[2].x
div r0.xy, r0.xyxx, r0.zzzz
iadd r0.z, cb3[2].x, l(-1)
mov r1.xyz, l(0,0,0,0)
mov r0.w, l(1.000000)
mov r1.w, r0.z
loop
  ilt r2.x, r1.w, l(0)
  breakc_nz r2.x
  itof r2.x, r1.w
  mad r2.xy, r0.xyxx, r2.xxxx, v2.xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t0.xyzw, s7, l(0.000000)
  mul r2.xyz, r2.xyzx, cb3[1].zzzz
  mad r1.xyz, r2.xyzx, r0.wwww, r1.xyzx
  add r0.w, r0.w, l(1.000000)
  iadd r1.w, r1.w, l(-1)
endloop
mov o0.xyz, r1.xyzx
mov o0.w, cb3[2].y
ret
// Approximately 23 instruction slots used

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