mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Fix colors in glium (srgb issue)
This commit is contained in:
@@ -41,8 +41,18 @@ impl Painter {
|
||||
in vec4 v_color;
|
||||
in vec2 v_tc;
|
||||
out vec4 f_color;
|
||||
|
||||
// glium expects linear output.
|
||||
vec3 linear_from_srgb(vec3 srgb) {
|
||||
bvec3 cutoff = lessThan(srgb, vec3(0.04045));
|
||||
vec3 higher = pow((srgb + vec3(0.055)) / vec3(1.055), vec3(2.4));
|
||||
vec3 lower = srgb / vec3(12.92);
|
||||
return mix(higher, lower, cutoff);
|
||||
}
|
||||
|
||||
void main() {
|
||||
f_color = v_color;
|
||||
f_color.rgb = linear_from_srgb(f_color.rgb);
|
||||
f_color.a *= texture(u_sampler, v_tc).r;
|
||||
}
|
||||
"
|
||||
@@ -74,8 +84,18 @@ impl Painter {
|
||||
uniform sampler2D u_sampler;
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tc;
|
||||
|
||||
// glium expects linear output.
|
||||
vec3 linear_from_srgb(vec3 srgb) {
|
||||
bvec3 cutoff = lessThan(srgb, vec3(0.04045));
|
||||
vec3 higher = pow((srgb + vec3(0.055)) / vec3(1.055), vec3(2.4));
|
||||
vec3 lower = srgb / vec3(12.92);
|
||||
return mix(higher, lower, cutoff);
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_FragColor = v_color;
|
||||
gl_FragColor.rgb = linear_from_srgb(gl_FragColor.rgb);
|
||||
gl_FragColor.a *= texture2D(u_sampler, v_tc).r;
|
||||
}
|
||||
",
|
||||
@@ -107,8 +127,18 @@ impl Painter {
|
||||
uniform sampler2D u_sampler;
|
||||
varying mediump vec4 v_color;
|
||||
varying mediump vec2 v_tc;
|
||||
|
||||
// glium expects linear output.
|
||||
vec3 linear_from_srgb(vec3 srgb) {
|
||||
bvec3 cutoff = lessThan(srgb, vec3(0.04045));
|
||||
vec3 higher = pow((srgb + vec3(0.055)) / vec3(1.055), vec3(2.4));
|
||||
vec3 lower = srgb / vec3(12.92);
|
||||
return mix(higher, lower, cutoff);
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_FragColor = v_color;
|
||||
gl_FragColor.rgb = linear_from_srgb(gl_FragColor.rgb);
|
||||
gl_FragColor.a *= texture2D(u_sampler, v_tc).r;
|
||||
}
|
||||
",
|
||||
|
||||
Reference in New Issue
Block a user