layout(location = 0) in vec3 vertex;
uniform mat4 projection;
uniform mat4 view;

out vec2 vert;
out vec4 color;

vec4 srgb_to_linear(vec4 srgb_color) {
    // Calcuation as documented by OpenGL
    vec3 srgb = srgb_color.rgb;
    vec3 selector = ceil(srgb - 0.04045);
    vec3 less_than_branch = srgb / 12.92;
    vec3 greater_than_branch = pow((srgb + 0.055) / 1.055, vec3(2.4));
    return vec4(
        mix(less_than_branch, greater_than_branch, selector),
        srgb_color.a
    );
}

void main() {
    vert = vec2(vertex.xy);
    color = srgb_to_linear(vec4(vert, 0.5, 1.0));
    gl_Position = vec4(vert, 0.0, 1.0);
}