
// Vk3DVision (http://3dsurroundgaming.com/) - Original Shader
#version 450

layout(set = 0, binding = 1, std140) uniform freqLow_vertexUniforms_ubo
{
    vec4 vertexxyzscale;
    vec4 vertexxyzbias;
} freqLow_vertexUniforms;

layout(set = 0, binding = 0, std140) uniform freqHigh_vertexUniforms_ubo
{
    vec4 hardwareskinning;
    vec4 mvpmatrixx;
    vec4 mvpmatrixy;
    vec4 mvpmatrixz;
    vec4 mvpmatrixw;
} freqHigh_vertexUniforms;

layout(set = 0, binding = 2, std140) uniform matrices_ubo
{
    vec4 matrices[768];
} _139;

layout(location = 0) in vec4 in_Position;
layout(location = 9) in vec4 in_Tangent;
layout(location = 2) in vec4 in_Normal;
layout(location = 3) in vec4 in_Color;

float dot4(vec4 a, vec4 b)
{
    return dot(a, b);
}

void main()
{
    vec4 localPosition = (in_Position * freqLow_vertexUniforms.vertexxyzscale) + freqLow_vertexUniforms.vertexxyzbias;
    if (freqHigh_vertexUniforms.hardwareskinning.x != 0.0)
    {
        vec4 tempPosition = localPosition;
        vec4 matX = vec4(0.0);
        vec4 matY = vec4(0.0);
        vec4 matZ = vec4(0.0);
        float hiweight = in_Tangent.w * 255.100006103515625;
        vec4 weights;
        weights.y = hiweight - (floor(hiweight / 128.0) * 128.0);
        float packedWeights = in_Normal.w * 255.100006103515625;
        weights.z = floor(packedWeights / 16.0);
        weights.w = packedWeights - (weights.z * 16.0);
        weights.y *= 0.00393700785934925079345703125;
        weights.z *= 0.02222222276031970977783203125;
        weights.w *= 0.01666666753590106964111328125;
        weights.x = 1.0 - ((weights.y + weights.z) + weights.w);
        uvec4 indices = uvec4(in_Color * 255.0);
        for (uint i = 0u; i < 4u; i++)
        {
            matX += (_139.matrices[(indices[i] * 3u) + 0u] * weights[i]);
        }
        for (uint i_1 = 0u; i_1 < 4u; i_1++)
        {
            matY += (_139.matrices[(indices[i_1] * 3u) + 1u] * weights[i_1]);
        }
        for (uint i_2 = 0u; i_2 < 4u; i_2++)
        {
            matZ += (_139.matrices[(indices[i_2] * 3u) + 2u] * weights[i_2]);
        }
        vec4 param = tempPosition;
        vec4 param_1 = matX;
        localPosition.x = dot4(param, param_1);
        vec4 param_2 = tempPosition;
        vec4 param_3 = matY;
        localPosition.y = dot4(param_2, param_3);
        vec4 param_4 = tempPosition;
        vec4 param_5 = matZ;
        localPosition.z = dot4(param_4, param_5);
        localPosition.w = 1.0;
    }
    vec4 param_6 = localPosition;
    vec4 param_7 = freqHigh_vertexUniforms.mvpmatrixx;
    gl_Position.x = dot4(param_6, param_7);
    vec4 param_8 = localPosition;
    vec4 param_9 = freqHigh_vertexUniforms.mvpmatrixy;
    gl_Position.y = dot4(param_8, param_9);
    vec4 param_10 = localPosition;
    vec4 param_11 = freqHigh_vertexUniforms.mvpmatrixz;
    gl_Position.z = dot4(param_10, param_11);
    vec4 param_12 = localPosition;
    vec4 param_13 = freqHigh_vertexUniforms.mvpmatrixw;
    gl_Position.w = dot4(param_12, param_13);
    gl_Position.y = -gl_Position.y;
}

