//Yakuza 6 Hiroshima water waves PS. Fixes part of haloing in a temporal way.
// ---- Created with 3Dmigoto v1.3.16 on Sun Apr 04 10:24:40 2021
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 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[20];
}




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


void main(
  float4 v0 : TEXCOORD0,
  float4 v1 : TEXCOORD1,
  float2 v2 : TEXCOORD3,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  //v1.x+=stereo.x*(v1.z-stereo.y)*0.5;
  
  r0.xy = v1.xy / v1.zz;
  r0.zw = t1.Sample(s1_s, r0.xy).xy;
  r1.xyz = t3.Sample(s3_s, r0.xy).xyz;
  r2.xyz = cb9[12].xyz * r0.zzz + v0.xyz;
  r0.x = cb9[16].w * r0.w;
  r2.w = 1;
  r3.x = dot(cb9[4].xyzw, r2.xyzw);
  r3.y = dot(cb9[5].xyzw, r2.xyzw);
  r3.z = dot(cb9[6].xyzw, r2.xyzw);
  r3.w = 1;
  r0.y = dot(cb9[3].xyzw, r3.xyzw);
  r0.z = 0.5 * r0.y;
  r2.x = dot(cb9[0].xyzw, r3.xyzw);
  r2.y = dot(cb9[1].xyzw, r3.xyzw);
  r0.zw = r2.xy * float2(0.5,-0.5) + r0.zz;
  
  r0.z+=stereo.x*(r0.y-stereo.y)*0.5;
  
  r0.yz = r0.zw / r0.yy;
  r0.y = t0.Sample(s0_s, r0.yz).x;
  r0.y = cb9[2].z + r0.y;
  r0.y = -cb9[2].w / r0.y;
  r0.y = r0.y + -r3.z;
  r0.z = cb9[17].z * r3.z;
  r0.z = max(1, r0.z);
  r0.x = r0.x / r0.z;
  r0.x = cb9[17].w + r0.x;
  r0.x = max(0, r0.x);
  r0.y = saturate(cb9[17].y * abs(r0.y));
  r0.y = r0.y * -cb9[16].z + cb9[16].z;
  r0.z = v0.z * v0.z;
  r0.z = saturate(cb9[18].x / r0.z);
  r0.x = r0.y * r0.z + r0.x;
  r0.yz = float2(-0.5,-0.5) + r1.xy;
  r0.w = 1 / r1.z;
  r0.w = -1 + r0.w;
  r1.x = dot(r0.yz, r0.yz);
  r1.x = rsqrt(r1.x);
  r0.yz = r1.xx * r0.yz;
  r0.yz = r0.yz * r0.ww;
  r1.xyz = cb9[19].xyz * r0.zzz;
  r0.yzw = cb9[18].yzw * r0.yyy + r1.xyz;
  r1.xy = t4.Sample(s4_s, v2.xy).xy;
  r1.zw = float2(1,1);
  r2.x = dot(cb9[13].xyw, r1.xyz);
  r2.y = dot(cb9[14].xyw, r1.xyz);
  r2.z = dot(cb9[15].xyw, r1.xyz);
  r1.xyz = cb9[17].xxx * r2.xyz;
  r0.yzw = r0.yzw * cb9[16].yyy + r1.xyz;
  r1.xyz = v0.xyz + r0.yzw;
  r2.x = dot(cb9[8].xyzw, r1.xyzw);
  r2.y = dot(cb9[9].xyzw, r1.xyzw);
  r0.y = dot(cb9[11].xyzw, r1.xyzw);
  r0.z = 0.5 * r0.y;
  r0.zw = r2.xy * float2(0.5,-0.5) + r0.zz;
  r0.yz = r0.zw / r0.yy;
  r0.yz = t2.Sample(s2_s, r0.yz).xw;
  r0.x = r0.x + -r0.y;
  r0.w = cb9[16].x + -1;
  r0.z = r0.z * r0.w + 1;
  o0.xyz = r0.zzz * r0.xxx + r0.yyy;
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sun Apr 04 10:24:40 2021
//
//
// Note: shader requires additional functionality:
//       Early depth-stencil
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyz         0     NONE   float   xyz
// TEXCOORD                 1   xyz         1     NONE   float   xyz
// TEXCOORD                 3   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 | forceEarlyDepthStencil
dcl_constantbuffer cb9[20], 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_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_input_ps linear v0.xyz
dcl_input_ps linear v1.xyz
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 4
div r0.xy, v1.xyxx, v1.zzzz
sample_indexable(texture2d)(float,float,float,float) r0.zw, r0.xyxx, t1.zwxy, s1
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r0.xyxx, t3.xyzw, s3
mad r2.xyz, cb9[12].xyzx, r0.zzzz, v0.xyzx
mul r0.x, r0.w, cb9[16].w
mov r2.w, l(1.000000)
dp4 r3.x, cb9[4].xyzw, r2.xyzw
dp4 r3.y, cb9[5].xyzw, r2.xyzw
dp4 r3.z, cb9[6].xyzw, r2.xyzw
mov r3.w, l(1.000000)
dp4 r0.y, cb9[3].xyzw, r3.xyzw
mul r0.z, r0.y, l(0.500000)
dp4 r2.x, cb9[0].xyzw, r3.xyzw
dp4 r2.y, cb9[1].xyzw, r3.xyzw
mad r0.zw, r2.xxxy, l(0.000000, 0.000000, 0.500000, -0.500000), r0.zzzz
div r0.yz, r0.zzwz, r0.yyyy
sample_indexable(texture2d)(float,float,float,float) r0.y, r0.yzyy, t0.yxzw, s0
add r0.y, r0.y, cb9[2].z
div r0.y, -cb9[2].w, r0.y
add r0.y, -r3.z, r0.y
mul r0.z, r3.z, cb9[17].z
max r0.z, r0.z, l(1.000000)
div r0.x, r0.x, r0.z
add r0.x, r0.x, cb9[17].w
max r0.x, r0.x, l(0.000000)
mul_sat r0.y, |r0.y|, cb9[17].y
mad r0.y, r0.y, -cb9[16].z, cb9[16].z
mul r0.z, v0.z, v0.z
div_sat r0.z, cb9[18].x, r0.z
mad r0.x, r0.y, r0.z, r0.x
add r0.yz, r1.xxyx, l(0.000000, -0.500000, -0.500000, 0.000000)
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.z
add r0.w, r0.w, l(-1.000000)
dp2 r1.x, r0.yzyy, r0.yzyy
rsq r1.x, r1.x
mul r0.yz, r0.yyzy, r1.xxxx
mul r0.yz, r0.wwww, r0.yyzy
mul r1.xyz, r0.zzzz, cb9[19].xyzx
mad r0.yzw, cb9[18].yyzw, r0.yyyy, r1.xxyz
sample_indexable(texture2d)(float,float,float,float) r1.xy, v2.xyxx, t4.xyzw, s4
mov r1.zw, l(0,0,1.000000,1.000000)
dp3 r2.x, cb9[13].xywx, r1.xyzx
dp3 r2.y, cb9[14].xywx, r1.xyzx
dp3 r2.z, cb9[15].xywx, r1.xyzx
mul r1.xyz, r2.xyzx, cb9[17].xxxx
mad r0.yzw, r0.yyzw, cb9[16].yyyy, r1.xxyz
add r1.xyz, r0.yzwy, v0.xyzx
dp4 r2.x, cb9[8].xyzw, r1.xyzw
dp4 r2.y, cb9[9].xyzw, r1.xyzw
dp4 r0.y, cb9[11].xyzw, r1.xyzw
mul r0.z, r0.y, l(0.500000)
mad r0.zw, r2.xxxy, l(0.000000, 0.000000, 0.500000, -0.500000), r0.zzzz
div r0.yz, r0.zzwz, r0.yyyy
sample_indexable(texture2d)(float,float,float,float) r0.yz, r0.yzyy, t2.yxwz, s2
add r0.x, -r0.y, r0.x
add r0.w, l(-1.000000), cb9[16].x
mad r0.z, r0.z, r0.w, l(1.000000)
mad o0.xyz, r0.zzzz, r0.xxxx, r0.yyyy
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used

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