#anti-aliasing #graphics

smaa

A library for post process antialiasing using SMAA

14 breaking releases

0.15.0 Jul 28, 2024
0.13.0 Mar 9, 2024
0.12.0 Nov 25, 2023
0.10.0 Jun 10, 2023
0.2.1 Mar 28, 2021

#41 in Rendering


Used in 2 crates

MIT license

1.5MB
17K SLoC

smaa-rs crates.io docs.rs

Post-process antialiasing for wgpu-rs, relying on the SMAA reference implementation.

Example

// Create SMAA target
let mut smaa_target = SmaaTarget::new(
    &device,
    &queue,
    window.inner_size().width,
    window.inner_size().height,
    swapchain_format,
    SmaaMode::Smaa1X,
);

// Main loop
event_loop.run(move |event, event_loop| {
    if let Event::WindowEvent { event, .. } = event {
        match event {
            WindowEvent::RedrawRequested => {
                let output_frame = surface.get_current_texture().unwrap();
                let output_view = output_frame.texture.create_view(&Default::default());
                let smaa_frame = smaa_target.start_frame(&device, &queue, &output_view);

                // Render the scene into `*smaa_frame`.
                // [...]

                smaa_frame.resolve();
                output_frame.present();
            }
            _ => {}
        }
    }
});

Dependencies

~11–41MB
~664K SLoC