uniform mat4 projection; uniform mat4 view; const vec2 verts[3] = vec2[3]( vec2(0.5f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 0.0f) ); 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 = verts[gl_VertexID]; color = srgb_to_linear(vec4(vert, 0.5, 1.0)); gl_Position = vec4(vert - 0.5, 0.0, 1.0); }