#version 450


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

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 modelmatrixx;
    vec4 modelmatrixy;
    vec4 modelmatrixz;
    vec4 modelmatrixw;
    vec4 mvpmatrixx;
    vec4 mvpmatrixy;
    vec4 mvpmatrixz;
    vec4 mvpmatrixw;
    vec4 smatrix;
    vec4 tmatrix;
    vec4 color;
    vec4 colorscale;
    vec4 color2;
} freqHigh_vertexUniforms;

layout(location = 0) in vec4 in_Position;
layout(location = 3) out vec4 vofi_TexCoord1;
layout(location = 2) out vec4 vofi_TexCoord0;
layout(location = 1) in vec2 in_TexCoord;
layout(location = 3) in vec4 in_Color;
layout(location = 0) out vec4 vofi_Color;

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

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

void main()
{
    vec4 position = (in_Position * freqLow_vertexUniforms.vertexxyzscale) + freqLow_vertexUniforms.vertexxyzbias;
    vec4 param = position;
    vec4 param_1 = freqHigh_vertexUniforms.modelmatrixx;
    vec4 tempPosition0;
    tempPosition0.x = dot4(param, param_1);
    vec4 param_2 = position;
    vec4 param_3 = freqHigh_vertexUniforms.modelmatrixy;
    tempPosition0.y = dot4(param_2, param_3);
    vec4 param_4 = position;
    vec4 param_5 = freqHigh_vertexUniforms.modelmatrixz;
    tempPosition0.z = dot4(param_4, param_5);
    vec4 param_6 = position;
    vec4 param_7 = freqHigh_vertexUniforms.modelmatrixw;
    tempPosition0.w = dot4(param_6, param_7);
    vofi_TexCoord1 = tempPosition0;
    vec4 param_8 = position;
    vec4 param_9 = freqHigh_vertexUniforms.mvpmatrixx;
    gl_Position.x = dot4(param_8, param_9);
    vec4 param_10 = position;
    vec4 param_11 = freqHigh_vertexUniforms.mvpmatrixy;
    gl_Position.y = dot4(param_10, param_11);
    vec4 param_12 = position;
    vec4 param_13 = freqHigh_vertexUniforms.mvpmatrixz;
    gl_Position.z = dot4(param_12, param_13);
    vec4 param_14 = position;
    vec4 param_15 = freqHigh_vertexUniforms.mvpmatrixw;
    gl_Position.w = dot4(param_14, param_15);
    vec2 _144 = (in_TexCoord * freqLow_vertexUniforms.vertexstscalebias.xy) + freqLow_vertexUniforms.vertexstscalebias.zw;
    vofi_TexCoord0 = vec4(_144.x, _144.y, vofi_TexCoord0.z, vofi_TexCoord0.w);
    vec2 param_16 = vofi_TexCoord0.xy;
    vec4 param_17 = freqHigh_vertexUniforms.smatrix;
    vofi_TexCoord0.x = dot4(param_16, param_17);
    vec2 param_18 = vofi_TexCoord0.xy;
    vec4 param_19 = freqHigh_vertexUniforms.tmatrix;
    vofi_TexCoord0.y = dot4(param_18, param_19);
    vofi_TexCoord0 = vec4(vofi_TexCoord0.x, vofi_TexCoord0.y, vec2(0.0).x, vec2(0.0).y);
    float test = 1.0 - step(1.0, in_Color.w);
    float overbright = (1.0 - test) + ((in_Color.w * 16.0) * test);
    vofi_Color = (((freqHigh_vertexUniforms.color * freqHigh_vertexUniforms.colorscale.x) * freqHigh_vertexUniforms.color2) * vec4(in_Color.xyz, 1.0)) * overbright;
    gl_Position.y = -gl_Position.y;

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
if (vk3d_params.custom_params.z != 0)
{
    if(gl_Position.w > vk3d_params.custom_params.z)
        gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y);
    else
        gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y * 0.65) * 0.75;
}
else
{
    gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y);
}
}


