//Cutscene rain PS 1.
// ---- Created with 3Dmigoto v1.3.16 on Sat May 25 15:28:45 2019
Texture2D<float4> t5 : register(t5);

Texture2D<float4> t4 : register(t4);

Texture2D<float4> t3 : register(t3);

Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

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 cb9 : register(b9)
{
  float4 cb9[12];
}

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,r10,r11,r12,r13;
  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;
  r1.xyz = t1.Sample(s1_s, r0.xy).xyz;
  r0.z = f32tof16(r1.z);
  r1.xy = float2(4,4) * r1.xy;
  r0.z = (uint)r0.z >> 7;
  r0.z = (int)r0.z ^ 383;
  r0.z = (int)r0.z & 2;
  if (r0.z != 0) discard;
  r0.z = cb9[0].z + -1;
  r0.z = cb9[0].w * r0.z;
  r0.w = t0.Sample(s0_s, r0.xy).x;
  r0.w = cb9[0].x + r0.w;
  r0.w = -cb9[0].y / r0.w;
  r2.xyz = v1.xyz * r0.www;
  
  r2.x+=stereo.x*(r2.z+stereo.y*v1.z)/cb12[0].x;
  
  r2.xyz = r2.xyz / v1.zzz;
  r0.w = dot(r1.xy, r1.xy);
  r3.zw = -r0.ww * float2(0.25,0.5) + float2(1,1);
  r0.w = max(0, r3.z);
  r0.w = sqrt(r0.w);
  r3.xy = r1.xy * r0.ww;
  r0.w = dot(cb9[1].xyz, r3.xyw);
  r1.xyz = -r3.xyw * r0.www + cb9[1].xyz;
  r4.xyz = r1.xyz * r0.zzz + r2.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);
  r6.xyzw = cb9[2].yzzy * r5.xyyz;
  r5.xyz = t3.Sample(s3_s, r5.zx).xyw;
  r7.xyz = t3.Sample(s3_s, r6.zw).xyw;
  r6.xyz = t3.Sample(s3_s, r6.xy).xyw;
  r8.x = dot(cb9[7].xyz, r3.xyw);
  r8.y = dot(cb9[8].xyz, r3.xyw);
  r8.z = dot(cb9[9].xyz, r3.xyw);
  r8.xyz = r8.xyz * r8.xyz;
  r8.xyz = float3(0.100000001,1,0.100000001) * r8.xyz;
  r0.z = dot(r8.xyz, float3(1,1,1));
  r0.z = 1 / r0.z;
  r8.xyz = r8.xyz * r0.zzz;
  r0.z = r8.x * r7.z;
  r7.yz = float2(-0.5,-0.5) + r7.xy;
  r0.z = r6.z * r8.z + r0.z;
  r6.xy = float2(-0.5,-0.5) + r6.xy;
  r6.xy = r6.xy * r8.zz;
  r0.z = r5.z * r8.y + r0.z;
  r5.xy = float2(-0.5,-0.5) + r5.yx;
  r5.xz = r5.xy * r8.yy;
  r1.w = cb9[0].w * cb9[0].z;
  r9.xyz = r1.xyz * r1.www + r2.xyz;
  r1.x = dot(r1.xyz, r1.xyz);
  r1.x = sqrt(r1.x);
  r1.x = r1.x * cb9[2].x + cb9[1].w;
  r9.w = 1;
  r10.y = dot(cb9[8].xyzw, r9.xyzw);
  r10.x = dot(cb9[7].xyzw, r9.xyzw);
  r10.z = dot(cb9[9].xyzw, r9.xyzw);
  r11.xyzw = cb9[2].yzzy * r10.xyyz;
  r1.yzw = t3.Sample(s3_s, r10.zx).xyw;
  r10.xyz = t3.Sample(s3_s, r11.zw).xyw;
  r11.xyz = t3.Sample(s3_s, r11.xy).xyw;
  r2.w = r10.z * r8.x;
  r10.yz = float2(-0.5,-0.5) + r10.xy;
  r2.w = r11.z * r8.z + r2.w;
  r11.xy = float2(-0.5,-0.5) + r11.xy;
  r11.xy = r11.xy * r8.zz;
  r1.w = r1.w * r8.y + r2.w;
  r1.yz = float2(-0.5,-0.5) + r1.zy;
  r12.xz = r1.yz * r8.yy;
  r0.z = -r1.w + r0.z;
  r0.z = cb9[0].z * r0.z + r1.w;
  r0.z = cb9[5].z * r0.z;
  r1.y = 1 + -abs(r0.w);
  r1.z = cb9[4].w * r1.y;
  r1.w = max(0, r0.w);
  r0.w = max(0, -r0.w);
  r1.z = cb9[4].z * r1.w + r1.z;
  r1.z = cb9[6].y * r0.w + r1.z;
  r1.y = r1.w + r1.y;
  r0.w = r1.y + r0.w;
  r0.w = r1.z / r0.w;
  r1.y = 1 + -r0.w;
  r0.z = r0.z * r1.y + r0.w;
  r0.w = cmp(r0.z < 0);
  r0.z = min(1, r0.z);
  if (r0.w != 0) discard;
  r0.w = t2.Sample(s2_s, r0.xy).x;
  r0.w = r0.w * 2 + -1;
  r1.y = dot(r2.xyz, r2.xyz);
  r1.y = rsqrt(r1.y);
  r2.xyz = r2.xyz * r1.yyy;
  r1.y = dot(r2.xyz, r3.xyw);
  r1.y = 1 + -abs(r1.y);
  r1.z = cb9[4].y + -cb9[4].x;
  r1.y = r1.y * r1.z + cb9[4].x;
  r0.w = -r0.z * r1.y + r0.w;
  r1.y = -r0.z * r1.y + 1;
  r0.w = r0.w / r1.y;
  r1.y = cb9[5].y + -cb9[5].x;
  r0.w = r0.w * r1.y + cb9[5].x;
  r0.w = r1.w * r0.w;
  r0.w = max(0, r0.w);
  r13.x = dot(cb9[10].xyzw, r4.xyzw);
  r13.y = dot(cb9[11].xyzw, r4.xyzw);
  r1.yzw = t5.Sample(s5_s, r13.xy).xyz;
  r4.x = dot(cb9[10].xyzw, r9.xyzw);
  r4.y = dot(cb9[11].xyzw, r9.xyzw);
  r4.xyz = t5.Sample(s5_s, r4.xy).xyz;
  r1.yzw = -r4.xyz + r1.yzw;
  r1.yzw = cb9[0].zzz * r1.yzw + r4.xyz;
  r1.yz = r1.yz * float2(2,2) + float2(-1,-1);
  r4.x = dot(cb12[4].xz, r1.yz);
  r4.y = dot(cb12[5].xz, r1.yz);
  r4.z = dot(cb12[6].xz, r1.yz);
  r4.xyz = r4.xyz * r0.www;
  r0.w = min(1, r0.w);
  r0.w = r1.w * r0.w;
  r6.z = 0;
  r7.x = 0;
  r1.yzw = r7.xyz * r8.xxx + r6.xyz;
  r5.y = 0;
  r1.yzw = r1.yzw + r5.xyz;
  r11.z = 0;
  r10.x = 0;
  r5.xyz = r10.xyz * r8.xxx + r11.xyz;
  r12.y = 0;
  r5.xyz = r5.xyz + r12.xyz;
  r1.yzw = -r5.xyz + r1.yzw;
  r1.yzw = cb9[0].zzz * r1.yzw + r5.xyz;
  r5.x = dot(cb12[4].xyz, r1.yzw);
  r5.y = dot(cb12[5].xyz, r1.yzw);
  r5.z = dot(cb12[6].xyz, r1.yzw);
  r1.y = dot(r3.xyw, r5.xyz);
  r1.yzw = -r3.xyw * r1.yyy + r5.xyz;
  r3.xyz = r1.yzw * r1.xxx + r3.xyw;
  r3.xyz = r3.xyz + -r1.yzw;
  r1.xyz = r0.zzz * r3.xyz + r1.yzw;
  r0.z = saturate(100 * r0.z);
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www + r4.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www;
  r1.z = dot(r2.xyz, r1.xyz);
  r1.w = r1.z + r1.z;
  r1.xy = r1.xy * -r1.ww + r2.xy;
  r0.xy = r1.xy * float2(0.100000001,-0.100000001) + r0.xy;
  r1.xyw = t4.Sample(s4_s, r0.xy).xyz;
  r1.xyw = cb9[2].www * r1.xyw;
  r0.x = 1 + -abs(r1.z);
  r0.x = max(0, r0.x);
  r0.y = r0.x * r0.x;
  r0.y = r0.y * r0.y;
  r0.x = r0.y * r0.x;
  r2.xyz = r1.xyw * r0.xxx;
  r0.x = abs(r1.z) * abs(r1.z);
  r0.x = r0.x * r0.x;
  r0.x = -r0.x * abs(r1.z) + 1;
  r2.w = r0.x * r0.w;
  r0.x = r0.z * -2 + 3;
  r0.y = r0.z * r0.z;
  r0.x = r0.x * r0.y;
  o0.xyzw = r2.xyzw * r0.xxxx;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sat May 25 15:28:45 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[12], 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_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_input_ps linear v0.xyz
