Skip to content

Commit

Permalink
Update example.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Jun 14, 2024
1 parent 754d163 commit 38f54f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ c11-orbit = ["trackball/cc"]

[dependencies]
bevy = { version = "0.14.0-rc.2", default-features = false, features = ["bevy_render"] }
bevy_egui = { version = "0.27.1", default-features = false, features = ["render"], optional = true }
bevy_egui = { git = "https://github.com/mvlabat/bevy_egui", rev = "refs/pull/284/head", default-features = false, features = ["render"], optional = true }
trackball = { version = "0.13.0", features = ["glam"] }

[dev-dependencies.bevy]
Expand Down
14 changes: 8 additions & 6 deletions examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn setup(

let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0));
let default_material = StandardMaterial {
base_color: Color::rgb(0.8, 0.7, 0.6),
base_color: Color::srgb(0.8, 0.7, 0.6),
reflectance: 0.02,
unlit: false,
..default()
Expand All @@ -112,7 +112,7 @@ fn setup(
..default()
})
.insert(PreviewPassCube)
.insert(preview_pass_layer);
.insert(preview_pass_layer.clone());

// Cube parameters.
let cube_size = 4.0;
Expand Down Expand Up @@ -169,7 +169,7 @@ fn setup(
// render before the "main pass" camera
order: -1,
target: RenderTarget::Image(image_handle),
clear_color: ClearColorConfig::Custom(Color::rgba(1.0, 1.0, 1.0, 0.0)),
clear_color: ClearColorConfig::Custom(Color::srgba(1.0, 1.0, 1.0, 0.0)),
..default()
},
..default()
Expand Down Expand Up @@ -203,7 +203,9 @@ fn render_to_image_example_system(
ui.end_row();

ui.label("Emissive:");
color_picker_widget(ui, &mut preview_material.emissive);
let mut emissive_color = Color::from(preview_material.emissive);
color_picker_widget(ui, &mut emissive_color);
preview_material.emissive = emissive_color.into();
ui.end_row();

ui.label("Perceptual roughness:");
Expand Down Expand Up @@ -231,7 +233,7 @@ fn render_to_image_example_system(
}

fn color_picker_widget(ui: &mut egui::Ui, color: &mut Color) -> egui::Response {
let [r, g, b, a] = color.as_rgba_f32();
let [r, g, b, a] = Srgba::from(*color).to_f32_array();
let mut egui_color: egui::Rgba = egui::Rgba::from_srgba_unmultiplied(
(r * 255.0) as u8,
(g * 255.0) as u8,
Expand All @@ -244,7 +246,7 @@ fn color_picker_widget(ui: &mut egui::Ui, color: &mut Color) -> egui::Response {
egui::color_picker::Alpha::Opaque,
);
let [r, g, b, a] = egui_color.to_srgba_unmultiplied();
*color = Color::rgba(
*color = Color::srgba(
r as f32 / 255.0,
g as f32 / 255.0,
b as f32 / 255.0,
Expand Down

0 comments on commit 38f54f3

Please sign in to comment.