//Bloom.
// ---- Created with 3Dmigoto v1.3.11 on Tue Aug 14 22:02:02 2018

cbuffer _Globals : register(b0)
{
  float4 uDiffuseColor : packoffset(c0);
  float4 uEnvironmentColor : packoffset(c1);
  float4 uLightAmbience : packoffset(c2);
  float uFogNear : packoffset(c3);
  float uFogFar : packoffset(c3.y);
  float3 uFogColor : packoffset(c4);
  int uFullBright : packoffset(c4.w);
  float uBlurRadius : packoffset(c5);
  float uSize : packoffset(c5.y);
  int uDirection : packoffset(c5.z);
  int uBlurType : packoffset(c5.w);
}

SamplerState uTexSample0_s : register(s0);
Texture2D<float4> uTex0 : register(t0);


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


void main(
  float4 v0 : SV_POSITION0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_TARGET0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 iniparams1 = IniParams.Load(int2(1,0));
  
  r0.xyzw = uTex0.SampleLevel(uTexSample0_s, v1.xy, 0).xyzw;
  r1.x = uBlurRadius / uSize;
  r2.xyzw = float4(-4,-3,-2,3) * r1.xxxx;
  r1.yz = uDirection ? float2(1,0) : float2(0,1);
  r3.xyzw = saturate(r2.xxyy * r1.yzyz + v1.xyxy);
  r2.xyzw = saturate(r2.zzww * r1.yzyz + v1.xyxy);
  r4.xyzw = uTex0.SampleLevel(uTexSample0_s, r3.zw, 0).xyzw;
  r3.xyzw = uTex0.SampleLevel(uTexSample0_s, r3.xy, 0).xyzw;
  r4.xyzw = float4(0.0540540554,0.0540540554,0.0540540554,0.0540540554) * r4.xyzw;
  r3.xyzw = r3.xyzw * float4(0.0162162166,0.0162162166,0.0162162166,0.0162162166) + r4.xyzw;
  r4.xyzw = uTex0.SampleLevel(uTexSample0_s, r2.xy, 0).xyzw;
  r2.xyzw = uTex0.SampleLevel(uTexSample0_s, r2.zw, 0).xyzw;
  r3.xyzw = r4.xyzw * float4(0.121621624,0.121621624,0.121621624,0.121621624) + r3.xyzw;
  r4.xy = saturate(-r1.xx * r1.yz + v1.xy);
  r4.xyzw = uTex0.SampleLevel(uTexSample0_s, r4.xy, 0).xyzw;
  r3.xyzw = r4.xyzw * float4(0.194594592,0.194594592,0.194594592,0.194594592) + r3.xyzw;
  r0.xyzw = r0.xyzw * float4(0.227027029,0.227027029,0.227027029,0.227027029) + r3.xyzw;
  r3.xy = saturate(r1.xx * r1.yz + v1.xy);
  r3.xyzw = uTex0.SampleLevel(uTexSample0_s, r3.xy, 0).xyzw;
  r0.xyzw = r3.xyzw * float4(0.194594592,0.194594592,0.194594592,0.194594592) + r0.xyzw;
  r1.w = r1.x + r1.x;
  r1.x = 4 * r1.x;
  r3.xy = saturate(r1.xx * r1.yz + v1.xy);
  r1.xy = saturate(r1.ww * r1.yz + v1.xy);
  r1.xyzw = uTex0.SampleLevel(uTexSample0_s, r1.xy, 0).xyzw;
  r0.xyzw = r1.xyzw * float4(0.121621624,0.121621624,0.121621624,0.121621624) + r0.xyzw;
  r0.xyzw = r2.xyzw * float4(0.0540540554,0.0540540554,0.0540540554,0.0540540554) + r0.xyzw;
  r1.xyzw = uTex0.SampleLevel(uTexSample0_s, r3.xy, 0).xyzw;
  o0.xyzw = r1.xyzw * float4(0.0162162166,0.0162162166,0.0162162166,0.0162162166) * iniparams1.y + r0.xyzw * iniparams1.y;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.18773
//
//   using 3Dmigoto v1.3.11 on Tue Aug 14 22:02:02 2018
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 uDiffuseColor;              // Offset:    0 Size:    16 [unused]
//   float4 uEnvironmentColor;          // Offset:   16 Size:    16 [unused]
//   float4 uLightAmbience;             // Offset:   32 Size:    16 [unused]
//   float uFogNear;                    // Offset:   48 Size:     4 [unused]
//   float uFogFar;                     // Offset:   52 Size:     4 [unused]
//   float3 uFogColor;                  // Offset:   64 Size:    12 [unused]
//   int uFullBright;                   // Offset:   76 Size:     4 [unused]
//   float uBlurRadius;                 // Offset:   80 Size:     4
//   float uSize;                       // Offset:   84 Size:     4
//   int uDirection;                    // Offset:   88 Size:     4
//   int uBlurType;                     // Offset:   92 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// uTexSample0                       sampler      NA          NA    0        1
// uTex0                             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
// TEXCOORD                 0   xy          1     NONE   float   xy
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[6], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 5
sample_l r0.xyzw, v1.xyxx, t0.xyzw, s0, l(0.000000)
div r1.x, cb0[5].x, cb0[5].y
mul r2.xyzw, r1.xxxx, l(-4.000000, -3.000000, -2.000000, 3.000000)
movc r1.yz, cb0[5].zzzz, l(0,1.000000,0,0), l(0,0,1.000000,0)
mad_sat r3.xyzw, r2.xxyy, r1.yzyz, v1.xyxy
mad_sat r2.xyzw, r2.zzww, r1.yzyz, v1.xyxy
sample_l r4.xyzw, r3.zwzz, t0.xyzw, s0, l(0.000000)
sample_l r3.xyzw, r3.xyxx, t0.xyzw, s0, l(0.000000)
mul r4.xyzw, r4.xyzw, l(0.0540540554, 0.0540540554, 0.0540540554, 0.0540540554)
mad r3.xyzw, r3.xyzw, l(0.0162162166, 0.0162162166, 0.0162162166, 0.0162162166), r4.xyzw
sample_l r4.xyzw, r2.xyxx, t0.xyzw, s0, l(0.000000)
sample_l r2.xyzw, r2.zwzz, t0.xyzw, s0, l(0.000000)
mad r3.xyzw, r4.xyzw, l(0.121621624, 0.121621624, 0.121621624, 0.121621624), r3.xyzw
mad_sat r4.xy, -r1.xxxx, r1.yzyy, v1.xyxx
sample_l r4.xyzw, r4.xyxx, t0.xyzw, s0, l(0.000000)
mad r3.xyzw, r4.xyzw, l(0.194594592, 0.194594592, 0.194594592, 0.194594592), r3.xyzw
mad r0.xyzw, r0.xyzw, l(0.227027029, 0.227027029, 0.227027029, 0.227027029), r3.xyzw
mad_sat r3.xy, r1.xxxx, r1.yzyy, v1.xyxx
sample_l r3.xyzw, r3.xyxx, t0.xyzw, s0, l(0.000000)
mad r0.xyzw, r3.xyzw, l(0.194594592, 0.194594592, 0.194594592, 0.194594592), r0.xyzw
add r1.w, r1.x, r1.x
mul r1.x, r1.x, l(4.000000)
mad_sat r3.xy, r1.xxxx, r1.yzyy, v1.xyxx
mad_sat r1.xy, r1.wwww, r1.yzyy, v1.xyxx
sample_l r1.xyzw, r1.xyxx, t0.xyzw, s0, l(0.000000)
mad r0.xyzw, r1.xyzw, l(0.121621624, 0.121621624, 0.121621624, 0.121621624), r0.xyzw
mad r0.xyzw, r2.xyzw, l(0.0540540554, 0.0540540554, 0.0540540554, 0.0540540554), r0.xyzw
sample_l r1.xyzw, r3.xyxx, t0.xyzw, s0, l(0.000000)
mad o0.xyzw, r1.xyzw, l(0.0162162166, 0.0162162166, 0.0162162166, 0.0162162166), r0.xyzw
ret
// Approximately 30 instruction slots used

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