-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct color on wide-gamut displays #2712
Comments
Interesting! Do you know anyone with a wide-gamut display that can help fix this? :) |
I have a wide-gamut display, but I'm not sure how I'd go about a fix. I assume that pushing gamut support all the way through egui/eframe would be a huge amount of work and not necessarily desirable. But if there's a way to, say, set up the OpenGL context (or whatever backend we use these days) to use sRGB, maybe there's a simpler fix that wouldn't involve too much churn. We could perhaps put it behind a flag/setting so that interested users could still access Display P3 colors if they wanted to. But it would make it so that for everyone else, things would render more consistently across platforms. The fact that egui with WebGL already works this way makes me hopeful that it's maybe not too much work. But even so, I really don't know where to start. |
On macOS Ventura (13.4),
![]()
![]()
![]()
Code from Android docs: std::vector<EGLint> attributes;
attributes.push_back(EGL_GL_COLORSPACE_KHR);
attributes.push_back(EGL_GL_COLORSPACE_DISPLAY_P3_EXT);
attributes.push_back(EGL_NONE);
engine->surface_ = eglCreateWindowSurface(
engine->display_, config, engine->app->window, attributes.data()); This would probably need to be done in let surface_attributes =
glutin::surface::SurfaceAttributesBuilder::<glutin::surface::WindowSurface>::new()
.build(window.raw_window_handle(), width, height);
let gl_surface = unsafe {
self.gl_config
.display()
.create_window_surface(&self.gl_config, &surface_attributes)?
}; Although by looking in |
On this note: the docs do not say what color space the linear RGB (color model) used in Working on an app that needs to display images and stuff like e.g. color swatches 'correctly' (the RGB color is e.g. in linear ACEScg). My assumption is that this is simply treated as linear sRGB (i.e. sRGB primaries but no gamma-encoding). I.e. P.S.: I'd be interested in hearing if there is any new insights on this issue by anyone since the last comment? |
The way no movement on the general issue. Color is particularly cursed on WebGL, and nothing has been done yet to support P3 and other output formats. |
Some displays support color gamuts larger than sRGB. E.g., many recent Mac laptops use the Display P3 color space. As best I can tell, egui/eframe naively assume the display's color gamut is sRGB, and this causes colors to be drawn incorrectly on devices with wider gamuts.
The easiest way to test this to set up a comparison with a web browser. Safari and Firefox are both gamut-aware and will correctly draw colors in sRGB when viewed on a wide-gamut display. Note that the
display-p3
syntax is specific to Safari:For comparison, you can set up a simple app with eframe_template and draw a rect with
Color32::from_rgb(70, 130, 180)
. Note that the color that is shown matches the Display P3 color test, not sRGB.In contrast, when I run the same eframe_template app via
trunk
and open it in Firefox, the colors are rendered correctly. It must be that Firefox performs color correction in WebGL contexts and ensures that sRGB colors are displayed correctly.The text was updated successfully, but these errors were encountered: