//DMC3 bloom PS.
// ---- Created with 3Dmigoto v1.3.7 on Sun Mar 25 14:44:18 2018

cbuffer PS_CONSTANT_BUFFER : register(b0)
{
  int alpha_test : packoffset(c0);
  int alpha_test_func : packoffset(c0.y);
  float alpha_ref : packoffset(c0.z);
}

SamplerState sampler_textur_s : register(s0);
Texture2D<float4> textur : 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;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 iniparams = IniParams.Load(0);
  float4 iniparams7 = IniParams.Load(int2(7,0));
  float4 iniparams2 = IniParams.Load(int2(2,0));
  if (iniparams2.x==0 && v0.z<0.0001 && v0.z>-0.0001)
  {
	discard;
  }
  r0.xyzw = textur.Sample(sampler_textur_s, v1.xy).wxyz;
  r1.x = cmp(0 != alpha_test);
  if (r1.x != 0) {
    r1.x = alpha_test_func;
    r0.x = r0.x;
    r1.y = alpha_ref;
    r1.z = cmp((int)r1.x == 1);
    if (r1.z != 0) {
      r1.z = -1;
    } else {
      r1.w = cmp((int)r1.x == 2);
      if (r1.w != 0) {
        r1.w = cmp(r0.x < r1.y);
        if (r1.w != 0) {
          r1.z = 1;
        } else {
          r1.z = -1;
        }
      } else {
        r1.w = cmp((int)r1.x == 3);
        if (r1.w != 0) {
          r1.w = cmp(r0.x == r1.y);
          if (r1.w != 0) {
            r1.z = 1;
          } else {
            r1.z = -1;
          }
        } else {
          r1.w = cmp((int)r1.x == 4);
          if (r1.w != 0) {
            r1.w = cmp(r1.y >= r0.x);
            if (r1.w != 0) {
              r1.z = 1;
            } else {
              r1.z = -1;
            }
          } else {
            r1.w = cmp((int)r1.x == 5);
            if (r1.w != 0) {
              r1.w = cmp(r1.y < r0.x);
              if (r1.w != 0) {
                r1.z = 1;
              } else {
                r1.z = -1;
              }
            } else {
              r1.w = cmp((int)r1.x == 6);
              if (r1.w != 0) {
                r1.w = cmp(r0.x != r1.y);
                if (r1.w != 0) {
                  r1.z = 1;
                } else {
                  r1.z = -1;
                }
              } else {
                r1.x = cmp((int)r1.x == 7);
                if (r1.x != 0) {
                  r1.x = cmp(r0.x >= r1.y);
                  if (r1.x != 0) {
                    r1.z = 1;
                  } else {
                    r1.z = -1;
                  }
                } else {
                  r1.z = 1;
                }
              }
            }
          }
        }
      }
    }
    r1.z = r1.z;
    r1.x = (int)r1.z;
    r1.x = cmp(r1.x < 0);
    //r1.x = r1.x ? -1.#QNAN0 : 0;
    if (r1.x != 0) discard;
  }
  //General bloom. Disabled.
  //if (iniparams.w!=1 && iniparams7.w==20)
  //{
	//r0.yzw=pow(r0.yzw, iniparams.w*1.5*(1-r0.yzw));
  //}
  o0.xyzw = r0.yzwx;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.7 on Sun Mar 25 14:44:18 2018
//
//
// Buffer Definitions:
//
// cbuffer PS_CONSTANT_BUFFER
// {
//
//   int alpha_test;                    // Offset:    0 Size:     4
//   int alpha_test_func;               // Offset:    4 Size:     4
//   float alpha_ref;                   // Offset:    8 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// sampler_textur                    sampler      NA          NA    0        1
// textur                            texture  float4          2d    0        1
// PS_CONSTANT_BUFFER                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_5_0
dcl_globalFlags refactoringAllowed | skipOptimization
dcl_constantbuffer cb0[1], 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 2
//
// Initial variable locations:
//   v0.x <- pi.pos.x; v0.y <- pi.pos.y; v0.z <- pi.pos.z; v0.w <- pi.pos.w;
//   v1.x <- pi.texcoord.x; v1.y <- pi.texcoord.y;
//   o0.x <- <main return value>.x; o0.y <- <main return value>.y; o0.z <- <main return value>.z; o0.w <- <main return value>.w
//
#line 21 "C:\dev\dmc\dmc3\code\dmc3\source\dmc3nb\shaders\hlsl\ps\TEX_DECAL.hlsl"
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, v1.xyxx, t0.wxyz, s0  // r0.y <- color.x; r0.z <- color.y; r0.w <- color.z; r0.x <- color.w
ine r1.x, l(0, 0, 0, 0), cb0[0].x
if_nz r1.x
  nop
  mov r1.x, cb0[0].y
  mov r0.x, r0.x
  mov r1.y, cb0[0].z

#line 37 "C:\dev\dmc\dmc3\code\dmc3\source\dmc3nb\shaders\hlsl\Shared.fxh"
  ieq r1.z, r1.x, l(1)
  if_nz r1.z
    mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
  else
    ieq r1.w, r1.x, l(2)
    if_nz r1.w
      lt r1.w, r0.x, r1.y
      if_nz r1.w
        mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
      else

#line 50
        mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
      endif
    else
      ieq r1.w, r1.x, l(3)
      if_nz r1.w
        eq r1.w, r0.x, r1.y
        if_nz r1.w
          mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
        else

#line 62
          mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
        endif
      else
        ieq r1.w, r1.x, l(4)
        if_nz r1.w
          ge r1.w, r1.y, r0.x
          if_nz r1.w
            mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
          else

#line 74
            mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
          endif
        else
          ieq r1.w, r1.x, l(5)
          if_nz r1.w
            lt r1.w, r1.y, r0.x
            if_nz r1.w
              mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
            else

#line 86
              mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
            endif
          else
            ieq r1.w, r1.x, l(6)
            if_nz r1.w
              ne r1.w, r0.x, r1.y
              if_nz r1.w
                mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
              else

#line 98
                mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
              endif
            else
              ieq r1.x, r1.x, l(7)
              if_nz r1.x
                ge r1.x, r0.x, r1.y
                if_nz r1.x
                  mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
                else

#line 110
                  mov r1.z, l(-1)  // r1.z <- <AlphaTestFunc return value>
                endif
              else

#line 115
                mov r1.z, l(1)  // r1.z <- <AlphaTestFunc return value>
              endif
            endif
          endif
        endif
      endif
    endif
  endif

#line 25 "C:\dev\dmc\dmc3\code\dmc3\source\dmc3nb\shaders\hlsl\ps\TEX_DECAL.hlsl"
  mov r1.z, r1.z  // r1.z <- clipVal
  itof r1.x, r1.z
  lt r1.x, r1.x, l(0.000000)
  and r1.x, r1.x, l(-1)
  discard_nz r1.x
endif
mov o0.xyzw, r0.yzwx
ret
// Approximately 81 instruction slots used

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