diff --git a/Cargo.lock b/Cargo.lock index ea286af..d82203c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ab_glyph" @@ -1119,6 +1119,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "colorutils-rs" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06bb7c7479a238be740a3312b5693d76e234eb49b73b3e61ae768132c79d06a" +dependencies = [ + "erydanos", + "half", + "num-traits", + "rayon", +] + [[package]] name = "com" version = "0.6.0" @@ -1747,6 +1759,15 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" +[[package]] +name = "erydanos" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47baa8d6403c503aada20928019931ed367ed226ec0916f27c6a0d3af86c559" +dependencies = [ + "num-traits", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -2249,6 +2270,7 @@ checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", + "num-traits", ] [[package]] @@ -2630,10 +2652,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] -name = "libc" -version = "0.2.155" +name = "libblur" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "ad0f76a47545e28b618fb7acff7d0c5b0850fe6374e2de43cfa65ac32948c0ed" +dependencies = [ + "colorutils-rs", + "half", + "libc", + "num-traits", + "rayon", +] + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libfuzzer-sys" @@ -2892,6 +2927,7 @@ dependencies = [ "image 0.25.1", "imageproc", "itertools 0.13.0", + "libblur", "nalgebra 0.32.6", "notify-rust", "open", diff --git a/Cargo.toml b/Cargo.toml index 6fca9d1..a235434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,14 +16,15 @@ criterion = "0.5.1" dirs = "5.0.1" eframe = { version = "0.27.2", features = ["wgpu", "serde"] } egui = "0.27.2" -egui_dock = "0.12.0" -egui_tracing = "0.2.2" egui-phosphor = { git = "https://github.com/connorslade/egui-phosphor" } egui-wgpu = "0.27.2" +egui_dock = "0.12.0" +egui_tracing = "0.2.2" encase = { version = "0.8.0", features = ["nalgebra"] } image = "0.25.1" imageproc = "0.25.0" itertools = "0.13.0" +libblur = "0.15.1" md5 = "0.7.0" nalgebra = { version = "0.32.6", features = ["serde-serialize"] } notify-rust = "4.11.0" diff --git a/TODO.md b/TODO.md index b6f5eb1..5dd9ec9 100644 --- a/TODO.md +++ b/TODO.md @@ -89,6 +89,6 @@ - [ ] Make post processing async - [ ] Instance meshes in save files / rendering - [x] Allow recalculating normals -- [ ] Cleanup self intersection resolution +- [x] Cleanup self intersection resolution - [ ] Dont fail to load an stl without normals -- [ ] Dont clone all verts and faces to recompute normals. Just add another Arc? +- [ ] GPU accalration for post processing effect? diff --git a/mslicer/Cargo.toml b/mslicer/Cargo.toml index 4360a12..5e4dfeb 100644 --- a/mslicer/Cargo.toml +++ b/mslicer/Cargo.toml @@ -12,15 +12,16 @@ clone-macro.workspace = true const_format.workspace = true dirs.workspace = true eframe.workspace = true -egui_dock.workspace = true -egui_tracing.workspace = true egui-phosphor.workspace = true egui-wgpu.workspace = true egui.workspace = true +egui_dock.workspace = true +egui_tracing.workspace = true encase.workspace = true image.workspace = true imageproc.workspace = true itertools.workspace = true +libblur.workspace = true nalgebra.workspace = true notify-rust.workspace = true open.workspace = true @@ -29,8 +30,8 @@ plexus.workspace = true rand.workspace = true rayon.workspace = true rfd.workspace = true -serde_json.workspace = true serde.workspace = true +serde_json.workspace = true toml.workspace = true tracing-subscriber.workspace = true tracing.workspace = true diff --git a/mslicer/src/plugins/anti_alias.rs b/mslicer/src/plugins/anti_alias.rs index 959322c..002a121 100644 --- a/mslicer/src/plugins/anti_alias.rs +++ b/mslicer/src/plugins/anti_alias.rs @@ -1,4 +1,5 @@ use egui::{Context, Ui}; +use libblur::{EdgeMode, FastBlurChannels, ThreadingPolicy}; use rayon::iter::{ParallelBridge, ParallelIterator}; use slicer::format::FormatSliceFile; @@ -32,7 +33,17 @@ impl Plugin for AntiAliasPlugin { } file.iter_mut_layers().par_bridge().for_each(|mut layer| { - *layer = imageproc::filter::gaussian_blur_f32(&layer, self.radius); + let (width, height) = (layer.width(), layer.height()); + libblur::fast_gaussian_next( + &mut layer, + width, + width, + height, + self.radius as u32, + FastBlurChannels::Plane, + ThreadingPolicy::Adaptive, + EdgeMode::Clamp, + ); }); } }