//Light shafts PS 1.
// ---- Created with geo-11 v0.6.193 on Sun May 19 23:45:25 2024

cbuffer CBPerViewGlobal : register(b13)
{
  row_major float4x4 CV_ViewProjZeroMatr : packoffset(c0);
  float4 CV_AnimGenParams : packoffset(c4);
  row_major float4x4 CV_ViewProjMatr : packoffset(c5);
  row_major float4x4 CV_ViewProjNearestMatr : packoffset(c9);
  row_major float4x4 CV_InvViewProj : packoffset(c13);
  row_major float4x4 CV_PrevViewProjMatr : packoffset(c17);
  row_major float4x4 CV_PrevViewProjNearestMatr : packoffset(c21);
  row_major float3x4 CV_ScreenToWorldBasis : packoffset(c25);
  float4 CV_TessInfo : packoffset(c28);
  float4 CV_CameraRightVector : packoffset(c29);
  float4 CV_CameraFrontVector : packoffset(c30);
  float4 CV_CameraUpVector : packoffset(c31);
  float4 CV_ScreenSize : packoffset(c32);
  float4 CV_HPosScale : packoffset(c33);
  float4 CV_HPosClamp : packoffset(c34);
  float4 CV_ProjRatio : packoffset(c35);
  float4 CV_NearestScaled : packoffset(c36);
  float4 CV_NearFarClipDist : packoffset(c37);
  float4 CV_SunLightDir : packoffset(c38);
  float4 CV_SunColor : packoffset(c39);
  float4 CV_SkyColor : packoffset(c40);
  float4 CV_FogColor : packoffset(c41);
  float4 CV_TerrainInfo : packoffset(c42);
  float4 CV_DecalZFightingRemedy : packoffset(c43);
  row_major float4x4 CV_FrustumPlaneEquation : packoffset(c44);
  float4 CV_WindGridOffset : packoffset(c48);
  row_major float4x4 CV_ViewMatr : packoffset(c49);
  row_major float4x4 CV_InvViewMatr : packoffset(c53);
  float CV_LookingGlass_SunSelector : packoffset(c57);
  float CV_LookingGlass_DepthScalar : packoffset(c57.y);
  float CV_PADDING0 : packoffset(c57.z);
  float CV_PADDING1 : packoffset(c57.w);
}

cbuffer CBSunShafts : register(b0)
{

  struct
  {
    float4 sunPos;
    float4 params;
  } cbSunShafts : packoffset(c0);

}

SamplerState _tex0_s : register(s0);
Texture2D<float4> _tex0 : register(t0);


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


