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

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

layout(set = 0, binding = 0, std140) uniform freqHigh_vertexUniforms_ubo
{
    vec4 hardwareskinning;
    vec4 mvpmatrixx;
    vec4 mvpmatrixy;
    vec4 mvpmatrixz;
    vec4 mvpmatrixw;
    vec4 wound3posa;
    vec4 wound3posb;
    vec4 wound3posc;
    vec4 wound3posd;
    vec4 wound3pose;
    vec4 wound3posf;
    vec4 wound3posg;
    vec4 wound3posh;
    vec4 wound3posi;
    vec4 wound3posj;
    vec4 wound3posk;
    vec4 wound3posl;
    vec4 wound3posm;
    vec4 wound3posn;
    vec4 wound3poso;
    vec4 wound3posp;
    vec4 wound3posq;
    vec4 wound3posr;
    vec4 wound3poss;
    vec4 wound3post;
    vec4 woundtextile;
} freqHigh_vertexUniforms;

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

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;
layout(location = 2) out vec4 vofi_TexCoord0;
layout(location = 1) in vec2 in_TexCoord;
layout(location = 8) out vec4 vofi_TexCoord6;
layout(location = 9) out vec4 vofi_TexCoord7;

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

float dot3(vec3 a, vec3 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 += (_151.matrices[(indices[i] * 3u) + 0u] * weights[i]);
        }
        for (uint i_1 = 0u; i_1 < 4u; i_1++)
        {
            matY += (_151.matrices[(indices[i_1] * 3u) + 1u] * weights[i_1]);
        }
        for (uint i_2 = 0u; i_2 < 4u; i_2++)
        {
            matZ += (_151.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);
    vofi_TexCoord0 = ((in_TexCoord * freqLow_vertexUniforms.vertexstscalebias.xy) + freqLow_vertexUniforms.vertexstscalebias.zw).xyxy;
    vec3 vertexPos = in_Position.xyz;
    vofi_TexCoord6 = vec4(0.0);
    vec3 wound3A = (freqHigh_vertexUniforms.wound3posa.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posa.w;
    vec3 wound3B = (freqHigh_vertexUniforms.wound3posb.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posb.w;
    vec3 wound3C = (freqHigh_vertexUniforms.wound3posc.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posc.w;
    vec3 wound3D = (freqHigh_vertexUniforms.wound3posd.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posd.w;
    vec3 wound3E = (freqHigh_vertexUniforms.wound3pose.xyz - vertexPos) * freqHigh_vertexUniforms.wound3pose.w;
    vec3 wound3F = (freqHigh_vertexUniforms.wound3posf.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posf.w;
    vec3 wound3G = (freqHigh_vertexUniforms.wound3posg.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posg.w;
    vec3 wound3H = (freqHigh_vertexUniforms.wound3posh.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posh.w;
    vec3 wound3I = (freqHigh_vertexUniforms.wound3posi.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posi.w;
    vec3 wound3J = (freqHigh_vertexUniforms.wound3posj.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posj.w;
    vec3 wound3K = (freqHigh_vertexUniforms.wound3posk.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posk.w;
    vec3 wound3L = (freqHigh_vertexUniforms.wound3posl.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posl.w;
    vec3 wound3M = (freqHigh_vertexUniforms.wound3posm.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posm.w;
    vec3 wound3N = (freqHigh_vertexUniforms.wound3posn.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posn.w;
    vec3 wound3O = (freqHigh_vertexUniforms.wound3poso.xyz - vertexPos) * freqHigh_vertexUniforms.wound3poso.w;
    vec3 wound3P = (freqHigh_vertexUniforms.wound3posp.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posp.w;
    vec3 wound3Q = (freqHigh_vertexUniforms.wound3posq.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posq.w;
    vec3 wound3R = (freqHigh_vertexUniforms.wound3posr.xyz - vertexPos) * freqHigh_vertexUniforms.wound3posr.w;
    vec3 wound3S = (freqHigh_vertexUniforms.wound3poss.xyz - vertexPos) * freqHigh_vertexUniforms.wound3poss.w;
    vec3 wound3T = (freqHigh_vertexUniforms.wound3post.xyz - vertexPos) * freqHigh_vertexUniforms.wound3post.w;
    vec3 param_14 = wound3A;
    vec3 param_15 = wound3A;
    float wound3A_DOT = dot3(param_14, param_15);
    vec3 param_16 = wound3B;
    vec3 param_17 = wound3B;
    float wound3B_DOT = dot3(param_16, param_17);
    vec3 param_18 = wound3C;
    vec3 param_19 = wound3C;
    float wound3C_DOT = dot3(param_18, param_19);
    vec3 param_20 = wound3D;
    vec3 param_21 = wound3D;
    float wound3D_DOT = dot3(param_20, param_21);
    vec3 param_22 = wound3E;
    vec3 param_23 = wound3E;
    float wound3E_DOT = dot3(param_22, param_23);
    vec3 param_24 = wound3F;
    vec3 param_25 = wound3F;
    float wound3F_DOT = dot3(param_24, param_25);
    vec3 param_26 = wound3G;
    vec3 param_27 = wound3G;
    float wound3G_DOT = dot3(param_26, param_27);
    vec3 param_28 = wound3H;
    vec3 param_29 = wound3H;
    float wound3H_DOT = dot3(param_28, param_29);
    vec3 param_30 = wound3I;
    vec3 param_31 = wound3I;
    float wound3I_DOT = dot3(param_30, param_31);
    vec3 param_32 = wound3J;
    vec3 param_33 = wound3J;
    float wound3J_DOT = dot3(param_32, param_33);
    vec3 param_34 = wound3K;
    vec3 param_35 = wound3K;
    float wound3K_DOT = dot3(param_34, param_35);
    vec3 param_36 = wound3L;
    vec3 param_37 = wound3L;
    float wound3L_DOT = dot3(param_36, param_37);
    vec3 param_38 = wound3M;
    vec3 param_39 = wound3M;
    float wound3M_DOT = dot3(param_38, param_39);
    vec3 param_40 = wound3N;
    vec3 param_41 = wound3N;
    float wound3N_DOT = dot3(param_40, param_41);
    vec3 param_42 = wound3O;
    vec3 param_43 = wound3O;
    float wound3O_DOT = dot3(param_42, param_43);
    vec3 param_44 = wound3P;
    vec3 param_45 = wound3P;
    float wound3P_DOT = dot3(param_44, param_45);
    vec3 param_46 = wound3Q;
    vec3 param_47 = wound3Q;
    float wound3Q_DOT = dot3(param_46, param_47);
    vec3 param_48 = wound3R;
    vec3 param_49 = wound3R;
    float wound3R_DOT = dot3(param_48, param_49);
    vec3 param_50 = wound3S;
    vec3 param_51 = wound3S;
    float wound3S_DOT = dot3(param_50, param_51);
    vec3 param_52 = wound3T;
    vec3 param_53 = wound3T;
    float wound3T_DOT = dot3(param_52, param_53);
    float mask = min(wound3A_DOT, wound3B_DOT);
    mask = min(mask, wound3C_DOT);
    mask = min(mask, wound3D_DOT);
    mask = min(mask, wound3E_DOT);
    mask = min(mask, wound3F_DOT);
    mask = min(mask, wound3G_DOT);
    mask = min(mask, wound3H_DOT);
    mask = min(mask, wound3K_DOT);
    mask = min(mask, wound3L_DOT);
    mask = min(mask, wound3M_DOT);
    mask = min(mask, wound3N_DOT);
    mask = min(mask, wound3O_DOT);
    mask = min(mask, wound3P_DOT);
    mask = min(mask, wound3Q_DOT);
    mask = min(mask, wound3R_DOT);
    float bloodSphereMask = sqrt(min(mask, min(min(wound3S_DOT, wound3T_DOT), min(wound3I_DOT, wound3J_DOT)))) - 1.0;
    float woundMask = sqrt(mask) - 1.0;
    vofi_TexCoord6 = vec4(bloodSphereMask, 0.0, 0.0, woundMask);
    vofi_TexCoord7 = vofi_TexCoord0 * vec4(freqHigh_vertexUniforms.woundtextile.xy, 1.0, 1.0);
    gl_Position.y = -gl_Position.y;
}

