//Pucci wave effect PS.
// ---- Created with 3Dmigoto v1.3.16 on Sun Sep 04 17:38:31 2022

SamplerState g_samplerRefNormal_s : register(s0);
SamplerState g_samplerRefScene_s : register(s2);
SamplerState g_samplerRefPostEff_s : register(s3);
SamplerState g_samplerRefDepth_s : register(s4);
Texture2D<float4> g_textureRefNormal : register(t0);
Texture2D<float4> g_textureRefScene : register(t2);
Texture2D<float4> g_textureRefPostEff : register(t3);
Texture2D<float4> g_textureRefDepth : register(t4);


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


void main(
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float4 v2 : TEXCOORD1,
  float4 v3 : TEXCOORD2,
  float4 v4 : TEXCOORD3,
  float4 v5 : TEXCOORD4,
  float2 v6 : COLOR0,
  float w6 : TEXCOORD5,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xy = v1.xy * v3.zw + v3.xy;
  r0.xyzw = g_textureRefNormal.Sample(g_samplerRefNormal_s, r0.xy).xyzw;
  r0.zw = v1.yx * v4.wz + v4.yx;
  r1.xyzw = g_textureRefNormal.Sample(g_samplerRefNormal_s, r0.zw).xyzw;
  r0.xy = r1.xy + r0.xy;
  r0.xy = float2(-1,-1) + r0.xy;
  r0.xy = v2.xy * r0.xy;
  r0.zw = v1.zw * v5.zw + v5.xy;
  
  //r0.z-=stereo.x*(0-stereo.y/v0.w)*0.1;
  
  r1.xyzw = g_textureRefNormal.Sample(g_samplerRefNormal_s, r0.zw).xyzw;
  r0.xy = r1.ww * r0.xy;
  r0.xy = r0.xy + r0.xy;
  r0.z = -r0.y;
  r0.xy = v0.xy * v2.zw + r0.xz;
  
  //r0.x-=stereo.x*(0-stereo.y/v0.w)*0.1;
  
  r1.xyzw = g_textureRefDepth.Sample(g_samplerRefDepth_s, r0.xy).xyzw;
  r0.z = cmp(v0.z < r1.x);
  r1.xy = v2.zw * v0.xy;
  r0.xy = r0.zz ? r0.xy : r1.xy;
  r1.xyzw = g_textureRefScene.Sample(g_samplerRefScene_s, r0.xy).xyzw;
  r0.xyzw = g_textureRefPostEff.Sample(g_samplerRefPostEff_s, r0.xy).xyzw;
  o1.xyz = r0.xyz;
  o0.xyz = r1.xyz;
  o0.w = v6.y;
  o1.w = v6.y;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Sun Sep 04 17:38:31 2022
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_samplerRefNormal                sampler      NA          NA    0        1
// g_samplerRefScene                 sampler      NA          NA    2        1
// g_samplerRefPostEff               sampler      NA          NA    3        1
// g_samplerRefDepth                 sampler      NA          NA    4        1
// g_textureRefNormal                texture  float4          2d    0        1
// g_textureRefScene                 texture  float4          2d    2        1
// g_textureRefPostEff               texture  float4          2d    3        1
// g_textureRefDepth                 texture  float4          2d    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyz
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// COLOR                    0   xy          6     NONE   float    y
// TEXCOORD                 5     z         6     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_4_0
dcl_sampler s0, 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) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_input_ps_siv linear noperspective v0.xyz, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.y
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 2
mad r0.xy, v1.xyxx, v3.zwzz, v3.xyxx
sample r0.xyzw, r0.xyxx, t0.xyzw, s0
mad r0.zw, v1.yyyx, v4.wwwz, v4.yyyx
sample r1.xyzw, r0.zwzz, t0.xyzw, s0
add r0.xy, r0.xyxx, r1.xyxx
add r0.xy, r0.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, v2.xyxx
mad r0.zw, v1.zzzw, v5.zzzw, v5.xxxy
sample r1.xyzw, r0.zwzz, t0.xyzw, s0
mul r0.xy, r0.xyxx, r1.wwww
add r0.xy, r0.xyxx, r0.xyxx
mov r0.z, -r0.y
mad r0.xy, v0.xyxx, v2.zwzz, r0.xzxx
sample r1.xyzw, r0.xyxx, t4.xyzw, s4
lt r0.z, v0.z, r1.x
mul r1.xy, v0.xyxx, v2.zwzz
movc r0.xy, r0.zzzz, r0.xyxx, r1.xyxx
sample r1.xyzw, r0.xyxx, t2.xyzw, s2
sample r0.xyzw, r0.xyxx, t3.xyzw, s3
mov o1.xyz, r0.xyzx
mov o0.xyz, r1.xyzx
mov o0.w, v6.y
mov o1.w, v6.y
ret
// Approximately 24 instruction slots used

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