void main(
  float4 v0 : SV_Position0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xy = CV_HPosScale.xy * v1.xy;
  r0.xyzw = _tex0.Sample(_tex0_s, r0.xy).xyzw;
  r1.x = cbSunShafts.params.x * cbSunShafts.sunPos.w;
  r1.yz = cbSunShafts.sunPos.xy + -v1.xy;
  
  r1.y+=stereo.x*0.5;
  
  r2.xy = r1.yz * r1.xx + v1.xy;
  r1.xw = r1.yz * r1.xx;
  r2.xy = CV_HPosScale.xy * r2.xy;
  r2.xyzw = _tex0.Sample(_tex0_s, r2.xy).xyzw;
  r0.xyzw = r2.xyzw * float4(0.875,0.875,0.875,0.875) + r0.xyzw;
  r2.xy = r1.xw * float2(2,2) + v1.xy;
  r2.xy = CV_HPosScale.xy * r2.xy;
  r2.xyzw = _tex0.Sample(_tex0_s, r2.xy).xyzw;
  r0.xyzw = r2.xyzw * float4(0.75,0.75,0.75,0.75) + r0.xyzw;
  r2.xyzw = r1.xwxw * float4(3,3,4,4) + v1.xyxy;
  r2.xyzw = CV_HPosScale.xyxy * r2.xyzw;
  r3.xyzw = _tex0.Sample(_tex0_s, r2.xy).xyzw;
  r2.xyzw = _tex0.Sample(_tex0_s, r2.zw).xyzw;
  r0.xyzw = r3.xyzw * float4(0.625,0.625,0.625,0.625) + r0.xyzw;
  r0.xyzw = r2.xyzw * float4(0.5,0.5,0.5,0.5) + r0.xyzw;
  r2.xyzw = r1.xwxw * float4(5,5,6,6) + v1.xyxy;
  r1.xw = r1.xw * float2(7,7) + v1.xy;
  r1.xw = CV_HPosScale.xy * r1.xw;
  r3.xyzw = _tex0.Sample(_tex0_s, r1.xw).xyzw;
  r2.xyzw = CV_HPosScale.xyxy * r2.xyzw;
  r4.xyzw = _tex0.Sample(_tex0_s, r2.xy).xyzw;
  r2.xyzw = _tex0.Sample(_tex0_s, r2.zw).xyzw;
  r0.xyzw = r4.xyzw * float4(0.375,0.375,0.375,0.375) + r0.xyzw;
  r0.xyzw = r2.xyzw * float4(0.25,0.25,0.25,0.25) + r0.xyzw;
  r0.xyzw = r3.xyzw * float4(0.125,0.125,0.125,0.125) + r0.xyzw;
  r0.xyzw = float4(0.25,0.25,0.25,1) * r0.xyzw;
  r1.xw = CV_HPosScale.xy * CV_ScreenSize.yx;
  r1.x = 1.33299994 * r1.x;
  r2.y = r1.x / r1.w;
  r2.x = 1;
  r1.xy = r2.xy * r1.yz;
  r1.x = dot(r1.xy, r1.xy);
  r1.x = sqrt(r1.x);
  r1.x = saturate(cbSunShafts.params.y * r1.x);
  r1.x = 1 + -r1.x;
  r1.y = saturate(cbSunShafts.sunPos.w);
  r1.xyz = r1.yyy * r1.xxx;
  r0.xyz = r1.xyz * r0.xyz;
  o0.xyz = r0.xyz;
  r0.x = saturate(cbSunShafts.sunPos.w * 0.100000001 + 0.899999976);
  r0.x = 1 + -r0.x;
  r0.y = 0.25;
  o0.w = r0.w * r0.y + r0.x;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v0.6.193 on Sun May 19 23:45:25 2024
//
//
// Buffer Definitions:
//
// cbuffer CBPerViewGlobal
// {
//
//   row_major float4x4 CV_ViewProjZeroMatr;// Offset:    0 Size:    64 [unused]
//   float4 CV_AnimGenParams;           // Offset:   64 Size:    16 [unused]
//   row_major float4x4 CV_ViewProjMatr;// Offset:   80 Size:    64 [unused]
//   row_major float4x4 CV_ViewProjNearestMatr;// Offset:  144 Size:    64 [unused]
//   row_major float4x4 CV_InvViewProj; // Offset:  208 Size:    64 [unused]
//   row_major float4x4 CV_PrevViewProjMatr;// Offset:  272 Size:    64 [unused]
//   row_major float4x4 CV_PrevViewProjNearestMatr;// Offset:  336 Size:    64 [unused]
//   row_major float3x4 CV_ScreenToWorldBasis;// Offset:  400 Size:    48 [unused]
//   float4 CV_TessInfo;                // Offset:  448 Size:    16 [unused]
//   float4 CV_CameraRightVector;       // Offset:  464 Size:    16 [unused]
//   float4 CV_CameraFrontVector;       // Offset:  480 Size:    16 [unused]
//   float4 CV_CameraUpVector;          // Offset:  496 Size:    16 [unused]
//   float4 CV_ScreenSize;              // Offset:  512 Size:    16
//   float4 CV_HPosScale;               // Offset:  528 Size:    16
//   float4 CV_HPosClamp;               // Offset:  544 Size:    16 [unused]
//   float4 CV_ProjRatio;               // Offset:  560 Size:    16 [unused]
//   float4 CV_NearestScaled;           // Offset:  576 Size:    16 [unused]
//   float4 CV_NearFarClipDist;         // Offset:  592 Size:    16 [unused]
//   float4 CV_SunLightDir;             // Offset:  608 Size:    16 [unused]
//   float4 CV_SunColor;                // Offset:  624 Size:    16 [unused]
//   float4 CV_SkyColor;                // Offset:  640 Size:    16 [unused]
//   float4 CV_FogColor;                // Offset:  656 Size:    16 [unused]
//   float4 CV_TerrainInfo;             // Offset:  672 Size:    16 [unused]
//   float4 CV_DecalZFightingRemedy;    // Offset:  688 Size:    16 [unused]
//   row_major float4x4 CV_FrustumPlaneEquation;// Offset:  704 Size:    64 [unused]
//   float4 CV_WindGridOffset;          // Offset:  768 Size:    16 [unused]
//   row_major float4x4 CV_ViewMatr;    // Offset:  784 Size:    64 [unused]
//   row_major float4x4 CV_InvViewMatr; // Offset:  848 Size:    64 [unused]
//   float CV_LookingGlass_SunSelector; // Offset:  912 Size:     4 [unused]
//   float CV_LookingGlass_DepthScalar; // Offset:  916 Size:     4 [unused]
//   float CV_PADDING0;                 // Offset:  920 Size:     4 [unused]
//   float CV_PADDING1;                 // Offset:  924 Size:     4 [unused]
//
// }
//
// cbuffer CBSunShafts
// {
//
//   struct <unnamed>
//   {
//
//       float4 sunPos;                 // Offset:    0
//       float4 params;                 // Offset:   16
//
//   } cbSunShafts;                     // Offset:    0 Size:    32
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// _tex0                             sampler      NA          NA    0        1
// _tex0                             texture  float4          2d    0        1
// CBSunShafts                       cbuffer      NA          NA    0        1
// CBPerViewGlobal                   cbuffer      NA          NA   13        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     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 CB13[34], immediateIndexed
dcl_constantbuffer CB0[2], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 5
mul r0.xy, v1.xyxx, cb13[33].xyxx
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t0.xyzw, s0
mul r1.x, cb0[0].w, cb0[1].x
add r1.yz, -v1.xxyx, cb0[0].xxyx
mad r2.xy, r1.yzyy, r1.xxxx, v1.xyxx
mul r1.xw, r1.xxxx, r1.yyyz
mul r2.xy, r2.xyxx, cb13[33].xyxx
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t0.xyzw, s0
mad r0.xyzw, r2.xyzw, l(0.875000, 0.875000, 0.875000, 0.875000), r0.xyzw
mad r2.xy, r1.xwxx, l(2.000000, 2.000000, 0.000000, 0.000000), v1.xyxx
mul r2.xy, r2.xyxx, cb13[33].xyxx
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t0.xyzw, s0
mad r0.xyzw, r2.xyzw, l(0.750000, 0.750000, 0.750000, 0.750000), r0.xyzw
mad r2.xyzw, r1.xwxw, l(3.000000, 3.000000, 4.000000, 4.000000), v1.xyxy
mul r2.xyzw, r2.xyzw, cb13[33].xyxy
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r2.xyxx, t0.xyzw, s0
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.zwzz, t0.xyzw, s0
mad r0.xyzw, r3.xyzw, l(0.625000, 0.625000, 0.625000, 0.625000), r0.xyzw
mad r0.xyzw, r2.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000), r0.xyzw
mad r2.xyzw, r1.xwxw, l(5.000000, 5.000000, 6.000000, 6.000000), v1.xyxy
mad r1.xw, r1.xxxw, l(7.000000, 0.000000, 0.000000, 7.000000), v1.xxxy
mul r1.xw, r1.xxxw, cb13[33].xxxy
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r1.xwxx, t0.xyzw, s0
mul r2.xyzw, r2.xyzw, cb13[33].xyxy
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.xyxx, t0.xyzw, s0
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.zwzz, t0.xyzw, s0
mad r0.xyzw, r4.xyzw, l(0.375000, 0.375000, 0.375000, 0.375000), r0.xyzw
mad r0.xyzw, r2.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000), r0.xyzw
mad r0.xyzw, r3.xyzw, l(0.125000, 0.125000, 0.125000, 0.125000), r0.xyzw
mul r0.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 1.000000)
mul r1.xw, cb13[32].yyyx, cb13[33].xxxy
mul r1.x, r1.x, l(1.333000)
div r2.y, r1.x, r1.w
mov r2.x, l(1.000000)
mul r1.xy, r1.yzyy, r2.xyxx
dp2 r1.x, r1.xyxx, r1.xyxx
sqrt r1.x, r1.x
mul_sat r1.x, r1.x, cb0[1].y
add r1.x, -r1.x, l(1.000000)
mov_sat r1.y, cb0[0].w
mul r1.xyz, r1.xxxx, r1.yyyy
mul r0.xyz, r0.xyzx, r1.xyzx
mov o0.xyz, r0.xyzx
mad_sat r0.x, cb0[0].w, l(0.100000), l(0.900000)
add r0.x, -r0.x, l(1.000000)
mov r0.y, l(0.250000)
mad o0.w, r0.w, r0.y, r0.x
ret
// Approximately 48 instruction slots used

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