mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Introduce dithering to reduce banding (#4497)
This PR introduces dithering in the egui_glow and egui_wgpu backends to reduce banding artifacts. It's based on the approach mentioned in #4493 with the small difference that the amount of noise is scaled down slightly to avoid dithering colors that can be represented exactly. This keeps flat surfaces clean. Exaggerated dithering to show what is happening:  Subtle dithering as commited.  Closes #4493
This commit is contained in:
@@ -138,6 +138,7 @@ impl Painter {
|
||||
gl: Arc<glow::Context>,
|
||||
shader_prefix: &str,
|
||||
shader_version: Option<ShaderVersion>,
|
||||
dithering: bool,
|
||||
) -> Result<Self, PainterError> {
|
||||
crate::profile_function!();
|
||||
crate::check_for_gl_error_even_in_release!(&gl, "before Painter::new");
|
||||
@@ -197,9 +198,10 @@ impl Painter {
|
||||
&gl,
|
||||
glow::FRAGMENT_SHADER,
|
||||
&format!(
|
||||
"{}\n#define NEW_SHADER_INTERFACE {}\n#define SRGB_TEXTURES {}\n{}\n{}",
|
||||
"{}\n#define NEW_SHADER_INTERFACE {}\n#define DITHERING {}\n#define SRGB_TEXTURES {}\n{}\n{}",
|
||||
shader_version_declaration,
|
||||
shader_version.is_new_shader_interface() as i32,
|
||||
dithering as i32,
|
||||
srgb_textures as i32,
|
||||
shader_prefix,
|
||||
FRAG_SRC
|
||||
|
||||
Reference in New Issue
Block a user