//Cutscene rain PS 2.
// ---- Created with 3Dmigoto v1.3.16 on Sat May 25 15:32:19 2019
Texture2D<float4> t3 : register(t3);

Texture2DMS<float4> t1 : register(t1);

Texture2DMS<float4> t0 : register(t0);

SamplerState s3_s : register(s3);

cbuffer cb9 : register(b9)
{
  float4 cb9[10];
}

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




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


void main(
  float4 v0 : TEXCOORD0,
  float3 v1 : TEXCOORD1,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 stereo = StereoParams.Load(0);
  
  //v0.x+=stereo.x*(v0.z-stereo.y)*0.5;
  //v1.x-=stereo.x*stereo.y/cb12[0].x;

  r0.xy = v0.xy / v0.zz;
  r0.xy = cb9[6].zw * r0.xy;
  r0.xy = (int2)r0.xy;
  r0.zw = float2(0,0);
  r1.xyz = t1.Load(r0.xy, 0).xyz;
  r0.x = t0.Load(r0.xy, 0).x;
  r0.x = cb9[0].x + r0.x;
  r0.x = -cb9[0].y / r0.x;
  r0.xyz = v1.xyz * r0.xxx;
  
  r0.x+=stereo.x*(r0.z+stereo.y*v1.z)/cb12[0].x;
  
  r0.xyz = r0.xyz / v1.zzz;
  r0.w = f32tof16(r1.z);
  r1.xy = float2(4,4) * r1.xy;
  r0.w = (uint)r0.w >> 7;
  r0.w = (int)r0.w ^ 383;
  r0.w = (int)r0.w & 2;
  r0.w = r0.w ? cb9[5].w : cb9[6].x;
  r1.z = -9.99999975e-005 + r0.w;
  r1.z = cmp(r1.z < 0);
  if (r1.z != 0) discard;
  r1.z = cb9[0].z + -1;
  r1.z = cb9[0].w * r1.z;
  r1.w = dot(r1.xy, r1.xy);
  r2.zw = -r1.ww * float2(0.25,0.5) + float2(1,1);
  r1.w = max(0, r2.z);
  r1.w = sqrt(r1.w);
  r2.xy = r1.xy * r1.ww;
  r1.x = dot(cb9[1].xyz, r2.xyw);
  r3.xyz = -r2.xyw * r1.xxx + cb9[1].xyz;
  r4.xyz = r3.xyz * r1.zzz + r0.xyz;
  r4.w = 1;
  r5.y = dot(cb9[8].xyzw, r4.xyzw);
  r5.x = dot(cb9[7].xyzw, r4.xyzw);
  r5.z = dot(cb9[9].xyzw, r4.xyzw);
  r4.xyzw = cb9[2].yzzy * r5.xyyz;
  r1.yzw = t3.Sample(s3_s, r5.zx).xyw;
  r5.xyz = t3.Sample(s3_s, r4.zw).xyw;
  r4.xyz = t3.Sample(s3_s, r4.xy).xyw;
  r6.x = dot(cb9[7].xyz, r2.xyw);
  r6.y = dot(cb9[8].xyz, r2.xyw);
  r6.z = dot(cb9[9].xyz, r2.xyw);
  r6.xyz = r6.xyz * r6.xyz;
  r6.xyz = float3(0.100000001,1,0.100000001) * r6.xyz;
  r2.z = dot(r6.xyz, float3(1,1,1));
  r2.z = 1 / r2.z;
  r6.xyz = r6.xyz * r2.zzz;
  r2.z = r6.x * r5.z;
  r5.yz = float2(-0.5,-0.5) + r5.xy;
  r2.z = r4.z * r6.z + r2.z;
  r4.xy = float2(-0.5,-0.5) + r4.xy;
  r4.xy = r4.xy * r6.zz;
  r1.w = r1.w * r6.y + r2.z;
  r1.yz = float2(-0.5,-0.5) + r1.zy;
  r7.xz = r1.yz * r6.yy;
  r1.y = cb9[0].w * cb9[0].z;
  r8.xyz = r3.xyz * r1.yyy + r0.xyz;
  r1.y = dot(r3.xyz, r3.xyz);
  r1.y = sqrt(r1.y);
  r1.y = r1.y * cb9[2].x + cb9[1].w;
  r8.w = 1;
  r3.y = dot(cb9[8].xyzw, r8.xyzw);
  r3.x = dot(cb9[7].xyzw, r8.xyzw);
  r3.z = dot(cb9[9].xyzw, r8.xyzw);
  r8.xyzw = cb9[2].yzzy * r3.xyyz;
  r3.xyz = t3.Sample(s3_s, r3.zx).xyw;
  r9.xyz = t3.Sample(s3_s, r8.xy).xyw;
  r8.xyz = t3.Sample(s3_s, r8.zw).xyw;
  r1.z = r8.z * r6.x;
  r8.yz = float2(-0.5,-0.5) + r8.xy;
  r1.z = r9.z * r6.z + r1.z;
  r9.xy = float2(-0.5,-0.5) + r9.xy;
  r9.xy = r9.xy * r6.zz;
  r1.z = r3.z * r6.y + r1.z;
  r3.xy = float2(-0.5,-0.5) + r3.yx;
  r3.xz = r3.xy * r6.yy;
  r1.w = r1.w + -r1.z;
  r1.z = cb9[0].z * r1.w + r1.z;
  r1.z = cb9[5].z * r1.z;
  r1.w = 1 + -abs(r1.x);
  r2.z = cb9[4].w * r1.w;
  r3.w = max(0, r1.x);
  r1.x = max(0, -r1.x);
  r2.z = cb9[4].z * r3.w + r2.z;
  r1.w = r3.w + r1.w;
  r1.w = r1.w + r1.x;
  r1.x = cb9[6].y * r1.x + r2.z;
  r1.x = r1.x / r1.w;
  r1.w = 1 + -r1.x;
  r1.x = r1.z * r1.w + r1.x;
  r1.z = cmp(r1.x < 0);
  r1.x = min(1, r1.x);
  if (r1.z != 0) discard;
  r4.z = 0;
  r5.x = 0;
  r4.xyz = r5.xyz * r6.xxx + r4.xyz;
  r7.y = 0;
  r4.xyz = r4.xyz + r7.xyz;
  r9.z = 0;
  r8.x = 0;
  r5.xyz = r8.xyz * r6.xxx + r9.xyz;
  r3.y = 0;
  r3.xyz = r5.xyz + r3.xyz;
  r4.xyz = r4.xyz + -r3.xyz;
  r3.xyz = cb9[0].zzz * r4.xyz + r3.xyz;
  r4.x = dot(cb12[4].xyz, r3.xyz);
  r4.y = dot(cb12[5].xyz, r3.xyz);
  r4.z = dot(cb12[6].xyz, r3.xyz);
  r1.z = dot(r2.xyw, r4.xyz);
  r3.xyz = -r2.xyw * r1.zzz + r4.xyz;
  r1.yzw = r3.xyz * r1.yyy + r2.xyw;
  r1.yzw = r1.yzw + -r3.xyz;
  r1.yzw = r1.xxx * r1.yzw + r3.xyz;
  r2.x = dot(r1.yzw, r1.yzw);
  r2.x = rsqrt(r2.x);
  r1.yzw = r2.xxx * r1.yzw;
  r2.x = dot(r0.xyz, r0.xyz);
  r2.x = rsqrt(r2.x);
  r0.xyz = r2.xxx * r0.xyz;
  r0.x = dot(r0.xyz, r1.yzw);
  r0.x = 1 + -abs(r0.x);
  r0.y = cb9[4].y + -cb9[4].x;
  r0.x = r0.x * r0.y + cb9[4].x;
  r0.x = r1.x * r0.x;
  o0.xyzw = r0.xxxx * r0.wwww;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sat May 25 15:32:19 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyz         0     NONE   float   xyz
// TEXCOORD                 1   xyz         1     NONE   float   xyz
//
//
// 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[7], immediateIndexed
dcl_constantbuffer cb9[10], immediateIndexed
dcl_sampler s3, mode_default
dcl_resource_texture2dms(0) (float,float,float,float) t0
dcl_resource_texture2dms(0) (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v0.xyz
dcl_input_ps linear v1.xyz
dcl_output o0.xyzw
dcl_temps 10
div r0.xy, v0.xyxx, v0.zzzz
mul r0.xy, r0.xyxx, cb9[6].zwzz
ftoi r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms_indexable(texture2dms)(float,float,float,float) r1.xyz, r0.xyww, t1.xyzw, l(0)
ldms_indexable(texture2dms)(float,float,float,float) r0.x, r0.xyzw, t0.xyzw, l(0)
add r0.x, r0.x, cb9[0].x
div r0.x, -cb9[0].y, r0.x
mul r0.xyz, r0.xxxx, v1.xyzx
div r0.xyz, r0.xyzx, v1.zzzz
f32tof16 r0.w, r1.z
mul r1.xy, r1.xyxx, l(4.000000, 4.000000, 0.000000, 0.000000)
ushr r0.w, r0.w, l(7)
xor r0.w, r0.w, l(383)
and r0.w, r0.w, l(2)
movc r0.w, r0.w, cb9[5].w, cb9[6].x
add r1.z, r0.w, l(-0.000100)
lt r1.z, r1.z, l(0.000000)
discard_nz r1.z
add r1.z, l(-1.000000), cb9[0].z
mul r1.z, r1.z, cb9[0].w
dp2 r1.w, r1.xyxx, r1.xyxx
mad r2.zw, -r1.wwww, l(0.000000, 0.000000, 0.250000, 0.500000), l(0.000000, 0.000000, 1.000000, 1.000000)
max r1.w, r2.z, l(0.000000)
sqrt r1.w, r1.w
mul r2.xy, r1.wwww, r1.xyxx
dp3 r1.x, cb9[1].xyzx, r2.xywx
mad r3.xyz, -r2.xywx, r1.xxxx, cb9[1].xyzx
mad r4.xyz, r3.xyzx, r1.zzzz, r0.xyzx
mov r4.w, l(1.000000)
dp4 r5.y, cb9[8].xyzw, r4.xyzw
dp4 r5.x, cb9[7].xyzw, r4.xyzw
dp4 r5.z, cb9[9].xyzw, r4.xyzw
mul r4.xyzw, r5.xyyz, cb9[2].yzzy
sample_indexable(texture2d)(float,float,float,float) r1.yzw, r5.zxzz, t3.zxyw, s3
sample_indexable(texture2d)(float,float,float,float) r5.xyz, r4.zwzz, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t3.xywz, s3
dp3 r6.x, cb9[7].xyzx, r2.xywx
dp3 r6.y, cb9[8].xyzx, r2.xywx
dp3 r6.z, cb9[9].xyzx, r2.xywx
mul r6.xyz, r6.xyzx, r6.xyzx
mul r6.xyz, r6.xyzx, l(0.100000, 1.000000, 0.100000, 0.000000)
dp3 r2.z, r6.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
div r2.z, l(1.000000, 1.000000, 1.000000, 1.000000), r2.z
mul r6.xyz, r2.zzzz, r6.xyzx
mul r2.z, r5.z, r6.x
add r5.yz, r5.xxyx, l(0.000000, -0.500000, -0.500000, 0.000000)
mad r2.z, r4.z, r6.z, r2.z
add r4.xy, r4.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r4.xy, r6.zzzz, r4.xyxx
mad r1.w, r1.w, r6.y, r2.z
add r1.yz, r1.zzyz, l(0.000000, -0.500000, -0.500000, 0.000000)
mul r7.xz, r6.yyyy, r1.yyzy
mul r1.y, cb9[0].z, cb9[0].w
mad r8.xyz, r3.xyzx, r1.yyyy, r0.xyzx
dp3 r1.y, r3.xyzx, r3.xyzx
sqrt r1.y, r1.y
mad r1.y, r1.y, cb9[2].x, cb9[1].w
mov r8.w, l(1.000000)
dp4 r3.y, cb9[8].xyzw, r8.xyzw
dp4 r3.x, cb9[7].xyzw, r8.xyzw
dp4 r3.z, cb9[9].xyzw, r8.xyzw
mul r8.xyzw, r3.xyyz, cb9[2].yzzy
sample_indexable(texture2d)(float,float,float,float) r3.xyz, r3.zxzz, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r9.xyz, r8.xyxx, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r8.xyz, r8.zwzz, t3.xywz, s3
mul r1.z, r6.x, r8.z
add r8.yz, r8.xxyx, l(0.000000, -0.500000, -0.500000, 0.000000)
mad r1.z, r9.z, r6.z, r1.z
add r9.xy, r9.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r9.xy, r6.zzzz, r9.xyxx
mad r1.z, r3.z, r6.y, r1.z
add r3.xy, r3.yxyy, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r3.xz, r6.yyyy, r3.xxyx
add r1.w, -r1.z, r1.w
mad r1.z, cb9[0].z, r1.w, r1.z
mul r1.z, r1.z, cb9[5].z
add r1.w, -|r1.x|, l(1.000000)
mul r2.z, r1.w, cb9[4].w
max r3.w, r1.x, l(0.000000)
max r1.x, -r1.x, l(0.000000)
mad r2.z, cb9[4].z, r3.w, r2.z
add r1.w, r1.w, r3.w
add r1.w, r1.x, r1.w
mad r1.x, cb9[6].y, r1.x, r2.z
div r1.x, r1.x, r1.w
add r1.w, -r1.x, l(1.000000)
mad r1.x, r1.z, r1.w, r1.x
lt r1.z, r1.x, l(0.000000)
min r1.x, r1.x, l(1.000000)
discard_nz r1.z
mov r4.z, l(0)
mov r5.x, l(0)
mad r4.xyz, r5.xyzx, r6.xxxx, r4.xyzx
mov r7.y, l(0)
add r4.xyz, r7.xyzx, r4.xyzx
mov r9.z, l(0)
mov r8.x, l(0)
mad r5.xyz, r8.xyzx, r6.xxxx, r9.xyzx
mov r3.y, l(0)
add r3.xyz, r3.xyzx, r5.xyzx
add r4.xyz, -r3.xyzx, r4.xyzx
mad r3.xyz, cb9[0].zzzz, r4.xyzx, r3.xyzx
dp3 r4.x, cb12[4].xyzx, r3.xyzx
dp3 r4.y, cb12[5].xyzx, r3.xyzx
dp3 r4.z, cb12[6].xyzx, r3.xyzx
dp3 r1.z, r2.xywx, r4.xyzx
mad r3.xyz, -r2.xywx, r1.zzzz, r4.xyzx
mad r1.yzw, r3.xxyz, r1.yyyy, r2.xxyw
add r1.yzw, -r3.xxyz, r1.yyzw
mad r1.yzw, r1.xxxx, r1.yyzw, r3.xxyz
dp3 r2.x, r1.yzwy, r1.yzwy
rsq r2.x, r2.x
mul r1.yzw, r1.yyzw, r2.xxxx
dp3 r2.x, r0.xyzx, r0.xyzx
rsq r2.x, r2.x
mul r0.xyz, r0.xyzx, r2.xxxx
dp3 r0.x, r0.xyzx, r1.yzwy
add r0.x, -|r0.x|, l(1.000000)
add r0.y, -cb9[4].x, cb9[4].y
mad r0.x, r0.x, r0.y, cb9[4].x
mul r0.x, r0.x, r1.x
mul o0.xyzw, r0.wwww, r0.xxxx
ret
// Approximately 0 instruction slots used

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