// Missles UI
#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 = 0, std140) uniform freqHigh_vertexUniforms_ubo
{
    vec4 mvpmatrixx;
    vec4 mvpmatrixy;
    vec4 mvpmatrixz;
    vec4 mvpmatrixw;
} freqHigh_vertexUniforms;

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

layout(location = 0) in vec4 in_Position;
layout(location = 9) in vec4 in_Tangent;
layout(location = 2) out vec4 vofi_TexCoord0;
layout(location = 1) in vec2 in_TexCoord;
layout(location = 3) out vec4 vofi_TexCoord1;
layout(location = 4) in vec2 in_TexCoord1;
layout(location = 4) out vec4 vofi_TexCoord2;
layout(location = 2) in vec4 in_Normal;
layout(location = 0) out vec4 vofi_Color;
layout(location = 3) in vec4 in_Color;

float _65;

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

float saturate(float v)
{
    return clamp(v, 0.0, 1.0);
}

float SRGBlinear(float value)
{
    if (value <= 0.040449999272823333740234375)
    {
        return value / 12.9200000762939453125;
    }
    else
    {
        return pow((value / 1.05499994754791259765625) + 0.0521326996386051177978515625, 2.400000095367431640625);
    }
}

vec3 SRGBlinear(vec3 sRGB)
{
    float param = sRGB.x;
    vec3 outLinear;
    outLinear.x = SRGBlinear(param);
    float param_1 = sRGB.y;
    outLinear.y = SRGBlinear(param_1);
    float param_2 = sRGB.z;
    outLinear.z = SRGBlinear(param_2);
    return outLinear;
}

vec4 SRGBlinear(vec4 sRGBA)
{
    vec3 param = sRGBA.xyz;
    vec4 outLinear = vec4(SRGBlinear(param), 1.0);
    float param_1 = sRGBA.w;
    outLinear.w = SRGBlinear(param_1);
    return outLinear;
}

vec4 DeGamma(vec4 color)
{
    vec4 param = color;
    return SRGBlinear(param);
}

void main()
{
    vec4 param = in_Position;
    vec4 param_1 = freqHigh_vertexUniforms.mvpmatrixx;
    gl_Position.x = dot4(param, param_1);
    vec4 param_2 = in_Position;
    vec4 param_3 = freqHigh_vertexUniforms.mvpmatrixy;
    gl_Position.y = dot4(param_2, param_3);
    vec4 param_4 = in_Position;
    vec4 param_5 = freqHigh_vertexUniforms.mvpmatrixz;
    gl_Position.z = dot4(param_4, param_5);
    vec4 param_6 = in_Position;
    vec4 param_7 = freqHigh_vertexUniforms.mvpmatrixw;
    gl_Position.w = dot4(param_6, param_7);
    gl_Position.z *= 0.949999988079071044921875;
    float eyeDist = gl_Position.w;
    float frameFrac = in_Tangent.z;
    float alphascale = in_Tangent.w;
    float param_8 = exp2(-(clamp(gl_Position.w - freqLow_vertexUniforms.fogparms.x, 0.0, freqLow_vertexUniforms.fogparms.y) * freqLow_vertexUniforms.fogparms.z));
    float fogVal = saturate(param_8);
    float thickness = ((1.0 - alphascale) * 127.0) / eyeDist;
    vec2 _211 = (in_TexCoord * freqLow_vertexUniforms.particlestscalebias.x) + vec2(freqLow_vertexUniforms.particlestscalebias.y);
    vofi_TexCoord0 = vec4(_211.x, _211.y, vofi_TexCoord0.z, vofi_TexCoord0.w);
    vofi_TexCoord0.z = fogVal;
    vofi_TexCoord0.w = alphascale;
    vec2 _227 = (in_TexCoord1 * freqLow_vertexUniforms.particlestscalebias.x) + vec2(freqLow_vertexUniforms.particlestscalebias.y);
    vofi_TexCoord1 = vec4(_227.x, _227.y, vofi_TexCoord1.z, vofi_TexCoord1.w);
    vofi_TexCoord1.z = frameFrac;
    vofi_TexCoord1.w = 0.0;
    vofi_TexCoord2.x = (in_Normal.x * 10.0) + 1.0;
    vofi_TexCoord2.y = (in_Normal.y * 10.0) + 1.0;
    vofi_TexCoord2.z = (in_Normal.z * 10.0) + 1.0;
    vofi_TexCoord2.w = in_Normal.w;
    gl_Position.z -= (thickness * vofi_TexCoord2.z);
    float param_9 = abs(eyeDist) / ((1.0 - alphascale) * 127.0);
    float particleFade = saturate(param_9);
    vec4 param_10 = in_Color;
    vofi_Color = DeGamma(param_10);
    vofi_Color.w *= particleFade;
    bool facingCamera = in_Tangent.y > 0.0;
    if (facingCamera == true)
    {
        float opacityMin = 0.0039215688593685626983642578125;
        float opacityScale = 1.0 / (1.0 - opacityMin);
        if (vofi_Color.w < opacityMin)
        {
            gl_Position = vec4(vec3(0.0).x, vec3(0.0).y, vec3(0.0).z, gl_Position.w);
        }
        vofi_Color.w = (vofi_Color.w - opacityMin) * opacityScale;
    }
    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);
}
}


