//God rays DJ-RK.
// ---- Created with 3Dmigoto v1.2.45 on Thu Nov 10 04:12:52 2016
Texture2D<float4> t6 : register(t6);

Texture2D<float4> t5 : register(t5);

Texture2D<float4> t4 : register(t4);

Texture1D<float4> t3 : register(t3);

Texture3D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s6_s : register(s6);

SamplerState s5_s : register(s5);

SamplerState s4_s : register(s4);

SamplerState s3_s : register(s3);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

cbuffer cb2 : register(b2)
{
  float4 cb2[1];
}

cbuffer cb12 : register(b12)
{
  float4 cb12[45];
}




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


void main( 
  float4 v0 : SV_POSITION0,
  float2 v1 : TEXCOORD0,
  out float o0 : SV_Target0)
{
// Needs manual fix for instruction: 
// unknown dcl_: dcl_resource_texture1d (float,float,float,float) t3
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);
float2 origin = cb12[43].xy;
origin.x += stereo.x / 2;
  r0.xy = cb12[43].xy * v1.xy;
// r0.xy = origin.xy * v1.xy;
  r0.xy = max(float2(0,0), r0.xy);
  r1.x = min(cb12[44].z, r0.x);
  r1.y = min(cb12[43].y, r0.y);
  r0.x = t0.Sample(s0_s, r1.xy).x;
  r0.y = t3.SampleLevel(s3_s, r0.x, 0).x;
  r0.y = max(0, r0.y);
  r2.z = min(0.999899983, r0.y);
  r2.xy = v1.xy;
// Standard light shaft fix
//r2.x-=stereo.x/2;
r2.x-=(stereo.x+stereo.y*stereo.z/10000)/2;
  r0.y = t2.SampleLevel(s2_s, r2.xyz, 0).x;
  r0.y = cb2[0].x * r0.y;
  r0.zw = float2(0.125,0.125) * v0.xy;
  r0.z = t4.Sample(s4_s, r0.zw).x;
  r0.y = r0.z * 0.03125 + r0.y;
  r0.y = -0.0078125 + r0.y;
  r0.z = cmp(0.00100000005 < cb2[0].y);
  if (r0.z != 0) {
    r0.zw = t5.Sample(s5_s, r1.xy).xy;
    r0.zw = v1.xy + r0.zw;
    r1.xy = cb12[43].zw * r0.zw;
    r1.xy = max(float2(0,0), r1.xy);
    r2.x = min(cb12[44].w, r1.x);
    r2.y = min(cb12[43].w, r1.y);
    r1.x = t1.Sample(s1_s, r2.xy).x;
    r1.y = t6.Sample(s6_s, r2.xy).x;
    r0.x = -r1.y + r0.x;
    r0.x = 100 * abs(r0.x);
    r0.x = min(1, r0.x);
    r1.y = r0.x * -2 + 3;
    r0.x = r0.x * r0.x;
    r0.x = -r1.y * r0.x + 1;
    r0.x = cb2[0].y * r0.x;
    r1.yz = cmp(r0.zw >= float2(0,0));
    r0.zw = cmp(r0.zw < float2(1,1));
    r0.zw = r0.zw ? r1.yz : 0;
    r0.z = r0.w ? r0.z : 0;
    r0.z = r0.z ? 1.000000 : 0;
    r0.x = r0.x * r0.z;
    r0.z = r1.x + -r0.y;
    o0.x = r0.x * r0.z + r0.y;
  } else {
    o0.x = r0.y;
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.45 on Thu Nov 10 04:12:52 2016
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy  
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   x           0   TARGET   float   x   
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb12[45], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture3d (float,float,float,float) t2
dcl_resource_texture1d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xy
dcl_output o0.x
dcl_temps 3
mul r0.xy, v1.xyxx, cb12[43].xyxx
max r0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
min r1.x, r0.x, cb12[44].z
min r1.y, r0.y, cb12[43].y
sample_indexable(texture2d)(float,float,float,float) r0.x, r1.xyxx, t0.xyzw, s0
sample_l_indexable(texture1d)(float,float,float,float) r0.y, r0.x, t3.yxzw, s3, l(0.000000)
max r0.y, r0.y, l(0.000000)
min r2.z, r0.y, l(0.999900)
mov r2.xy, v1.xyxx
sample_l_indexable(texture3d)(float,float,float,float) r0.y, r2.xyzx, t2.yxzw, s2, l(0.000000)
mul r0.y, r0.y, cb2[0].x
mul r0.zw, v0.xxxy, l(0.000000, 0.000000, 0.125000, 0.125000)
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t4.yzxw, s4
mad r0.y, r0.z, l(0.031250), r0.y
add r0.y, r0.y, l(-0.00781250000)
lt r0.z, l(0.001000), cb2[0].y
if_nz r0.z
  sample_indexable(texture2d)(float,float,float,float) r0.zw, r1.xyxx, t5.zwxy, s5
  add r0.zw, r0.zzzw, v1.xxxy
  mul r1.xy, r0.zwzz, cb12[43].zwzz
  max r1.xy, r1.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
  min r2.x, r1.x, cb12[44].w
  min r2.y, r1.y, cb12[43].w
  sample_indexable(texture2d)(float,float,float,float) r1.x, r2.xyxx, t1.xyzw, s1
  sample_indexable(texture2d)(float,float,float,float) r1.y, r2.xyxx, t6.yxzw, s6
  add r0.x, r0.x, -r1.y
  mul r0.x, |r0.x|, l(100.000000)
  min r0.x, r0.x, l(1.000000)
  mad r1.y, r0.x, l(-2.000000), l(3.000000)
  mul r0.x, r0.x, r0.x
  mad r0.x, -r1.y, r0.x, l(1.000000)
  mul r0.x, r0.x, cb2[0].y
  ge r1.yz, r0.zzwz, l(0.000000, 0.000000, 0.000000, 0.000000)
  lt r0.zw, r0.zzzw, l(0.000000, 0.000000, 1.000000, 1.000000)
  and r0.zw, r0.zzzw, r1.yyyz
  and r0.z, r0.w, r0.z
  and r0.z, r0.z, l(0x3f800000)
  mul r0.x, r0.z, r0.x
  add r0.z, -r0.y, r1.x
  mad o0.x, r0.x, r0.z, r0.y
else 
  mov o0.x, r0.y
endif 
ret 
// Approximately 0 instruction slots used

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