//Yakuza 2 boat water decals PS.
// ---- Created with 3Dmigoto v1.3.16 on Sat Apr 10 15:30:39 2021
Texture2D<float4> t3 : register(t3);

Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

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[8];
}

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


// 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;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  v1.x-=stereo.x*stereo.y/cb12[0].x;
  
  r0.w = 1;
  r1.xy = v0.xy / v0.zz;
  r1.z = t0.Sample(s0_s, r1.xy).x;
  r1.z = cb9[1].x + r1.z;
  r1.z = -cb9[1].y / r1.z;
  r2.xyz = v1.xyz * r1.zzz;
  
  r2.x+=stereo.x*(0+stereo.y*v1.z)/cb12[0].x;
  
  r0.xyz = r2.xyz / v1.zzz;
  r0.w = dot(cb9[0].xyzw, r0.xyzw);
  r1.zw = float2(0.100000001,1) + r0.ww;
  r1.z = cmp(r1.z < 0);
  if (r1.z != 0) discard;
  r1.z = -r0.w * cb9[7].x + 1;
  r2.x = cmp(r1.z < 0);
  if (r2.x != 0) discard;
  r2.x = cb9[1].z + -1;
  r2.yz = t1.Sample(s1_s, r1.xy).xy;
  r3.xyz = t3.Sample(s3_s, r1.xy).xyz;
  r1.x = dot(r2.yz, r2.yz);
  r1.x = 1 + -r1.x;
  r1.x = max(0, r1.x);
  r2.w = sqrt(r1.x);
  r1.xyw = r2.yzw * r1.www;
  r4.xyz = r1.xyw * r2.xxx + r0.xyz;
  r5.xyz = r1.xyw * cb9[1].zzz + r0.xyz;
  r4.w = 1;
  r0.x = dot(cb9[2].xyzw, r4.xyzw);
  r0.y = dot(cb9[3].xyzw, r4.xyzw);
  r0.z = 4 * r0.w;
  r0.w = r0.w * r0.w;
  r0.w = cb9[4].w * r0.w + 1;
  r0.w = 1 / r0.w;
  r0.w = r1.z * r0.w;
  r0.x = t2.SampleLevel(s2_s, r0.xy, r0.z).w;
  r5.w = 1;
  r1.x = dot(cb9[2].xyzw, r5.xyzw);
  r1.y = dot(cb9[3].xyzw, r5.xyzw);
  r0.y = t2.SampleLevel(s2_s, r1.xy, r0.z).w;
  r0.x = r0.x + -r0.y;
  r0.x = cb9[1].z * r0.x + r0.y;
  r0.y = dot(cb9[0].xyz, r2.yzw);
  r0.z = dot(cb9[4].xyz, r2.yzw);
  r0.z = 1 + r0.z;
  r0.z = 0.5 * r0.z;
  r0.z = max(0, r0.z);
  r0.z = log2(r0.z);
  r0.z = cb9[1].w * r0.z;
  r0.z = exp2(r0.z);
  r1.xyzw = cb9[6].wxyz + -cb9[5].wxyz;
  r0.y = saturate(r0.y * r1.x + cb9[5].w);
  r1.xyz = r0.zzz * r1.yzw + cb9[5].xyz;
  r0.y = r0.y * r0.w;
  r0.yzw = r0.yyy * r3.xyz;
  r0.xyz = r0.yzw * r0.xxx;
  o0.xyz = r0.xyz * r1.xyz;
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sat Apr 10 15:30:39 2021
//
//
// 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 cb9[8], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, 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_input_ps linear v0.xyz
dcl_input_ps linear v1.xyz
dcl_output o0.xyzw
dcl_temps 6
mov r0.w, l(1.000000)
div r1.xy, v0.xyxx, v0.zzzz
sample_indexable(texture2d)(float,float,float,float) r1.z, r1.xyxx, t0.yzxw, s0
add r1.z, r1.z, cb9[1].x
div r1.z, -cb9[1].y, r1.z
mul r2.xyz, r1.zzzz, v1.xyzx
div r0.xyz, r2.xyzx, v1.zzzz
dp4 r0.w, cb9[0].xyzw, r0.xyzw
add r1.zw, r0.wwww, l(0.000000, 0.000000, 0.100000, 1.000000)
lt r1.z, r1.z, l(0.000000)
discard_nz r1.z
mad r1.z, -r0.w, cb9[7].x, l(1.000000)
lt r2.x, r1.z, l(0.000000)
discard_nz r2.x
add r2.x, l(-1.000000), cb9[1].z
sample_indexable(texture2d)(float,float,float,float) r2.yz, r1.xyxx, t1.wxyz, s1
sample_indexable(texture2d)(float,float,float,float) r3.xyz, r1.xyxx, t3.xyzw, s3
dp2 r1.x, r2.yzyy, r2.yzyy
add r1.x, -r1.x, l(1.000000)
max r1.x, r1.x, l(0.000000)
sqrt r2.w, r1.x
mul r1.xyw, r1.wwww, r2.yzyw
mad r4.xyz, r1.xywx, r2.xxxx, r0.xyzx
mad r5.xyz, r1.xywx, cb9[1].zzzz, r0.xyzx
mov r4.w, l(1.000000)
dp4 r0.x, cb9[2].xyzw, r4.xyzw
dp4 r0.y, cb9[3].xyzw, r4.xyzw
mul r0.z, r0.w, l(4.000000)
mul r0.w, r0.w, r0.w
mad r0.w, cb9[4].w, r0.w, l(1.000000)
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
mul r0.w, r0.w, r1.z
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t2.wxyz, s2, r0.z
mov r5.w, l(1.000000)
dp4 r1.x, cb9[2].xyzw, r5.xyzw
dp4 r1.y, cb9[3].xyzw, r5.xyzw
sample_l_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t2.xwyz, s2, r0.z
add r0.x, -r0.y, r0.x
mad r0.x, cb9[1].z, r0.x, r0.y
dp3 r0.y, cb9[0].xyzx, r2.yzwy
dp3 r0.z, cb9[4].xyzx, r2.yzwy
add r0.z, r0.z, l(1.000000)
mul r0.z, r0.z, l(0.500000)
max r0.z, r0.z, l(0.000000)
log r0.z, r0.z
mul r0.z, r0.z, cb9[1].w
exp r0.z, r0.z
add r1.xyzw, -cb9[5].wxyz, cb9[6].wxyz
mad_sat r0.y, r0.y, r1.x, cb9[5].w
mad r1.xyz, r0.zzzz, r1.yzwy, cb9[5].xyzx
mul r0.y, r0.w, r0.y
mul r0.yzw, r3.xxyz, r0.yyyy
mul r0.xyz, r0.xxxx, r0.yzwy
mul o0.xyz, r1.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used

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