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

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

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

layout(location = 0) in vec4 mkLocalPositionVec4;
layout(location = 9) in vec4 mkTransformMat4R0;
layout(location = 10) in vec4 mkTransformMat4R1;
layout(location = 11) in vec4 mkTransformMat4R2;
layout(location = 12) in vec4 mkTransformMat4R3;
layout(location = 13) in vec4 mkTransformMat4R4;
layout(location = 14) in vec4 mkTransformMat4R5;
layout(location = 0) out VertexBlock
{
    vec4 mScreenSpacePositionVec4;
    vec4 mTexCoordsVec4;
    vec3 mPixelZandW_mfFadeValueForInstance;
} Out;

layout(location = 1) in vec4 mkTexCoordsVec4;
layout(location = 6) in vec4 mkWeightsVec4;
layout(location = 5) in vec4 mkJointsVec4;
layout(location = 7) in vec4 mkLocalNormalVec4;
layout(location = 3) in vec4 mkTangentVec4;
layout(location = 8) in vec4 mkColourVec4;

mat4 _2683;
vec3 _2684;

void main()
{
    vec4 _2520 = mkLocalPositionVec4;
    _2520.w = 1.0;
    mat4 _2522 = _2683;
    _2522[0] = mkTransformMat4R0;
    mat4 _2524 = _2522;
    _2524[1] = mkTransformMat4R1;
    mat4 _2526 = _2524;
    _2526[2] = mkTransformMat4R2;
    mat4 _2528 = _2526;
    _2528[3] = mkTransformMat4R3;
    Out.mPixelZandW_mfFadeValueForInstance.z = mkTransformMat4R0.w;
    mat4 _2534 = _2528;
    _2534[0].w = 0.0;
    mat4 _2536 = _2534;
    _2536[1].w = 0.0;
    mat4 _2538 = _2536;
    _2538[2].w = 0.0;
    mat4 _2540 = _2538;
    _2540[3].w = 1.0;
    int _1759 = int(mkJointsVec4.x) * 4;
    vec2 _1867 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1759].x)));
    vec3 _2545 = vec3(_1867.x, _1867.y, _2684.z);
    _2545.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1759].y;
    vec2 _1880 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1759].z)));
    vec3 _2550 = vec3(_1880.x, _1880.y, _2684.z);
    _2550.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1759].w;
    int _1780 = _1759 + 1;
    vec2 _1893 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1780].x)));
    vec3 _2555 = vec3(_1893.x, _1893.y, _2684.z);
    _2555.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1780].y;
    vec3 _1788 = ((_2545 * mkTransformMat4R1.w) + (_2550 * mkTransformMat4R2.w)) + (_2555 * mkTransformMat4R3.w);
    bool _1792 = abs(mkTransformMat4R4.x) > 0.0;
    vec3 _2685;
    if (_1792)
    {
        vec2 _1906 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1780].z)));
        vec3 _2561 = vec3(_1906.x, _1906.y, _2684.z);
        _2561.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1780].w;
        int _1808 = _1759 + 2;
        vec2 _1919 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1808].x)));
        vec3 _2566 = vec3(_1919.x, _1919.y, _2684.z);
        _2566.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1808].y;
        vec2 _1932 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1808].z)));
        vec3 _2571 = vec3(_1932.x, _1932.y, _2684.z);
        _2571.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1808].w;
        _2685 = ((_1788 + (_2561 * mkTransformMat4R4.x)) + (_2566 * mkTransformMat4R4.y)) + (_2571 * mkTransformMat4R4.z);
    }
    else
    {
        _2685 = _1788;
    }
    int _1830 = _1759 + 3;
    vec3 _2686;
    if (_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1830].w > 0.0)
    {
        vec2 _1857 = _2685.xz + (mkTransformMat4R5.xy + (mkTransformMat4R5.zw * (_2520.xz - _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1830].xz)));
        _2686 = vec3(_1857.x, _2685.y, _1857.y);
    }
    else
    {
        _2686 = _2685;
    }
    vec3 _1688 = _2520.xyz + (_2686 * mkWeightsVec4.x);
    vec3 _2739;
    if (mkWeightsVec4.y > 9.9999997473787516355514526367188e-05)
    {
        int _1951 = int(mkJointsVec4.y) * 4;
        vec2 _2059 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1951].x)));
        vec3 _2579 = vec3(_2059.x, _2059.y, _2684.z);
        _2579.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1951].y;
        vec2 _2072 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1951].z)));
        vec3 _2584 = vec3(_2072.x, _2072.y, _2684.z);
        _2584.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1951].w;
        int _1972 = _1951 + 1;
        vec2 _2085 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1972].x)));
        vec3 _2589 = vec3(_2085.x, _2085.y, _2684.z);
        _2589.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1972].y;
        vec3 _1980 = ((_2579 * mkTransformMat4R1.w) + (_2584 * mkTransformMat4R2.w)) + (_2589 * mkTransformMat4R3.w);
        vec3 _2701;
        if (_1792)
        {
            vec2 _2098 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1972].z)));
            vec3 _2595 = vec3(_2098.x, _2098.y, _2684.z);
            _2595.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_1972].w;
            int _2000 = _1951 + 2;
            vec2 _2111 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2000].x)));
            vec3 _2600 = vec3(_2111.x, _2111.y, _2684.z);
            _2600.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2000].y;
            vec2 _2124 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2000].z)));
            vec3 _2605 = vec3(_2124.x, _2124.y, _2684.z);
            _2605.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2000].w;
            _2701 = ((_1980 + (_2595 * mkTransformMat4R4.x)) + (_2600 * mkTransformMat4R4.y)) + (_2605 * mkTransformMat4R4.z);
        }
        else
        {
            _2701 = _1980;
        }
        int _2022 = _1951 + 3;
        vec3 _2702;
        if (_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2022].w > 0.0)
        {
            vec2 _2049 = _2701.xz + (mkTransformMat4R5.xy + (mkTransformMat4R5.zw * (_2520.xz - _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2022].xz)));
            _2702 = vec3(_2049.x, _2701.y, _2049.y);
        }
        else
        {
            _2702 = _2701;
        }
        _2739 = _1688 + (_2702 * mkWeightsVec4.y);
    }
    else
    {
        _2739 = _1688;
    }
    vec3 _2792;
    if (mkWeightsVec4.z > 9.9999997473787516355514526367188e-05)
    {
        int _2143 = int(mkJointsVec4.z) * 4;
        vec2 _2251 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2143].x)));
        vec3 _2613 = vec3(_2251.x, _2251.y, _2684.z);
        _2613.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2143].y;
        vec2 _2264 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2143].z)));
        vec3 _2618 = vec3(_2264.x, _2264.y, _2684.z);
        _2618.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2143].w;
        int _2164 = _2143 + 1;
        vec2 _2277 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2164].x)));
        vec3 _2623 = vec3(_2277.x, _2277.y, _2684.z);
        _2623.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2164].y;
        vec3 _2172 = ((_2613 * mkTransformMat4R1.w) + (_2618 * mkTransformMat4R2.w)) + (_2623 * mkTransformMat4R3.w);
        vec3 _2735;
        if (_1792)
        {
            vec2 _2290 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2164].z)));
            vec3 _2629 = vec3(_2290.x, _2290.y, _2684.z);
            _2629.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2164].w;
            int _2192 = _2143 + 2;
            vec2 _2303 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2192].x)));
            vec3 _2634 = vec3(_2303.x, _2303.y, _2684.z);
            _2634.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2192].y;
            vec2 _2316 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2192].z)));
            vec3 _2639 = vec3(_2316.x, _2316.y, _2684.z);
            _2639.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2192].w;
            _2735 = ((_2172 + (_2629 * mkTransformMat4R4.x)) + (_2634 * mkTransformMat4R4.y)) + (_2639 * mkTransformMat4R4.z);
        }
        else
        {
            _2735 = _2172;
        }
        int _2214 = _2143 + 3;
        vec3 _2736;
        if (_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2214].w > 0.0)
        {
            vec2 _2241 = _2735.xz + (mkTransformMat4R5.xy + (mkTransformMat4R5.zw * (_2520.xz - _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2214].xz)));
            _2736 = vec3(_2241.x, _2735.y, _2241.y);
        }
        else
        {
            _2736 = _2735;
        }
        _2792 = _2739 + (_2736 * mkWeightsVec4.z);
    }
    else
    {
        _2792 = _2739;
    }
    vec3 _2793;
    if (mkWeightsVec4.w > 9.9999997473787516355514526367188e-05)
    {
        int _2335 = int(mkJointsVec4.w) * 4;
        vec2 _2443 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2335].x)));
        vec3 _2647 = vec3(_2443.x, _2443.y, _2684.z);
        _2647.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2335].y;
        vec2 _2456 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2335].z)));
        vec3 _2652 = vec3(_2456.x, _2456.y, _2684.z);
        _2652.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2335].w;
        int _2356 = _2335 + 1;
        vec2 _2469 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2356].x)));
        vec3 _2657 = vec3(_2469.x, _2469.y, _2684.z);
        _2657.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2356].y;
        vec3 _2364 = ((_2647 * mkTransformMat4R1.w) + (_2652 * mkTransformMat4R2.w)) + (_2657 * mkTransformMat4R3.w);
        vec3 _2788;
        if (_1792)
        {
            vec2 _2482 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2356].z)));
            vec3 _2663 = vec3(_2482.x, _2482.y, _2684.z);
            _2663.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2356].w;
            int _2384 = _2335 + 2;
            vec2 _2495 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2384].x)));
            vec3 _2668 = vec3(_2495.x, _2495.y, _2684.z);
            _2668.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2384].y;
            vec2 _2508 = unpackHalf2x16(uint(floatBitsToInt(_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2384].z)));
            vec3 _2673 = vec3(_2508.x, _2508.y, _2684.z);
            _2673.z = _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2384].w;
            _2788 = ((_2364 + (_2663 * mkTransformMat4R4.x)) + (_2668 * mkTransformMat4R4.y)) + (_2673 * mkTransformMat4R4.z);
        }
        else
        {
            _2788 = _2364;
        }
        int _2406 = _2335 + 3;
        vec3 _2789;
        if (_110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2406].w > 0.0)
        {
            vec2 _2433 = _2788.xz + (mkTransformMat4R5.xy + (mkTransformMat4R5.zw * (_2520.xz - _110.lUniforms.mpCommonPerMesh.gaSkinMatrixRowsVec4[_2406].xz)));
            _2789 = vec3(_2433.x, _2788.y, _2433.y);
        }
        else
        {
            _2789 = _2788;
        }
        _2793 = _2792 + (_2789 * mkWeightsVec4.w);
    }
    else
    {
        _2793 = _2792;
    }
    Out.mTexCoordsVec4 = vec4(mkTexCoordsVec4.x, mkTexCoordsVec4.y, mkTexCoordsVec4.z, mkTexCoordsVec4.w);
    vec4 _2518 = _110.lUniforms.mpPerFrame.gViewProjectionMat4 * (_2540 * (_110.lUniforms.mpCommonPerMesh.gWorldMat4 * vec4(_2793.x, _2793.y, _2793.z, _2520.w)));
    vec4 _2681 = _2518;
    _2681.z = 0.5 - (max(_2518.z, -1.0) * 0.5);
    Out.mScreenSpacePositionVec4 = _2681;
    gl_Position = _2681;

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


