//clouds and more things
// ---- Created with 3Dmigoto v0.6.164 on Mon Dec 29 16:34:41 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[8];
}

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




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


void main(
  float4 v0 : SV_POSITION0,
  float2 v1 : TEXCOORD0,
  float2 w1 : TEXCOORD1,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 s = StereoParams.Load(0);
float4 testeo = IniParams.Load(int2(90,0));   


  r0.xy = w1.xy * cb0[2].xy + cb0[2].zw;
  r0.xyzw = t0.Sample(s0_s, r0.xy).xyzw;
  r1.xy = w1.xy * cb0[4].xy + cb0[4].zw;
  r1.xyzw = t1.Sample(s1_s, r1.xy).xyzw;
  r1.x = cb1[7].x * r1.x + cb1[7].y;
  r1.x = 1 / r1.x;
  r1.x = cmp(0.999899983 < r1.x);
  if (r1.x != 0) {
    r1.xy = cb0[40].xy * v1.xy;
    r1.xy = floor(r1.xy);
    r1.xy = r1.xy / cb0[39].yy;
    r1.zw = cmp(r1.xy >= -r1.xy);
    r1.xy = frac(abs(r1.xy));
    r1.xy = r1.zw ? r1.xy : -r1.xy;
    r1.x = cb0[39].y * r1.x;
    r1.z = cb0[39].y * cb0[39].y;
    r1.x = r1.z * r1.y + r1.x;
    r1.x = cmp(r1.x == cb0[39].x);
    if (r1.x != 0) {
      r1.xy = cb0[39].zw * v1.xy;
      r1.xy = floor(r1.xy);
      r1.xy = float2(0.5,0.5) + r1.xy;
      r1.xy = r1.xy / cb0[39].zw;
      r1.xy = r1.xy * cb0[2].xy + cb0[2].zw;
	  r1.xyzw = t2.Sample(s2_s, r1.xy).xyzw;
    } else {
      r2.xy = v1.xy * float2(2,2) + float2(-1,-1);
      r3.xyzw = cb0[16].xyzw * r2.yyyy;
      r2.xyzw = cb0[15].xyzw * r2.xxxx + r3.xyzw;
      r2.xyzw = cb0[17].xyzw + r2.xyzw;
      r2.xyzw = cb0[18].xyzw + r2.xyzw;
	  r2.xyzw = r2.xyzw / r2.wwww;
      r3.xyz = cb0[24].xyz * r2.yyy;
      r3.xyz = cb0[23].xyz * r2.xxx + r3.xyz;
      r2.xyz = cb0[25].xyz * r2.zzz + r3.xyz;
      r3.xyz = cb0[32].xyz * r2.yyy;
      r3.xyz = cb0[31].xyz * r2.xxx + r3.xyz;
      r2.xyz = cb0[33].xyz * r2.zzz + r3.xyz;
      r3.xy = cb0[8].xy * r2.yy;
      r2.xy = cb0[7].xy * r2.xx + r3.xy;
      r2.xy = cb0[9].xy * r2.zz + r2.xy;
      r2.xy = cb0[10].xy * r2.ww + r2.xy;
      r2.zw = cmp(r2.yx < float2(0,0));
      r3.xy = cmp(float2(1,1) < r2.yx);
      r2.z = (int)r2.z | (int)r3.x;
      r2.z = (int)r2.w | (int)r2.z;
      r2.z = (int)r3.y | (int)r2.z;
      if (r2.z != 0) {
        r2.zw = v1.xy * cb0[2].xy + cb0[2].zw;
				
		 r2.z -= s.x * 0.5;  //clouds push to infinite
		
        r1.xyzw = t2.Sample(s2_s, r2.zw).xyzw;
      } else {
        r2.xy = r2.xy * cb0[2].xy + cb0[2].zw;
        r1.xyzw = t3.Sample(s3_s, r2.xy).xyzw;
      }
    }
    r2.x = 1 + -r1.w;
    r1.xyz = r1.xyz * r1.www;
    o0.xyz = r0.xyz * r2.xxx + r1.xyz;
    o0.w = 1;
  } else {
    o0.xyzw = r0.xyzw;
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v0.6.164 on Mon Dec 29 16:34:41 2025
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float   xy
// TEXCOORD                 1     zw        1     NONE   float     zw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer CB0[41], immediateIndexed
dcl_constantbuffer CB1[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 v1.xy
dcl_input_ps linear v1.zw
dcl_output o0.xyzw
dcl_temps 4
mad r0.xy, v1.zwzz, cb0[2].xyxx, cb0[2].zwzz
sample r0.xyzw, r0.xyxx, t0.xyzw, s0
mad r1.xy, v1.zwzz, cb0[4].xyxx, cb0[4].zwzz
sample r1.xyzw, r1.xyxx, t1.xyzw, s1
mad r1.x, cb1[7].x, r1.x, cb1[7].y
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
lt r1.x, l(0.999900), r1.x
if_nz r1.x
  mul r1.xy, v1.xyxx, cb0[40].xyxx
  round_ni r1.xy, r1.xyxx
  div r1.xy, r1.xyxx, cb0[39].yyyy
  ge r1.zw, r1.xxxy, -r1.xxxy
  frc r1.xy, |r1.xyxx|
  movc r1.xy, r1.zwzz, r1.xyxx, -r1.xyxx
  mul r1.x, r1.x, cb0[39].y
  mul r1.z, cb0[39].y, cb0[39].y
  mad r1.x, r1.z, r1.y, r1.x
  eq r1.x, r1.x, cb0[39].x
  if_nz r1.x
    mul r1.xy, v1.xyxx, cb0[39].zwzz
    round_ni r1.xy, r1.xyxx
    add r1.xy, r1.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
    div r1.xy, r1.xyxx, cb0[39].zwzz
    mad r1.xy, r1.xyxx, cb0[2].xyxx, cb0[2].zwzz
    sample r1.xyzw, r1.xyxx, t2.xyzw, s2
  else
    mad r2.xy, v1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
    mul r3.xyzw, r2.yyyy, cb0[16].xyzw
    mad r2.xyzw, cb0[15].xyzw, r2.xxxx, r3.xyzw
    add r2.xyzw, r2.xyzw, cb0[17].xyzw
    add r2.xyzw, r2.xyzw, cb0[18].xyzw
    div r2.xyzw, r2.xyzw, r2.wwww
    mul r3.xyz, r2.yyyy, cb0[24].xyzx
    mad r3.xyz, cb0[23].xyzx, r2.xxxx, r3.xyzx
    mad r2.xyz, cb0[25].xyzx, r2.zzzz, r3.xyzx
    mul r3.xyz, r2.yyyy, cb0[32].xyzx
    mad r3.xyz, cb0[31].xyzx, r2.xxxx, r3.xyzx
    mad r2.xyz, cb0[33].xyzx, r2.zzzz, r3.xyzx
    mul r3.xy, r2.yyyy, cb0[8].xyxx
    mad r2.xy, cb0[7].xyxx, r2.xxxx, r3.xyxx
    mad r2.xy, cb0[9].xyxx, r2.zzzz, r2.xyxx
    mad r2.xy, cb0[10].xyxx, r2.wwww, r2.xyxx
    lt r2.zw, r2.yyyx, l(0.000000, 0.000000, 0.000000, 0.000000)
    lt r3.xy, l(1.000000, 1.000000, 0.000000, 0.000000), r2.yxyy
    or r2.z, r2.z, r3.x
    or r2.z, r2.w, r2.z
    or r2.z, r3.y, r2.z
    if_nz r2.z
      mad r2.zw, v1.xxxy, cb0[2].xxxy, cb0[2].zzzw
      sample r1.xyzw, r2.zwzz, t2.xyzw, s2
    else
      mad r2.xy, r2.xyxx, cb0[2].xyxx, cb0[2].zwzz
      sample r1.xyzw, r2.xyxx, t3.xyzw, s3
    endif
  endif
  add r2.x, -r1.w, l(1.000000)
  mul r1.xyz, r1.wwww, r1.xyzx
  mad o0.xyz, r0.xyzx, r2.xxxx, r1.xyzx
  mov o0.w, l(1.000000)
else
  mov o0.xyzw, r0.xyzw
endif
ret
// Approximately 0 instruction slots used

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