// ---- 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;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = 0;
  r0.y = -fsize.x;
  while (true) {
    r0.z = cmp(fsize.x < r0.y);
    if (r0.z != 0) break;
    r1.x = offset.x + r0.y;
    r2.x = r0.x;
    r2.y = -fsize.y;
    while (true) {
      r0.z = cmp(fsize.y < r2.y);
      if (r0.z != 0) break;
      r1.y = offset.y + r2.y;
      r0.zw = r1.xy * texscale.xy + v2.xy;
      r0.z = tex.Sample(sampler_tex_s, r0.zw).w;
      r2.x = r2.x + r0.z;
      r2.y = 1 + r2.y;
    }
    r0.x = r2.x;
    r0.y = 1 + r0.y;
  }
  r0.x = fsize.w * r0.x;
  r0.x = saturate(fsize.z * r0.x);
  r0.y = 0;
  r0.xyzw = gradtex.Sample(sampler_gradtex_s, r0.xy).xyzw;
  r1.xy = srctexscale.xy * v2.xy;
  r1.x = srctex.Sample(sampler_srctex_s, r1.xy).w;
  r2.w = 9.99999975e-005 * r1.x;
  r1.y = saturate(r0.w);
  r0.w = 1;
  r1.z = 1 + -r1.y;
  r2.xyz = float3(0,0,0);
  r2.xyzw = r2.xyzw * r1.zzzz;
  r0.xyzw = r0.xyzw * r1.yyyy + r2.xyzw;
  r0.xyzw = r0.xyzw * r1.xxxx;
  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 3
mov r0.x, l(0)
mov r0.y, -cb0[0].x
loop 
  lt r0.z, cb0[0].x, r0.y
  breakc_nz r0.z
  add r1.x, r0.y, cb0[1].x
  mov r2.x, r0.x
  mov r2.y, -cb0[0].y
  loop 
    lt r0.z, cb0[0].y, r2.y
    breakc_nz r0.z
    add r1.y, r2.y, cb0[1].y
    mad r0.zw, r1.xxxy, cb0[3].xxxy, v2.xxxy
    sample_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t2.xywz, s2
    add r2.x, r0.z, r2.x
    add r2.y, r2.y, l(1.000000)
  endloop 
  mov r0.x, r2.x
  add r0.y, r0.y, l(1.000000)
endloop 
mul r0.x, r0.x, cb0[0].w
mul_sat r0.x, r0.x, cb0[0].z
mov r0.y, l(0)
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t0.xyzw, s0
mul r1.xy, v2.xyxx, cb0[2].xyxx
sample_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t1.wxyz, s1
mul r2.w, r1.x, l(0.000100)
mov_sat r1.y, r0.w
mov r0.w, l(1.000000)
add r1.z, -r1.y, l(1.000000)
mov r2.xyz, l(0,0,0,0)
mul r2.xyzw, r1.zzzz, r2.xyzw
mad r0.xyzw, r0.xyzw, r1.yyyy, r2.xyzw
mul r0.xyzw, r1.xxxx, r0.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 40 instruction slots used

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