#version 450
 
struct PerFrameUniforms
{
    mat4 gViewMat4;
    mat4 gViewProjectionMat4;
    mat4 gCameraMat4;
    vec3 gViewPositionVec3;
    float gfTime;
    vec4 gFrameBufferSizeVec4;
};

struct CommonPerMeshUniforms
{
    vec4 gPlanetPositionVec4;
    mat4 gWorldMat4;
    float gfFadeValue;
    vec4 gaSkinMatrixRowsVec4[225];
    vec4 gaPrevSkinMatrixRowsVec4[225];
    vec4 gUserDataVec4;
};

struct CustomPerMaterialUniforms
{
    vec4 gImposterDataVec4;
    vec4 gTileBlendScalesVec4;
    vec4 gHueOverlayParamsVec4;
    vec4 gSaturationOverlayParamsVec4;
    vec4 gValueOverlayParamsVec4;
    vec4 gTerrainColour1Vec4;
    vec4 gTerrainColour2Vec4;
};

struct CustomPerMeshUniforms
{
    vec4 gUVScrollStepVec4;
    vec4 gCustomParams01Vec4;
    vec4 gBboxDepthAndClips;
};

struct UniformBuffer
{
    PerFrameUniforms mpPerFrame;
    CommonPerMeshUniforms mpCommonPerMesh;
    CustomPerMaterialUniforms mpCustomPerMaterial;
    CustomPerMeshUniforms mpCustomPerMesh;
};


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

layout(set = 0, binding = 0, std140) uniform lUniforms_BLK
{
    UniformBuffer lUniforms;
} _62;

layout(location = 0) in vec4 mkLocalPositionVec4;
layout(location = 1) in vec4 mkTexCoordsVec4;
layout(location = 6) in vec4 mkWeightsVec4;
layout(location = 5) in vec4 mkJointsVec4;
layout(location = 0) out VertexBlock
{
    vec4 mScreenSpacePositionVec4;
    vec4 mTexCoordsVec4;
} Out;

layout(location = 7) in vec4 mkLocalNormalVec4;
layout(location = 3) in vec4 mkTangentVec4;
layout(location = 8) in vec4 mkColourVec4;

mat4 _1664;

void main()
{
    vec4 _1613 = mkLocalPositionVec4;
    _1613.w = 1.0;
    int _1527 = int(mkJointsVec4.x) * 3;
    mat4 _1616 = _1664;
    _1616[0] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1527];
    mat4 _1618 = _1616;
    _1618[1] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1527 + 1];
    mat4 _1620 = _1618;
    _1620[2] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1527 + 2];
    mat4 _1622 = _1620;
    _1622[3] = vec4(0.0, 0.0, 0.0, 1.0);
    vec4 _1465 = (_1613 * _1622) * mkWeightsVec4.x;
    vec4 _1666;
    if (mkWeightsVec4.y > 0.001000000047497451305389404296875)
    {
        int _1548 = int(mkJointsVec4.y) * 3;
        mat4 _1627 = _1664;
        _1627[0] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1548];
        mat4 _1629 = _1627;
        _1629[1] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1548 + 1];
        mat4 _1631 = _1629;
        _1631[2] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1548 + 2];
        mat4 _1633 = _1631;
        _1633[3] = vec4(0.0, 0.0, 0.0, 1.0);
        _1666 = _1465 + ((_1613 * _1633) * mkWeightsVec4.y);
    }
    else
    {
        _1666 = _1465;
    }
    vec4 _1669;
    if (mkWeightsVec4.z > 0.001000000047497451305389404296875)
    {
        int _1569 = int(mkJointsVec4.z) * 3;
        mat4 _1638 = _1664;
        _1638[0] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1569];
        mat4 _1640 = _1638;
        _1640[1] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1569 + 1];
        mat4 _1642 = _1640;
        _1642[2] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1569 + 2];
        mat4 _1644 = _1642;
        _1644[3] = vec4(0.0, 0.0, 0.0, 1.0);
        _1669 = _1666 + ((_1613 * _1644) * mkWeightsVec4.z);
    }
    else
    {
        _1669 = _1666;
    }
    vec4 _1670;
    if (mkWeightsVec4.w > 0.001000000047497451305389404296875)
    {
        int _1590 = int(mkJointsVec4.w) * 3;
        mat4 _1649 = _1664;
        _1649[0] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1590];
        mat4 _1651 = _1649;
        _1651[1] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1590 + 1];
        mat4 _1653 = _1651;
        _1653[2] = _62.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1590 + 2];
        mat4 _1655 = _1653;
        _1655[3] = vec4(0.0, 0.0, 0.0, 1.0);
        _1670 = _1669 + ((_1613 * _1655) * mkWeightsVec4.w);
    }
    else
    {
        _1670 = _1669;
    }
    Out.mTexCoordsVec4 = vec4(mkTexCoordsVec4.x, mkTexCoordsVec4.y, mkTexCoordsVec4.z, mkTexCoordsVec4.w);
    vec4 _1611 = _62.lUniforms.mpPerFrame.gViewProjectionMat4 * (_62.lUniforms.mpCommonPerMesh.gWorldMat4 * (_1670 / vec4(max(_1670.w, 9.9999999747524270787835121154785e-07))));
    vec4 _1663 = _1611;
    _1663.z = 0.5 - (max(_1611.z, -1.0) * 0.5);
    Out.mScreenSpacePositionVec4 = _1663;
    gl_Position = _1663;

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
//gl_Position.x -= vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y); 

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
//gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y); 
}


