//water Swamp  caustics
// ---- Created with 3Dmigoto v0.6.164 on Sat Dec 20 09:07:12 2025
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 cb1 : register(b1)
{
  float4 cb1[1];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[15];
}




// 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,
  float4 v6 : TEXCOORD5,
  float3 v7 : TEXCOORD6,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  // Carga parámetros estéreo
  float4 s = StereoParams.Load(0);
  float4 testeo = IniParams.Load(int2(90,0));  


  r0.xy = v4.xy * cb0[5].xy + cb1[0].xx;
  r0.xyzw = t0.Sample(s3_s, r0.xy).xyzw;
  r0.xy = r0.xy * float2(2,2) + float2(-1,-1);
  r0.xy = cb0[4].xy * r0.xy;

//v2.x += s.x * (v2.w - s.y) * 0.5;   
  
  r0.zw = v2.xy / v2.ww;
  r1.xy = r0.zw * float2(2,2) + float2(-1,-1);
  r2.xyzw = cb0[8].xyzw * r1.yyyy;
  r1.xyzw = cb0[7].xyzw * r1.xxxx + r2.xyzw;
  r2.xyzw = t1.Sample(s1_s, r0.zw).xyzw;
  r1.xyzw = cb0[9].xyzw * r2.xxxx + r1.xyzw;
  r1.xyzw = cb0[10].xyzw + r1.xyzw;
  
  //r1.x += s.x * -cb0[7].x; //convergencia 0
  
r1.x += s.x * (1 - s.y / v2.w) * -cb0[7].x; // cb0[7].x = fov
  
  r1.xyz = r1.xyz / r1.www;
  r2.xy = cb1[0].xx * cb0[6].xy;
  r2.xy = r1.xz * float2(0.0625,0.0625) + r2.xy;
  r1.xyz = v4.xyz + -r1.xyz;
  r1.x = dot(r1.xyz, r1.xyz);
  r1.x = sqrt(r1.x);
  r1.x = saturate(r1.x / cb0[12].z);
  r0.xy = r0.xy * float2(0.0199999996,0.0199999996) + r2.xy;
  r0.xy = cb0[2].zw + r0.xy;
  r2.xyzw = t2.Sample(s0_s, r0.xy).xyzw;
  r0.xy = v4.xz * cb0[5].xy + cb0[5].zw;
  r0.xy = cb1[0].xx + r0.xy;
  r3.xyzw = t0.Sample(s3_s, r0.xy).xyzw;
  r0.xy = r3.xy * float2(2,2) + float2(-1,-1);
  r0.xy = r0.xy * float2(0.920000017,0.920000017) + v4.yz;
  r1.y = cb1[0].x * cb0[12].y;
  r0.xy = r0.xy * float2(10,10) + r1.yy;
  r0.xy = sin(r0.xy);
  r1.y = 0.00100000005 * cb0[12].x;
  r0.xy = r0.xy * r1.yy + r0.zw;
  r0.xyzw = t3.Sample(s2_s, r0.xy).xyzw;
  r0.xyz = cb0[11].www * r0.xyz;
  r0.xyz = r2.xyz * r0.xyz;
  r1.yzw = cb0[14].xyz + -cb0[13].xyz;
  r1.yzw = r1.xxx * r1.yzw + cb0[13].xyz;
  r0.w = 1 + -r1.x;
  o0.xyz = r0.xyz * r0.www + r1.yzw;
  o0.w = cb0[11].z;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v0.6.164 on Sat Dec 20 09:07:12 2025
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float
// TEXCOORD                 1   xyzw        2     NONE   float   xy w
// TEXCOORD                 2   xyzw        3     NONE   float
// TEXCOORD                 3   xyzw        4     NONE   float   xyz
// TEXCOORD                 4   xyz         5     NONE   float
// TEXCOORD                 5   xyz         6     NONE   float
// TEXCOORD                 6   xyz         7     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer CB0[15], immediateIndexed
dcl_constantbuffer CB1[1], 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 v2.xyw
dcl_input_ps linear v4.xyz
dcl_output o0.xyzw
dcl_temps 4
mad r0.xy, v4.xyxx, cb0[5].xyxx, cb1[0].xxxx
sample r0.xyzw, r0.xyxx, t0.xyzw, s3
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, cb0[4].xyxx
div r0.zw, v2.xxxy, v2.wwww
mad r1.xy, r0.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r2.xyzw, r1.yyyy, cb0[8].xyzw
mad r1.xyzw, cb0[7].xyzw, r1.xxxx, r2.xyzw
sample r2.xyzw, r0.zwzz, t1.xyzw, s1
mad r1.xyzw, cb0[9].xyzw, r2.xxxx, r1.xyzw
add r1.xyzw, r1.xyzw, cb0[10].xyzw
div r1.xyz, r1.xyzx, r1.wwww
mul r2.xy, cb0[6].xyxx, cb1[0].xxxx
mad r2.xy, r1.xzxx, l(0.062500, 0.062500, 0.000000, 0.000000), r2.xyxx
add r1.xyz, -r1.xyzx, v4.xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
sqrt r1.x, r1.x
div_sat r1.x, r1.x, cb0[12].z
mad r0.xy, r0.xyxx, l(0.020000, 0.020000, 0.000000, 0.000000), r2.xyxx
add r0.xy, r0.xyxx, cb0[2].zwzz
sample r2.xyzw, r0.xyxx, t2.xyzw, s0
mad r0.xy, v4.xzxx, cb0[5].xyxx, cb0[5].zwzz
add r0.xy, r0.xyxx, cb1[0].xxxx
sample r3.xyzw, r0.xyxx, t0.xyzw, s3
mad r0.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r0.xy, r0.xyxx, l(0.920000, 0.920000, 0.000000, 0.000000), v4.yzyy
mul r1.y, cb0[12].y, cb1[0].x
mad r0.xy, r0.xyxx, l(10.000000, 10.000000, 0.000000, 0.000000), r1.yyyy
sincos r0.xy, null, r0.xyxx
mul r1.y, cb0[12].x, l(0.001000)
mad r0.xy, r0.xyxx, r1.yyyy, r0.zwzz
sample r0.xyzw, r0.xyxx, t3.xyzw, s2
mul r0.xyz, r0.xyzx, cb0[11].wwww
mul r0.xyz, r0.xyzx, r2.xyzx
add r1.yzw, -cb0[13].xxyz, cb0[14].xxyz
mad r1.yzw, r1.xxxx, r1.yyzw, cb0[13].xxyz
add r0.w, -r1.x, l(1.000000)
mad o0.xyz, r0.xyzx, r0.wwww, r1.yzwy
mov o0.w, cb0[11].z
ret
// Approximately 0 instruction slots used

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