
// Vk3DVision (http://3dsurroundgaming.com/) - Original Shader
#version 450
#extension GL_EXT_nonuniform_qualifier : require
#extension GL_ARB_shader_draw_parameters : require
#extension GL_ARB_shader_ballot : require

out float gl_ClipDistance[1];

invariant gl_Position;

struct S_MATRICES
{
    mat4 _mModelViewProj;
    mat4 _mModelViewProjPrevious;
    mat4 _mModelView;
    mat4 _mInvModelView;
};

struct unaligned_float3
{
    float x;
    float y;
    float z;
};

struct S_INDICES
{
    uint _uiObjectIndex;
    uint _uiMaterialIndex;
    uint _uiMaterialInstanceIndex;
    uint _uiLastFrameMaterialIndex;
    uint _uiLastFrameMaterialInstanceIndex;
    uint _uiPositionsBufferIndex;
    uint _uiPrevPositionsBufferIndex;
    uint _uiNormalsBufferIndex;
    uint _uiPositionOffset;
    uint _uiPrevPositionOffset;
    uint _uiNormalOffset;
    uint _uiMatricesIndex;
};

struct S_MAIN_DEFAULT
{
    S_INDICES _Indices;
};

struct S_MAIN_DEFAULT_ARRAY
{
    S_MAIN_DEFAULT _aMain[32];
};

struct S_MATERIAL
{
    vec4 _vErrorColor;
    float _fDepthBias;
    float _fDummy0;
    float _fDummy1;
    float _fDummy2;
};

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;
};

layout(set = 1, binding = 24, std430) readonly buffer stc_g_rbMatrices_Layout
{
    S_MATRICES g_rbMatrices[];
} _150;

layout(set = 1, binding = 39, std430) readonly buffer g_rbVertices_Layout
{
    unaligned_float3 g_rbVertices[];
} g_rbVertices_Buffer[];

layout(set = 1, binding = 40, std430) readonly buffer g_rbNormals_Layout
{
    int g_rbNormals[];
} g_rbNormals_Buffer[];

layout(set = 0, binding = 52, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_CB_S_MAIN_ARRAY_BINDING
{
    S_MAIN_DEFAULT_ARRAY g_cbMainArray;
} _586;

layout(set = 1, binding = 34, std430) readonly buffer g_rbMaterials_Layout
{
    S_MATERIAL g_rbMaterials[];
} g_rbMaterials_Buffer[];

layout(set = 2, binding = 53, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_CB_S_PASS_BINDING
{
    S_PASS g_cbPass;
} _755;

layout(location = 8) in vec2 in_uv0;
layout(location = 8) out vec2 interp_uv0;
layout(location = 21) out vec3 interp_vfVsPosition;
layout(location = 13) out vec3 interp_vfVsNormal;
layout(location = 23) out float interp_instanceID;

void main()
{
    int _576 = gl_InstanceIndex + gl_DrawIDARB;
    int _577 = readFirstInvocationARB(_576);
    uint _2416 = uint(gl_VertexIndex);
    uint _2419 = _2416 + _586.g_cbMainArray._aMain[_577]._Indices._uiPositionOffset;
    uint _2439 = _2416 + _586.g_cbMainArray._aMain[_577]._Indices._uiNormalOffset;
    int _2458 = g_rbNormals_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiNormalsBufferIndex].g_rbNormals[_2439] & 1023;
    int _2461 = (g_rbNormals_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiNormalsBufferIndex].g_rbNormals[_2439] >> 10) & 1023;
    int _2464 = (g_rbNormals_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiNormalsBufferIndex].g_rbNormals[_2439] >> 20) & 1023;
    int _5409;
    if (_2458 > 512)
    {
        _5409 = _2458 | (-1024);
    }
    else
    {
        _5409 = _2458;
    }
    int _5411;
    if (_2461 > 512)
    {
        _5411 = _2461 | (-1024);
    }
    else
    {
        _5411 = _2461;
    }
    int _5413;
    if (_2464 > 512)
    {
        _5413 = _2464 | (-1024);
    }
    else
    {
        _5413 = _2464;
    }
    vec4 _2587 = vec4(g_rbVertices_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiPositionsBufferIndex].g_rbVertices[_2419].x, g_rbVertices_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiPositionsBufferIndex].g_rbVertices[_2419].y, g_rbVertices_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiPositionsBufferIndex].g_rbVertices[_2419].z, 1.0);
    vec4 _2588 = _150.g_rbMatrices[_586.g_cbMainArray._aMain[_577]._Indices._uiMatricesIndex]._mModelView * _2587;
    vec4 _2607 = _150.g_rbMatrices[_586.g_cbMainArray._aMain[_577]._Indices._uiMatricesIndex]._mModelViewProj * _2587;
    float _2716 = g_rbMaterials_Buffer[_586.g_cbMainArray._aMain[_577]._Indices._uiMaterialIndex].g_rbMaterials[0]._fDepthBias * 9.9999999747524270787835121154785e-07;
    float _2722 = _2588.z;
    float _2731 = _2607.z * (1.0 + ((-_755.g_cbPass._fFarPlane) * (_2716 / (_2722 + _2716))));
    vec4 _5398 = _2607;
    _5398.z = _2731;
    vec4 _5419;
    if (_755.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _2746 = _2607.w;
        vec4 _5420;
        if ((_2731 / _2746) > 1.0)
        {
            vec4 _5421;
            if (_2722 > _755.g_cbPass._fNearPlane)
            {
                vec4 _5404 = _5398;
                _5404.z = _2746;
                _5421 = _5404;
            }
            else
            {
                _5421 = _5398;
            }
            _5420 = _5421;
        }
        else
        {
            _5420 = _5398;
        }
        _5419 = _5420;
    }
    else
    {
        _5419 = _5398;
    }
    interp_instanceID = float(_576) + 0.5;
    float _2300 = _2588.x;
    float _2301 = _2588.y;
    vec4 _2303 = vec4(_2300, _2301, _2722, 1.0);
    float _2304 = dot(_755.g_cbPass._vfVsClippingPlane[0], _2303);
    float _2305 = -_2304;
    gl_ClipDistance[0] = _2305;
    interp_uv0 = in_uv0;
    interp_vfVsPosition = _2588.xyz;
    interp_vfVsNormal = mat3(_150.g_rbMatrices[_586.g_cbMainArray._aMain[_577]._Indices._uiMatricesIndex]._mModelView[0].xyz, _150.g_rbMatrices[_586.g_cbMainArray._aMain[_577]._Indices._uiMatricesIndex]._mModelView[1].xyz, _150.g_rbMatrices[_586.g_cbMainArray._aMain[_577]._Indices._uiMatricesIndex]._mModelView[2].xyz) * (vec3(float(_5409), float(_5411), float(_5413)) * vec3(0.001956947147846221923828125));
    gl_Position = _5419;
}

