// God Rays PS, no fix here

cbuffer HPixel_Buffer : register(b12)
{
  float4 g_TargetUvParam : packoffset(c0);
}

SamplerState g_ScatterSampler_s : register(s0);
SamplerState g_Z_TexSampler_s : register(s1);
Texture2D<float4> g_Scatter : register(t0);
Texture2D<float4> g_Z_Tex : register(t1);


// 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;

  r0.xy = g_TargetUvParam.zw * v1.xy;
  r0.xy = floor(r0.xy);
  r0.xy = (int2)r0.xy;
  r0.xy = (int2)r0.xy & int2(1,1);
  r0.xy = (int2)r0.xy;
  r0.zw = r0.yx * float2(2,2) + float2(1,1);
  r1.xy = r0.xy * float2(-2,-2) + float2(3,3);
  r0.xy = float2(-2,-2) + r0.xy;
  r1.zw = r1.xy * r0.zw;
  r0.z = r0.w * r0.z;
  r0.w = r1.x * r1.y;
  r1.xy = float2(1,1) / g_TargetUvParam.zw;
  r2.zw = r0.xy * r1.xy + v1.xy;
  r2.xy = r1.xy * float2(2,2) + r2.zw;
  r0.x = g_Z_Tex.Sample(g_Z_TexSampler_s, r2.xw).x;
  r0.y = g_Z_Tex.Sample(g_Z_TexSampler_s, v1.xy).x;
  r0.x = r0.y + -r0.x;
  r0.x = 1.00000004e-036 + abs(r0.x);
  r0.x = 1 / r0.x;
  
  float4 stereo = StereoParams.Load(0);
r0.x += stereo.x * (r0.z + stereo.y);	


  r0.x = r1.z * r0.x;
  r3.xyzw = g_Scatter.Sample(g_ScatterSampler_s, r2.xw).xyzw;
  r3.xyzw = r3.xyzw * r0.xxxx;
  r1.x = g_Z_Tex.Sample(g_Z_TexSampler_s, r2.zw).x;
  r1.x = -r1.x + r0.y;
  r1.x = 1.00000004e-036 + abs(r1.x);
  r1.x = 1 / r1.x;

  r1.y = r1.x * r0.z;
  r0.x = r0.z * r1.x + r0.x;
  r4.xyzw = g_Scatter.Sample(g_ScatterSampler_s, r2.zw).xyzw;
  r3.xyzw = r1.yyyy * r4.xyzw + r3.xyzw;
  r0.z = g_Z_Tex.Sample(g_Z_TexSampler_s, r2.zy).x;
  r4.xyzw = g_Scatter.Sample(g_ScatterSampler_s, r2.zy).xyzw;
  r0.z = r0.y + -r0.z;
  r0.z = 1.00000004e-036 + abs(r0.z);
  r0.z = 1 / r0.z;
  
  

  r1.x = r1.w * r0.z;
  r0.x = r1.w * r0.z + r0.x;
  r1.xyzw = r1.xxxx * r4.xyzw + r3.xyzw;
  r0.z = g_Z_Tex.Sample(g_Z_TexSampler_s, r2.xy).x;
  r2.xyzw = g_Scatter.Sample(g_ScatterSampler_s, r2.xy).xyzw;
  r0.y = r0.y + -r0.z;
  r0.y = 1.00000004e-036 + abs(r0.y);
  r0.y = 1 / r0.y;
  r0.z = r0.w * r0.y;
  r0.x = r0.w * r0.y + r0.x;
  r1.xyzw = r0.zzzz * r2.xyzw + r1.xyzw;
  o0.xyzw = r1.xyzw / r0.xxxx;

  
  discard;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.57 on Sun May 07 00:30:11 2017
//
//
// Buffer Definitions: 
//
// cbuffer HPixel_Buffer
// {
//
//   float4 g_TargetUvParam;            // Offset:    0 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_ScatterSampler                  sampler      NA          NA    0        1
// g_Z_TexSampler                    sampler      NA          NA    1        1
// g_Scatter                         texture  float4          2d    0        1
// g_Z_Tex                           texture  float4          2d    1        1
// HPixel_Buffer                     cbuffer      NA          NA   12        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
dcl_constantbuffer cb12[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 5
mul r0.xy, v1.xyxx, cb12[0].zwzz
round_ni r0.xy, r0.xyxx
ftoi r0.xy, r0.xyxx
and r0.xy, r0.xyxx, l(1, 1, 0, 0)
itof r0.xy, r0.xyxx
mad r0.zw, r0.yyyx, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, 1.000000)
mad r1.xy, r0.xyxx, l(-2.000000, -2.000000, 0.000000, 0.000000), l(3.000000, 3.000000, 0.000000, 0.000000)
add r0.xy, r0.xyxx, l(-2.000000, -2.000000, 0.000000, 0.000000)
mul r1.zw, r0.zzzw, r1.xxxy
mul r0.z, r0.z, r0.w
mul r0.w, r1.y, r1.x
div r1.xy, l(1.000000, 1.000000, 1.000000, 1.000000), cb12[0].zwzz
mad r2.zw, r0.xxxy, r1.xxxy, v1.xxxy
mad r2.xy, r1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r2.zwzz
sample_indexable(texture2d)(float,float,float,float) r0.x, r2.xwxx, t1.xyzw, s1
sample_indexable(texture2d)(float,float,float,float) r0.y, v1.xyxx, t1.yxzw, s1
add r0.x, -r0.x, r0.y
add r0.x, |r0.x|, l(1.000000036E-036)
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
mul r0.x, r0.x, r1.z
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r2.xwxx, t0.xyzw, s0
mul r3.xyzw, r0.xxxx, r3.xyzw
sample_indexable(texture2d)(float,float,float,float) r1.x, r2.zwzz, t1.xyzw, s1
add r1.x, r0.y, -r1.x
add r1.x, |r1.x|, l(1.000000036E-036)
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
mul r1.y, r0.z, r1.x
mad r0.x, r0.z, r1.x, r0.x
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.zwzz, t0.xyzw, s0
mad r3.xyzw, r1.yyyy, r4.xyzw, r3.xyzw
sample_indexable(texture2d)(float,float,float,float) r0.z, r2.zyzz, t1.yzxw, s1
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.zyzz, t0.xyzw, s0
add r0.z, -r0.z, r0.y
add r0.z, |r0.z|, l(1.000000036E-036)
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mul r1.x, r0.z, r1.w
mad r0.x, r1.w, r0.z, r0.x
mad r1.xyzw, r1.xxxx, r4.xyzw, r3.xyzw
sample_indexable(texture2d)(float,float,float,float) r0.z, r2.xyxx, t1.yzxw, s1
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t0.xyzw, s0
add r0.y, -r0.z, r0.y
add r0.y, |r0.y|, l(1.000000036E-036)
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
mul r0.z, r0.y, r0.w
mad r0.x, r0.w, r0.y, r0.x
mad r1.xyzw, r0.zzzz, r2.xyzw, r1.xyzw
div o0.xyzw, r1.xyzw, r0.xxxx
ret 
// Approximately 48 instruction slots used

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