// Lense flares at screen
#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;
    vec4 flaresmult;
} freqLow_vertexUniforms;

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

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

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

float SRGBlinearApprox(float value)
{
    return value * ((value * ((value * 0.305306017398834228515625) + 0.6821711063385009765625)) + 0.01252287812530994415283203125);
}

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

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

void main()
{
    vec4 position = (in_Position * freqLow_vertexUniforms.vertexxyzscale) + freqLow_vertexUniforms.vertexxyzbias;
    vec4 param = position;
    vec4 param_1 = freqHigh_vertexUniforms.mvpmatrixx;
    gl_Position.x = dot4(param, param_1);
    vec4 param_2 = position;
    vec4 param_3 = freqHigh_vertexUniforms.mvpmatrixy;
    gl_Position.y = dot4(param_2, param_3);
    vec4 param_4 = position;
    vec4 param_5 = freqHigh_vertexUniforms.mvpmatrixz;
    gl_Position.z = dot4(param_4, param_5);
    vec4 param_6 = position;
    vec4 param_7 = freqHigh_vertexUniforms.mvpmatrixw;
    gl_Position.w = dot4(param_6, param_7);
    vofi_TexCoord0 = ((in_TexCoord * freqLow_vertexUniforms.vertexstscalebias.xy) + freqLow_vertexUniforms.vertexstscalebias.zw).xyxy;
    vec4 param_8 = in_Color;
    vofi_Color = (SRGBlinearApprox(param_8) * freqHigh_vertexUniforms.color) * freqLow_vertexUniforms.flaresmult.x;
    gl_Position.y = -gl_Position.y;

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
//gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y); 
}


