// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:31:05 2016

cbuffer Constants : register(b0)
{
  float4 fsize : packoffset(c0);
  float4 offset : packoffset(c1);
  float4 srctexscale : packoffset(c2);
  float4 texscale : packoffset(c3);
}

SamplerState sampler_gradtex_s : register(s0);
SamplerState sampler_srctex_s : register(s1);
SamplerState sampler_tex_s : register(s2);
Texture2D<float4> gradtex : register(t0);
Texture2D<float4> srctex : register(t1);
Texture2D<float4> tex : register(t2);


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


void main( 
  float4 v0 : TEXCOORD0,
  float4 v1 : TEXCOORD1,
  float2 v2 : TEXCOORD2,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = float2(0,0);
  r0.z = -fsize.x;
  while (true) {
    r0.w = cmp(fsize.x < r0.z);
    if (r0.w != 0) break;
    r1.x = offset.x + r0.z;
    r2.xy = r0.xy;
    r2.z = -fsize.y;
    while (true) {
      r0.w = cmp(fsize.y < r2.z);
      if (r0.w != 0) break;
      r1.y = offset.y + r2.z;
      r1.zw = r1.xy * texscale.xy + v2.xy;
      r0.w = tex.Sample(sampler_tex_s, r1.zw).w;
      r2.y = r2.y + r0.w;
      r1.yz = -r1.xy * texscale.xy + v2.xy;
      r0.w = tex.Sample(sampler_tex_s, r1.yz).w;
      r2.x = r2.x + r0.w;
      r2.z = 1 + r2.z;
    }
    r0.xy = r2.xy;
    r0.z = 1 + r0.z;
  }
  r0.xy = -r0.xy * fsize.ww + float2(1,1);
  r0.xy = r0.xy + -r0.yx;
  r0.y = fsize.z * r0.y;
  r0.x = -r0.x * fsize.z + 1;
  r0.x = 0.5 * r0.x;
  r0.x = max(0, r0.x);
  r1.x = min(0.5, r0.x);
  r1.yw = float2(0,0);
  r2.xyzw = gradtex.Sample(sampler_gradtex_s, r1.xy).xyzw;
  r0.x = r0.y * 0.5 + 0.5;
  r0.x = max(0.5, r0.x);
  r1.z = min(1, r0.x);
  r0.xyzw = gradtex.Sample(sampler_gradtex_s, r1.zw).xyzw;
  r1.xy = srctexscale.xy * v2.xy;
  r1.xyzw = srctex.Sample(sampler_srctex_s, r1.xy).xyzw;
  r3.x = saturate(r2.w);
  r3.y = saturate(r0.w);
  r2.w = 1;
  r0.w = 1;
  r0.xyzw = r0.xyzw * r3.yyyy;
  r0.xyzw = r2.xyzw * r3.xxxx + r0.xyzw;
  r2.x = 1 + -r1.w;
  r0.xyzw = r0.xyzw * r2.xxxx + r1.xyzw;
  r1.xyz = v1.xyz;
  r1.w = 1;
  r0.xyzw = r1.xyzw * r0.xyzw;
  r0.xyzw = v1.wwww * r0.xyzw;
  o0.xyzw = saturate(v0.xyzw * r0.wwww + r0.xyzw);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer Constants
// {
//
//   float4 fsize;                      // Offset:    0 Size:    16
//   float4 offset;                     // Offset:   16 Size:    16
//   float4 srctexscale;                // Offset:   32 Size:    16
//   float4 texscale;                   // Offset:   48 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// sampler_gradtex                   sampler      NA          NA    0        1
// sampler_srctex                    sampler      NA          NA    1        1
// sampler_tex                       sampler      NA          NA    2        1
// gradtex                           texture  float4          2d    0        1
// srctex                            texture  float4          2d    1        1
// tex                               texture  float4          2d    2        1
// Constants                         cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 1   xyzw        1     NONE   float   xyzw
// TEXCOORD                 2   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 cb0[4], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, 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) t2
dcl_input_ps linear v0.xyzw
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 4
mov r0.xy, l(0,0,0,0)
mov r0.z, -cb0[0].x
loop 
  lt r0.w, cb0[0].x, r0.z
  breakc_nz r0.w
  add r1.x, r0.z, cb0[1].x
  mov r2.xy, r0.xyxx
  mov r2.z, -cb0[0].y
  loop 
    lt r0.w, cb0[0].y, r2.z
    breakc_nz r0.w
    add r1.y, r2.z, cb0[1].y
    mad r1.zw, r1.xxxy, cb0[3].xxxy, v2.xxxy
    sample_indexable(texture2d)(float,float,float,float) r0.w, r1.zwzz, t2.xyzw, s2
    add r2.y, r0.w, r2.y
    mad r1.yz, -r1.xxyx, cb0[3].xxyx, v2.xxyx
    sample_indexable(texture2d)(float,float,float,float) r0.w, r1.yzyy, t2.xyzw, s2
    add r2.x, r0.w, r2.x
    add r2.z, r2.z, l(1.000000)
  endloop 
  mov r0.xy, r2.xyxx
  add r0.z, r0.z, l(1.000000)
endloop 
mad r0.xy, -r0.xyxx, cb0[0].wwww, l(1.000000, 1.000000, 0.000000, 0.000000)
add r0.xy, -r0.yxyy, r0.xyxx
mul r0.y, r0.y, cb0[0].z
mad r0.x, -r0.x, cb0[0].z, l(1.000000)
mul r0.x, r0.x, l(0.500000)
max r0.x, r0.x, l(0.000000)
min r1.x, r0.x, l(0.500000)
mov r1.yw, l(0,0,0,0)
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xyxx, t0.xyzw, s0
mad r0.x, r0.y, l(0.500000), l(0.500000)
max r0.x, r0.x, l(0.500000)
min r1.z, r0.x, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r1.zwzz, t0.xyzw, s0
mul r1.xy, v2.xyxx, cb0[2].xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t1.xyzw, s1
mov_sat r3.x, r2.w
mov_sat r3.y, r0.w
mov r2.w, l(1.000000)
mov r0.w, l(1.000000)
mul r0.xyzw, r3.yyyy, r0.xyzw
mad r0.xyzw, r2.xyzw, r3.xxxx, r0.xyzw
add r2.x, -r1.w, l(1.000000)
mad r0.xyzw, r0.xyzw, r2.xxxx, r1.xyzw
mov r1.xyz, v1.xyzx
mov r1.w, l(1.000000)
mul r0.xyzw, r0.xyzw, r1.xyzw
mul r0.xyzw, r0.xyzw, v1.wwww
mad_sat o0.xyzw, v0.xyzw, r0.wwww, r0.xyzw
ret 
// Approximately 52 instruction slots used

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