dcl_input_ps linear v1.xyz
dcl_output o0.xyzw
dcl_temps 14
div r0.xy, v0.xyxx, v0.zzzz
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r0.xyxx, t1.xyzw, s1
f32tof16 r0.z, r1.z
mul r1.xy, r1.xyxx, l(4.000000, 4.000000, 0.000000, 0.000000)
ushr r0.z, r0.z, l(7)
xor r0.z, r0.z, l(383)
and r0.z, r0.z, l(2)
discard_nz r0.z
add r0.z, l(-1.000000), cb9[0].z
mul r0.z, r0.z, cb9[0].w
sample_indexable(texture2d)(float,float,float,float) r0.w, r0.xyxx, t0.yzwx, s0
add r0.w, r0.w, cb9[0].x
div r0.w, -cb9[0].y, r0.w
mul r2.xyz, r0.wwww, v1.xyzx
div r2.xyz, r2.xyzx, v1.zzzz
dp2 r0.w, r1.xyxx, r1.xyxx
mad r3.zw, -r0.wwww, l(0.000000, 0.000000, 0.250000, 0.500000), l(0.000000, 0.000000, 1.000000, 1.000000)
max r0.w, r3.z, l(0.000000)
sqrt r0.w, r0.w
mul r3.xy, r0.wwww, r1.xyxx
dp3 r0.w, cb9[1].xyzx, r3.xywx
mad r1.xyz, -r3.xywx, r0.wwww, cb9[1].xyzx
mad r4.xyz, r1.xyzx, r0.zzzz, r2.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 r6.xyzw, r5.xyyz, cb9[2].yzzy
sample_indexable(texture2d)(float,float,float,float) r5.xyz, r5.zxzz, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r7.xyz, r6.zwzz, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r6.xyz, r6.xyxx, t3.xywz, s3
dp3 r8.x, cb9[7].xyzx, r3.xywx
dp3 r8.y, cb9[8].xyzx, r3.xywx
dp3 r8.z, cb9[9].xyzx, r3.xywx
mul r8.xyz, r8.xyzx, r8.xyzx
mul r8.xyz, r8.xyzx, l(0.100000, 1.000000, 0.100000, 0.000000)
dp3 r0.z, r8.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mul r8.xyz, r0.zzzz, r8.xyzx
mul r0.z, r7.z, r8.x
add r7.yz, r7.xxyx, l(0.000000, -0.500000, -0.500000, 0.000000)
mad r0.z, r6.z, r8.z, r0.z
add r6.xy, r6.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r6.xy, r8.zzzz, r6.xyxx
mad r0.z, r5.z, r8.y, r0.z
add r5.xy, r5.yxyy, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r5.xz, r8.yyyy, r5.xxyx
mul r1.w, cb9[0].z, cb9[0].w
mad r9.xyz, r1.xyzx, r1.wwww, r2.xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
sqrt r1.x, r1.x
mad r1.x, r1.x, cb9[2].x, cb9[1].w
mov r9.w, l(1.000000)
dp4 r10.y, cb9[8].xyzw, r9.xyzw
dp4 r10.x, cb9[7].xyzw, r9.xyzw
dp4 r10.z, cb9[9].xyzw, r9.xyzw
mul r11.xyzw, r10.xyyz, cb9[2].yzzy
sample_indexable(texture2d)(float,float,float,float) r1.yzw, r10.zxzz, t3.zxyw, s3
sample_indexable(texture2d)(float,float,float,float) r10.xyz, r11.zwzz, t3.xywz, s3
sample_indexable(texture2d)(float,float,float,float) r11.xyz, r11.xyxx, t3.xywz, s3
mul r2.w, r8.x, r10.z
add r10.yz, r10.xxyx, l(0.000000, -0.500000, -0.500000, 0.000000)
mad r2.w, r11.z, r8.z, r2.w
add r11.xy, r11.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r11.xy, r8.zzzz, r11.xyxx
mad r1.w, r1.w, r8.y, r2.w
add r1.yz, r1.zzyz, l(0.000000, -0.500000, -0.500000, 0.000000)
mul r12.xz, r8.yyyy, r1.yyzy
add r0.z, r0.z, -r1.w
mad r0.z, cb9[0].z, r0.z, r1.w
mul r0.z, r0.z, cb9[5].z
add r1.y, -|r0.w|, l(1.000000)
mul r1.z, r1.y, cb9[4].w
max r1.w, r0.w, l(0.000000)
max r0.w, -r0.w, l(0.000000)
mad r1.z, cb9[4].z, r1.w, r1.z
mad r1.z, cb9[6].y, r0.w, r1.z
add r1.y, r1.y, r1.w
add r0.w, r0.w, r1.y
div r0.w, r1.z, r0.w
add r1.y, -r0.w, l(1.000000)
mad r0.z, r0.z, r1.y, r0.w
lt r0.w, r0.z, l(0.000000)
min r0.z, r0.z, l(1.000000)
discard_nz r0.w
sample_indexable(texture2d)(float,float,float,float) r0.w, r0.xyxx, t2.yzwx, s2
mad r0.w, r0.w, l(2.000000), l(-1.000000)
dp3 r1.y, r2.xyzx, r2.xyzx
rsq r1.y, r1.y
mul r2.xyz, r1.yyyy, r2.xyzx
dp3 r1.y, r2.xyzx, r3.xywx
add r1.y, -|r1.y|, l(1.000000)
add r1.z, -cb9[4].x, cb9[4].y
mad r1.y, r1.y, r1.z, cb9[4].x
mad r0.w, -r0.z, r1.y, r0.w
mad r1.y, -r0.z, r1.y, l(1.000000)
div r0.w, r0.w, r1.y
add r1.y, -cb9[5].x, cb9[5].y
mad r0.w, r0.w, r1.y, cb9[5].x
mul r0.w, r0.w, r1.w
max r0.w, r0.w, l(0.000000)
dp4 r13.x, cb9[10].xyzw, r4.xyzw
dp4 r13.y, cb9[11].xyzw, r4.xyzw
sample_indexable(texture2d)(float,float,float,float) r1.yzw, r13.xyxx, t5.wxyz, s5
dp4 r4.x, cb9[10].xyzw, r9.xyzw
dp4 r4.y, cb9[11].xyzw, r9.xyzw
sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t5.xyzw, s5
add r1.yzw, r1.yyzw, -r4.xxyz
mad r1.yzw, cb9[0].zzzz, r1.yyzw, r4.xxyz
mad r1.yz, r1.yyzy, l(0.000000, 2.000000, 2.000000, 0.000000), l(0.000000, -1.000000, -1.000000, 0.000000)
dp2 r4.x, cb12[4].xzxx, r1.yzyy
dp2 r4.y, cb12[5].xzxx, r1.yzyy
dp2 r4.z, cb12[6].xzxx, r1.yzyy
mul r4.xyz, r0.wwww, r4.xyzx
min r0.w, r0.w, l(1.000000)
mul r0.w, r0.w, r1.w
mov r6.z, l(0)
mov r7.x, l(0)
mad r1.yzw, r7.xxyz, r8.xxxx, r6.xxyz
mov r5.y, l(0)
add r1.yzw, r5.xxyz, r1.yyzw
mov r11.z, l(0)
mov r10.x, l(0)
mad r5.xyz, r10.xyzx, r8.xxxx, r11.xyzx
mov r12.y, l(0)
add r5.xyz, r12.xyzx, r5.xyzx
add r1.yzw, r1.yyzw, -r5.xxyz
mad r1.yzw, cb9[0].zzzz, r1.yyzw, r5.xxyz
dp3 r5.x, cb12[4].xyzx, r1.yzwy
dp3 r5.y, cb12[5].xyzx, r1.yzwy
dp3 r5.z, cb12[6].xyzx, r1.yzwy
dp3 r1.y, r3.xywx, r5.xyzx
mad r1.yzw, -r3.xxyw, r1.yyyy, r5.xxyz
mad r3.xyz, r1.yzwy, r1.xxxx, r3.xywx
add r3.xyz, -r1.yzwy, r3.xyzx
mad r1.xyz, r0.zzzz, r3.xyzx, r1.yzwy
mul_sat r0.z, r0.z, l(100.000000)
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mad r1.xyz, r1.xyzx, r1.wwww, r4.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r1.xyz, r1.wwww, r1.xyzx
dp3 r1.z, r2.xyzx, r1.xyzx
add r1.w, r1.z, r1.z
mad r1.xy, r1.xyxx, -r1.wwww, r2.xyxx
mad r0.xy, r1.xyxx, l(0.100000, -0.100000, 0.000000, 0.000000), r0.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xyw, r0.xyxx, t4.xywz, s4
mul r1.xyw, r1.xyxw, cb9[2].wwww
add r0.x, -|r1.z|, l(1.000000)
max r0.x, r0.x, l(0.000000)
mul r0.y, r0.x, r0.x
mul r0.y, r0.y, r0.y
mul r0.x, r0.x, r0.y
mul r2.xyz, r0.xxxx, r1.xywx
mul r0.x, |r1.z|, |r1.z|
mul r0.x, r0.x, r0.x
mad r0.x, -r0.x, |r1.z|, l(1.000000)
mul r2.w, r0.w, r0.x
mad r0.x, r0.z, l(-2.000000), l(3.000000)
mul r0.y, r0.z, r0.z
mul r0.x, r0.y, r0.x
mul o0.xyzw, r0.xxxx, r2.xyzw
ret
// Approximately 0 instruction slots used

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