//MASSIVE BLUR FILTRER -> FIXED - GENERATES HALOS
//SHARPEN FILTER
#version 450
struct S_MOTION_INFO
{
    mat4 _mTransform[2];
    vec4 _vfViewport;
};

struct S_PASS_MATRICES
{
    mat4 _mViewJitteredProj;
    mat4 _mViewProj;
    mat4 _mView;
    mat4 _mInvView;
    mat4 _mJitteredProj;
};

struct S_EYE_DATA
{
    S_PASS_MATRICES _mCurrentFrameMatrices[2];
    S_PASS_MATRICES _mPreviousFrameMatrices[2];
    mat4 _mJitteredProjection[2];
    mat4 _mNoJitterProjection[2];
    mat4 _mInvViewJitteredProj[2];
    vec4 _vWorldSpaceCameraVector[2];
    vec4 _vWorldSpaceCameraPosition[2];
    vec4 _vFrameBufferScale;
    vec4 _vFrameBufferViewportSize;
    vec4 _vFrameBufferOneOnViewportSize;
    vec4 _vViewportSize;
    vec4 _vFogSubCrop;
    uint _uiAlignment0;
    uint _uiAlignment1;
    float _vCameraJitterDeltaX;
    float _vCameraJitterDeltaY;
    vec4 _vfRcpFVolumetricFogDepthTileSize;
};

struct S_CASCADED_SHADOW
{
    mat4 _mCascadeMatrix[2][8];
    mat4 _mViewSpaceToStaticShadowMapSpace[2];
    vec4 _vfCascadeShadowAttenuation;
    vec4 _vfShadowCascadeTextureTexelSize;
    vec4 _vfStaticShadowBlurRadius;
    vec4 _vfCascadeLinearZProjFactors[8];
    vec4 _vfCascadeParams[8];
};

struct S_CLUSTER_LIGHT_SETUP
{
    S_CASCADED_SHADOW _CascadedShadow;
    vec4 _vfSkinUVParamsAndNormalBias;
    vec4 _vfShadowTextureTexelSize;
    vec4 _vfDummy_SkinFresnelF0AndF90;
    uint _uiCascadedUsed;
    float _fSSSWidth;
    float _fOffsetBias;
    float _fDummy;
};

struct S_CLUSTER_INFO
{
    mat4 _mViewToClusterView[2];
    mat4 _mClusterProjMatrix;
    mat4 _mClusterInvProjMatrix;
    vec4 _vfLeftEyeToCombinedEyeVsDeltaXZ;
    uint _uiFinestMipWidth;
    uint _uiFinestMipHeight;
    uint _uiFinestMipDepth;
    uint _uiFinestMipWidthHeight;
    float _fZSliceGeomFactor;
    float _fRcpLogZSliceGeomFactor;
    float _fDummy0;
    float _fDummy1;
    float _fNearP;
    float _fInvNearP;
    float _fFarP;
    float _fClusterCoincidentWithCamera;
};

struct S_PASS
{
    S_EYE_DATA _EyeData;
    vec4 _avFrustumCorners[4];
    vec4 _vTime;
    vec4 _cFogColor;
    vec4 _vFogSetup;
    vec4 _cSunColor;
    vec4 _vSunDir;
    vec4 _vProjectionSetup;
    vec4 _vProjectionCoeff;
    vec4 _vOutputColor;
    vec4 _vfVsClippingPlane[2];
    S_CLUSTER_LIGHT_SETUP _LightSetup;
    S_CLUSTER_INFO _ClusterInfo;
    float _fIBLIntensity;
    float _fGIIntensity;
    float _fAmbiantOcclusionDirectIntensity;
    float _fAmbiantOcclusionIndirectIntensity;
    float _fNormalSign;
    int _iFogType;
    float _fSelfOcclusionDebugRatio;
    float _fEmissive;
    int _iEnableSkinSSSSS;
    int _iUseHairOpaquePrepass;
    float _fLocalSceneExposure;
    uint _uiDebugMode;
    uint _sFlags;
    float _fTAADropsSharpness;
    uint _uNeoScaleX;
    uint _uNeoScaleY;
    uint _uiDirectOverdrawFilter;
    float _fCoderTest0;
    float _fCoderTest1;
    float _fCoderTest2;
    uint _uiBakeOutput;
    float _fDefaultAmbientIntensity;
    float _fDefaultLightingIntensity;
    uint _uiOutputColor;
    float _fAARotation;
    float _fClampDirectSpecular;
    float _fNearPlane;
    float _fFarPlane;
    float _fNDFFilteringScreenSpaceVariance;
    float _fNDFFilteringThreshold;
    float _fNDFFilteringScreenSpaceVariance_EyeShader;
    float _fNDFFilteringThreshold_EyeShader;
    float _fSurfaceGradientTextureFiltering;
    float _fZero;
    uint _uDepthClamp;
    uint _uiLightDebugMode;
    vec4 _vfFragCoordToDepthTexFactor;
    vec4 _vfFragCoordToDepthTexFactor_HalfRes;
    uint _uHdr;
    uint _uiDrawMayaSwatch;
    float _fEyeRoughnessBias;
    float _fDummy1;
};


// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
layout(set = 0, binding = 99, std140) uniform Vk3DParams
{
    vec4 stereo;
    vec4 custom_params;
}
 vk3d_params;

layout(set = 0, binding = 53, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_1
{
    S_MOTION_INFO g_cbMotionInfo;
} _133;

layout(set = 0, binding = 54, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_2
{
    S_PASS g_cbPass;
} _215;

layout(set = 0, binding = 1) uniform sampler2D g_tsDepth;
layout(set = 0, binding = 0) uniform sampler2D g_tsMotion;

layout(location = 8) in vec2 in_TexCoord;
layout(location = 0) out vec4 out_Color;

void main()
{
    //TO FIX PROPERLY?!?!
    //out_Color = vec4(1);
    //return;

    vec4 _163 = texture(g_tsMotion, in_TexCoord);
    bool _170 = _163.x == 0.0;
    bool _177;
    if (_170)
    {
        _177 = _163.y == 0.0;
    }
    else
    {
        _177 = _170;
    }
    vec2 _930;
    
    // Get the depth once
    vec4 _depth = texelFetch(g_tsDepth, ivec2(gl_FragCoord.xy), 0);
    
    if (_177)
    {
        vec4 _684 = vec4(((gl_FragCoord.xy * _133.g_cbMotionInfo._vfViewport.zw) * 2.0) - vec2(1.0), _depth.x, 1.0);
        vec4 _688 = _133.g_cbMotionInfo._mTransform[0] * _684;  

        _930 = (((_215.g_cbPass._EyeData._vFrameBufferScale.xy * ((_684.xy * 0.5) + vec2(0.5))) + _215.g_cbPass._EyeData._vFrameBufferScale.zw) - ((_215.g_cbPass._EyeData._vFrameBufferScale.xy * (((_688.xy / vec2(_688.w)) * 0.5) + vec2(0.5))) + _215.g_cbPass._EyeData._vFrameBufferScale.zw)) - 
        vec2(_215.g_cbPass._EyeData._vCameraJitterDeltaX, _215.g_cbPass._EyeData._vCameraJitterDeltaY);

       out_Color = vec4(1.0);
       return; 
        
    }
    else
    {
        _930 = _163.xy;
    }
    
    out_Color = vec4(_930, _177 ? 0.0 : 0.12549020349979400634765625, 1.0);
}



































