Skip to content
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

Image sampler set to linear/clamp #158

Merged
merged 1 commit into from
Mar 12, 2023
Merged

Image sampler set to linear/clamp #158

merged 1 commit into from
Mar 12, 2023

Conversation

galop1n
Copy link
Contributor

@galop1n galop1n commented Mar 4, 2023

If a Bevy application override the default sampler to repeat, Egui window backgrounds are incorrectly transparent.

If a Bevy application override the default sample to repeat,
Egui window backgrounds are incorrectly transparent.
@mvlabat
Copy link
Owner

mvlabat commented Mar 8, 2023

Hi! Could you provide more details on how to reproduce the issue? A code example with screenshots would be great.
I'm not sure how to confirm the fix atm. Thanks!

P.S. If I merge it after the Bevy 0.10 update release, I'll make a new patch release no problem.

@galop1n
Copy link
Contributor Author

galop1n commented Mar 8, 2023

In side_panel.rs replace the main function with the version below, clearing to red, and setting the default descriptor to Repeat and linear

fn main() {
    App::new()
        .insert_resource(ClearColor(Color::rgb(1.0, 0.0, 0.0)))
        .add_plugins(DefaultPlugins.set(ImagePlugin {
            default_sampler: bevy::render::render_resource::SamplerDescriptor {
                address_mode_u: bevy::render::render_resource::AddressMode::Repeat,
                address_mode_v: bevy::render::render_resource::AddressMode::Repeat,
                anisotropy_clamp: std::num::NonZeroU8::new(8u8),
                ..bevy::render::texture::ImageSampler::linear_descriptor()
            },
        }))
        .add_plugin(EguiPlugin)
        .init_resource::<OccupiedScreenSpace>()
        .add_startup_system(setup_system)
        .add_system(ui_example_system)
        .add_system(update_camera_transform_system)
        .run();
}

This is what it will looks like: wrong

With the PR: correct

If you look at egui glow backend, you can see the init to clamp : https://github.com/emilk/egui/blob/master/crates/egui_glow/src/painter.rs

 self.gl.tex_parameter_i32(
                glow::TEXTURE_2D,
                glow::TEXTURE_WRAP_S,
                glow::CLAMP_TO_EDGE as i32,
            );
            self.gl.tex_parameter_i32(
                glow::TEXTURE_2D,
                glow::TEXTURE_WRAP_T,
                glow::CLAMP_TO_EDGE as i32,
            );

@mvlabat
Copy link
Owner

mvlabat commented Mar 12, 2023

lgtm, thank you for the PR!

@mvlabat mvlabat merged commit 14a0192 into mvlabat:main Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants