//Shadows PS. Different kind, at the borders of some geometry.
// ---- Created with geo-11 v0.6.193 on Fri May 24 20:57:20 2024

cbuffer CBClipVolume : register(b0)
{

  struct
  {
    row_major float4x4 transformMatrix;
    float4 projRatioScreenScale;
    float4 blendPlane0;
    float4 blendPlane1;
    float2 screenScale;
    float LG_SceneSelector;
    float _padding;
  } cbClipVolume : packoffset(c0);

}

cbuffer CBPerViewGlobal : register(b7)
{
  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);
}

Texture2D<float4> DepthTex : register(t3);


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


void main(
  float4 v0 : SV_POSITION0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r10;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xy = (int2)v0.xy;
  r0.zw = float2(0,0);
  r0.x = DepthTex.Load(r0.xyz).x;
  
  r10.x = r0.x * CV_NearFarClipDist.y;
  
  r0.x = cbClipVolume.projRatioScreenScale.y / r0.x;
  r0.z = cbClipVolume.projRatioScreenScale.x + r0.x;
  r1.xy = cbClipVolume.projRatioScreenScale.zw * v0.xy;
  r1.xy = r1.xy / cbClipVolume.screenScale.xy;
  
  r1.x+=stereo.x*(stereo.y/r10.x-1)*0.5;
  
  r1.xy = r1.xy + r1.xy;
  r0.xy = r1.xy * float2(1,-1) + float2(-1,1);
  r0.w = 1;
  r1.x = dot(cbClipVolume.blendPlane1.xyzw, r0.xyzw);
  r0.x = dot(cbClipVolume.blendPlane0.xyzw, r0.xyzw);
  r0.x = max(0, r0.x);
  r0.y = max(0, r1.x);
  r0.y = r0.x + r0.y;
  r0.y = max(9.99999975e-06, r0.y);
  o0.xyzw = r0.xxxx / r0.yyyy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v0.6.193 on Fri May 24 20:57:20 2024
//
//
// Buffer Definitions:
//
// cbuffer CBClipVolume
// {
//
//   struct ClipVolumeConstants
//   {
//
//       row_major float4x4 transformMatrix;// Offset:    0
//       float4 projRatioScreenScale;   // Offset:   64
//       float4 blendPlane0;            // Offset:   80
//       float4 blendPlane1;            // Offset:   96
//       float2 screenScale;            // Offset:  112
//       float LG_SceneSelector;        // Offset:  120
//       float _padding;                // Offset:  124
//
//   } cbClipVolume;                    // Offset:    0 Size:   128
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// DepthTex                          texture  float4          2d    3        1
// CBClipVolume                      cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   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[8], immediateIndexed
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 2
ftoi r0.xy, v0.xyxx
mov r0.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.x, r0.xyzw, t3.xyzw
div r0.x, cb0[4].y, r0.x
add r0.z, r0.x, cb0[4].x
mul r1.xy, v0.xyxx, cb0[4].zwzz
div r1.xy, r1.xyxx, cb0[7].xyxx
add r1.xy, r1.xyxx, r1.xyxx
mad r0.xy, r1.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
mov r0.w, l(1.000000)
dp4 r1.x, cb0[6].xyzw, r0.xyzw
dp4 r0.x, cb0[5].xyzw, r0.xyzw
max r0.x, r0.x, l(0.000000)
max r0.y, r1.x, l(0.000000)
add r0.y, r0.y, r0.x
max r0.y, r0.y, l(0.000010)
div o0.xyzw, r0.xxxx, r0.yyyy
ret
// Approximately 18 instruction slots used

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