//P5S onsen water ripples.
// ---- Created with 3Dmigoto v1.3.16 on Sat Mar 19 12:51:15 2022
//
//cbuffer _Globals : register(b0)
//{
//  row_major float4x4 mP2V : packoffset(c0);
//  row_major float4x4 mV2P : packoffset(c4);
//  int nMaxRaySmpl : packoffset(c8);
//  float4 vReflParam : packoffset(c9);
//  float4 vDepthParam : packoffset(c10);
//  float4 vDepthFadeParam : packoffset(c11);
//  float4 vSampleEdgeFadeParam : packoffset(c12);
//}
//
//SamplerState __smpsDepth_s : register(s0);
//SamplerState __smpsScene_s : register(s1);
//SamplerState __smpsSceneNormal_s : register(s2);
//Texture2D<float4> sDepth : register(t0);
//Texture2D<float4> sScene : register(t1);
//Texture2D<float4> sSceneNormal : register(t2);
//
//
//// 3Dmigoto declarations
//#define cmp -
//Texture1D<float4> IniParams : register(t120);
//Texture2D<float4> StereoParams : register(t125);
//
//
//void main(
//  float4 v0 : SV_Position0,
//  float4 v1 : TEXCOORD0,
//  float2 v2 : TEXCOORD1,
//  out float4 o0 : SV_Target0)
//{
//  float4 r0,r1,r2,r3,r4,r5,r6;
//  uint4 bitmask, uiDest;
//  float4 fDest;
//
//  r0.x = sDepth.SampleLevel(__smpsDepth_s, v2.xy, 0).x;
//  r0.y = cmp(0 < r0.x);
//  if (r0.y != 0) {
//    r1.xyzw = mP2V._m10_m11_m12_m13 * v1.yyyy;
//    r1.xyzw = v1.xxxx * mP2V._m00_m01_m02_m03 + r1.xyzw;
//    r1.xyzw = r0.xxxx * mP2V._m20_m21_m22_m23 + r1.xyzw;
//    r1.xyzw = mP2V._m30_m31_m32_m33 + r1.xyzw;
//    r0.yzw = r1.xyz / r1.www;
//    r1.xy = sSceneNormal.Sample(__smpsSceneNormal_s, v2.xy).xy;
//    r1.xy = r1.xy * float2(2,2) + float2(-1,-1);
//    r2.xyz = float3(1,1,1) + -abs(r1.xyx);
//    r3.z = r2.x + -abs(r1.y);
//    r1.z = cmp(r3.z >= 0);
//    r2.xw = cmp(r1.xy >= float2(0,0));
//    r2.xw = r2.xw ? float2(1,1) : float2(-1,-1);
//    r2.xy = r2.yz * r2.xw;
//    r3.xy = r1.zz ? r1.xy : r2.xy;
//    r1.x = dot(r3.xyz, r3.xyz);
//    r1.x = rsqrt(r1.x);
//    r1.xyz = r3.xyz * r1.xxx;
//    r1.w = dot(r0.yzw, r1.xyz);
//    r1.w = r1.w + r1.w;
//    r1.xyz = r1.xyz * -r1.www + r0.yzw;
//    r1.w = dot(r1.xyz, r1.xyz);
//    r1.w = rsqrt(r1.w);
//    r1.w = r1.z * r1.w;
//    r1.w = r1.w * vReflParam.z + vReflParam.w;
//    r2.x = cmp(r1.w < 1);
//    if (r2.x != 0) {
//      r0.yzw = r1.xyz + r0.yzw;
//      r2.xyzw = mV2P._m10_m11_m12_m13 * r0.zzzz;
//      r2.xyzw = r0.yyyy * mV2P._m00_m01_m02_m03 + r2.xyzw;
//      r2.xyzw = r0.wwww * mV2P._m20_m21_m22_m23 + r2.xyzw;
//      r2.xyzw = mV2P._m30_m31_m32_m33 + r2.xyzw;
//      r0.yzw = r2.xyz / r2.www;
//      r1.xy = v1.xy;
//      r1.z = r0.x;
//      r0.yzw = -r1.xyz + r0.yzw;
//      r2.x = vReflParam.y * r0.y;
//      r2.x = max(abs(r2.x), abs(r0.z));
//      r2.x = vReflParam.x / r2.x;
//      r0.yzw = r2.xxx * r0.yzw;
//      r1.xy = v2.xy;
//      r1.xyz = r0.yzw * float3(1,-1,2) + r1.xyz;
//      r1.w = saturate(r1.w);
//      r2.z = 0;
//      r3.xyzw = float4(0,0,0,0);
//      r4.xyz = r1.xyz;
//      r2.w = r0.x;
//      r5.x = 0;
//      while (true) {
//        r5.y = cmp((int)r5.x >= nMaxRaySmpl);
//        if (r5.y != 0) break;
//        r5.y = sDepth.SampleLevel(__smpsDepth_s, r4.xy, 0).x;
//        r5.z = cmp(r5.y >= r4.z);
//        if (r5.z != 0) {
//          r5.z = saturate(r4.z);
//          r5.z = r5.z * vDepthParam.x + vDepthParam.y;
//          r5.z = 1 / r5.z;
//          r5.w = r5.y * vDepthParam.x + vDepthParam.y;
//          r5.w = 1 / r5.w;
//          r4.w = r5.z + -r5.w;
//          r6.xyz = -r0.wyz * float3(1,0.5,-0.5) + r4.zxy;
//          r5.z = cmp(r2.w < r6.x);
//          r5.w = cmp(r2.w >= r4.z);
//          r5.z = r5.w ? r5.z : 0;
//          r6.x = saturate(r6.x);
//          r5.w = r6.x * vDepthParam.x + vDepthParam.y;
//          r5.w = 1 / r5.w;
//          r6.x = r2.w * vDepthParam.x + vDepthParam.y;
//          r6.x = 1 / r6.x;
//          r5.w = r6.x + -r5.w;
//          r6.x = r5.w + r4.w;
//          r5.w = r5.w / r6.x;
//          r6.xw = -r6.yz + r4.xy;
//          r2.xy = r5.ww * r6.xw + r6.yz;
//          r6.xyz = r5.zzz ? r2.xyz : r4.xyw;
//          r2.x = cmp(r6.z < vDepthFadeParam.x);
//          if (r2.x != 0) {
//            r2.x = saturate(r6.z * vDepthFadeParam.y + vDepthFadeParam.z);
//            r3.xyz = sScene.SampleLevel(__smpsScene_s, r6.xy, 0).xyz;
//            r5.zw = float2(-0.5,-0.5) + r6.xy;
//            r2.y = max(abs(r5.z), abs(r5.w));
//            r2.y = saturate(r2.y * vSampleEdgeFadeParam.z + vSampleEdgeFadeParam.w);
//            r4.w = (int)r5.x;
//            r4.w = saturate(r4.w * vSampleEdgeFadeParam.x + vSampleEdgeFadeParam.y);
//            r2.y = max(r2.y, r1.w);
//            r2.x = max(r4.w, r2.x);
//            r2.x = max(r2.y, r2.x);
//            r3.w = 1 + -r2.x;
//            break;
//          }
//          r4.xy = r6.xy;
//        }
//        r4.xyz = r0.yzw * float3(0.5,-0.5,1) + r4.xyz;
//        r2.xy = float2(-0.5,-0.5) + r4.xy;
//        r2.x = max(abs(r2.x), abs(r2.y));
//        r2.x = cmp(0.5 < r2.x);
//        if (r2.x != 0) {
//          r3.xyzw = float4(0,0,0,0);
//          break;
//        }
//        r2.x = cmp(r4.z < 0);
//        if (r2.x != 0) {
//          r3.xyzw = float4(0,0,0,0);
//          break;
//        }
//        r2.w = r5.y;
//        r5.x = (int)r5.x + 1;
//        r3.xyzw = float4(0,0,0,0);
//      }
//      o0.xyzw = r3.xyzw;
//    } else {
//      o0.xyzw = float4(0,0,0,0);
//    }
//  } else {
//    o0.xyzw = float4(0,0,0,0);
//  }
//  return;
//}
//
///*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Sat Mar 19 12:51:15 2022
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   row_major float4x4 mP2V;           // Offset:    0 Size:    64
//   row_major float4x4 mV2P;           // Offset:   64 Size:    64
//   int nMaxRaySmpl;                   // Offset:  128 Size:     4
//   float4 vReflParam;                 // Offset:  144 Size:    16
//   float4 vDepthParam;                // Offset:  160 Size:    16
//   float4 vDepthFadeParam;            // Offset:  176 Size:    16
//   float4 vSampleEdgeFadeParam;       // Offset:  192 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsDepth                       sampler      NA          NA    0        1
// __smpsScene                       sampler      NA          NA    1        1
// __smpsSceneNormal                 sampler      NA          NA    2        1
// sDepth                            texture  float4          2d    0        1
// sScene                            texture  float4          2d    1        1
// sSceneNormal                      texture  float4          2d    2        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xy
// TEXCOORD                 1   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
dcl_constantbuffer cb0[13], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, 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_input_ps linear v1.xy
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 30
dcl_resource_texture2d (float,float,float,float) t125
ld_indexable(texture2d)(float,float,float,float) r25.xyzw, l(0, 0, 0, 0), t125.xyzw
sample_l_indexable(texture2d)(float,float,float,float) r0.x, v2.xyxx, t0.xyzw, s0, l(0.000000)
lt r0.y, l(0.000000), r0.x
if_nz r0.y
  
  mov r26.x, v1.x
  
  mul r21.xyzw, v1.yyyy, cb0[1].xyzw
  mad r21.xyzw, r26.xxxx, cb0[0].xyzw, r21.xyzw
  mad r21.xyzw, r0.xxxx, cb0[2].xyzw, r21.xyzw
  add r21.xyzw, r21.xyzw, cb0[3].xyzw
  add r26.x, -r25.x, r26.x
  mul r11.xyzw, v1.yyyy, cb0[1].xyzw
  mad r11.xyzw, r26.xxxx, cb0[0].xyzw, r11.xyzw
  mad r11.xyzw, r0.xxxx, cb0[2].xyzw, r11.xyzw
  add r11.xyzw, r11.xyzw, cb0[3].xyzw
  div r10.yzw, r11.xxyz, r11.wwww
  mul r29.w, r25.y, r21.w
  mad r26.x, r25.x, r29.w, r26.x
  mul r1.xyzw, v1.yyyy, cb0[1].xyzw
  mad r1.xyzw, r26.xxxx, cb0[0].xyzw, r1.xyzw
  mad r1.xyzw, r0.xxxx, cb0[2].xyzw, r1.xyzw
  add r1.xyzw, r1.xyzw, cb0[3].xyzw
  div r0.yzw, r1.xxyz, r1.wwww
  sample_indexable(texture2d)(float,float,float,float) r1.xy, v2.xyxx, t2.xyzw, s2
  mad r1.xy, r1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
  add r2.xyz, -|r1.xyxx|, l(1.000000, 1.000000, 1.000000, 0.000000)
  add r3.z, -|r1.y|, r2.x
  ge r1.z, r3.z, l(0.000000)
  ge r2.xw, r1.xxxy, l(0.000000, 0.000000, 0.000000, 0.000000)
  movc r2.xw, r2.xxxw, l(1.000000,0,0,1.000000), l(-1.000000,0,0,-1.000000)
  mul r2.xy, r2.xwxx, r2.yzyy
  movc r3.xy, r1.zzzz, r1.xyxx, r2.xyxx
  dp3 r1.x, r3.xyzx, r3.xyzx
  rsq r1.x, r1.x
  mul r1.xyz, r1.xxxx, r3.xyzx
  dp3 r1.w, r10.yzwy, r1.xyzx
  add r1.w, r1.w, r1.w
  mad r1.xyz, r1.xyzx, -r1.wwww, r10.yzwy
  dp3 r1.w, r1.xyzx, r1.xyzx
  rsq r1.w, r1.w
  mul r1.w, r1.w, r1.z
  mad r1.w, r1.w, cb0[9].z, cb0[9].w
  lt r2.x, r1.w, l(1.000000)
  if_nz r2.x
    add r0.yzw, r0.yyzw, r1.xxyz
    mul r2.xyzw, r0.zzzz, cb0[5].xyzw
    mad r2.xyzw, r0.yyyy, cb0[4].xyzw, r2.xyzw
    mad r2.xyzw, r0.wwww, cb0[6].xyzw, r2.xyzw
    add r2.xyzw, r2.xyzw, cb0[7].xyzw
	
	add r25.w, r2.w, -r25.y
	mad r2.x, r25.x, r25.w, r2.x
	
    div r0.yzw, r2.xxyz, r2.wwww
    mov r1.xy, v1.xyxx
    mov r1.z, r0.x
    add r0.yzw, r0.yyzw, -r1.xxyz
    mul r2.x, r0.y, cb0[9].y
    max r2.x, |r0.z|, |r2.x|
    div r2.x, cb0[9].x, r2.x
    mul r0.yzw, r0.yyzw, r2.xxxx
    mov r1.xy, v2.xyxx
    mad r1.xyz, r0.yzwy, l(1.000000, -1.000000, 2.000000, 0.000000), r1.xyzx
    mov_sat r1.w, r1.w
    mov r2.z, l(0)
    mov r3.xyzw, l(0,0,0,0)
    mov r4.xyz, r1.xyzx
    mov r2.w, r0.x
    mov r5.x, l(0)
    loop
      ige r5.y, r5.x, cb0[8].x
      breakc_nz r5.y
      sample_l_indexable(texture2d)(float,float,float,float) r5.y, r4.xyxx, t0.yxzw, s0, l(0.000000)
      ge r5.z, r5.y, r4.z
      if_nz r5.z
        mov_sat r5.z, r4.z
        mad r5.z, r5.z, cb0[10].x, cb0[10].y
        div r5.z, l(1.000000, 1.000000, 1.000000, 1.000000), r5.z
        mad r5.w, r5.y, cb0[10].x, cb0[10].y
        div r5.w, l(1.000000, 1.000000, 1.000000, 1.000000), r5.w
        add r4.w, -r5.w, r5.z
        mad r6.xyz, -r0.wyzw, l(1.000000, 0.500000, -0.500000, 0.000000), r4.zxyz
        lt r5.z, r2.w, r6.x
        ge r5.w, r2.w, r4.z
        and r5.z, r5.w, r5.z
        mov_sat r6.x, r6.x
        mad r5.w, r6.x, cb0[10].x, cb0[10].y
        div r5.w, l(1.000000, 1.000000, 1.000000, 1.000000), r5.w
        mad r6.x, r2.w, cb0[10].x, cb0[10].y
        div r6.x, l(1.000000, 1.000000, 1.000000, 1.000000), r6.x
        add r5.w, -r5.w, r6.x
        add r6.x, r4.w, r5.w
        div r5.w, r5.w, r6.x
        add r6.xw, r4.xxxy, -r6.yyyz
        mad r2.xy, r5.wwww, r6.xwxx, r6.yzyy
        movc r6.xyz, r5.zzzz, r2.xyzx, r4.xywx
        lt r2.x, r6.z, cb0[11].x
        if_nz r2.x
          mad_sat r2.x, r6.z, cb0[11].y, cb0[11].z
          sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r6.xyxx, t1.xyzw, s1, l(0.000000)
          add r5.zw, r6.xxxy, l(0.000000, 0.000000, -0.500000, -0.500000)
          max r2.y, |r5.w|, |r5.z|
          mad_sat r2.y, r2.y, cb0[12].z, cb0[12].w
          itof r4.w, r5.x
          mad_sat r4.w, r4.w, cb0[12].x, cb0[12].y
          max r2.y, r1.w, r2.y
          max r2.x, r2.x, r4.w
          max r2.x, r2.x, r2.y
          add r3.w, -r2.x, l(1.000000)
          break
        endif
        mov r4.xy, r6.xyxx
      endif
      mad r4.xyz, r0.yzwy, l(0.500000, -0.500000, 1.000000, 0.000000), r4.xyzx
      add r2.xy, r4.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
      max r2.x, |r2.y|, |r2.x|
      lt r2.x, l(0.500000), r2.x
      if_nz r2.x
        mov r3.xyzw, l(0,0,0,0)
        break
      endif
      lt r2.x, r4.z, l(0.000000)
      if_nz r2.x
        mov r3.xyzw, l(0,0,0,0)
        break
      endif
      mov r2.w, r5.y
      iadd r5.x, r5.x, l(1)
      mov r3.xyzw, l(0,0,0,0)
    endloop
    mov o0.xyzw, r3.xyzw
  else
    mov o0.xyzw, l(0,0,0,0)
  endif
else
  mov o0.xyzw, l(0,0,0,0)
endif
ret
// Approximately 119 instruction slots used
