#version 450 // egui integration // Similar to // https://github.com/ArjunNair/egui_sdl2_gl/blob/main/src/painter.rs layout(location = 0) in vec2 position; layout(location = 1) in vec2 tex_coords; layout(location = 2) in vec4 colour; layout(location = 0) out vec4 v_colour; layout(location = 1) out vec2 v_tex_coords; layout(push_constant) uniform PushConstants { vec2 screen_size; int need_srgb_conv; } push_constants; // 0-1 linear from 0-255 sRGB vec3 linear_from_srgb(vec3 srgb) { bvec3 cutoff = lessThan(srgb, vec3(10.31475)); vec3 lower = srgb / vec3(3294.6); vec3 higher = pow((srgb + vec3(14.025)) / vec3(269.025), vec3(2.4)); return mix(higher, lower, cutoff); } vec4 linear_from_srgba(vec4 srgba) { return vec4(linear_from_srgb(srgba.rgb * 255.0), srgba.a); } void main() { gl_Position = vec4(2.0 * position.x / push_constants.screen_size.x - 1.0, 2.0 * position.y / push_constants.screen_size.y - 1.0, 0.0, 1.0); // Convert vertex colour to linear v_colour = linear_from_srgba(colour); v_tex_coords = tex_coords; }