bevy_smooth_pixel_camera

Crates.iobevy_smooth_pixel_camera
lib.rsbevy_smooth_pixel_camera
version0.3.0
sourcesrc
created_at2023-11-06 15:16:06.729152
updated_at2024-02-17 21:13:09.430903
descriptionSmooth pixel-perfect camera for Bevy
homepage
repositoryhttps://github.com/doonv/bevy_smooth_pixel_camera
max_upload_size
id1027003
size141,035
Doonv (doonv)

documentation

README

bevy_smooth_pixel_camera

crates.io docs.rs

A bevy plugin that adds a simple smooth pixel camera.

The smoothing is based on this video from aarthificial which explains how it works pretty nicely: https://youtu.be/jguyR4yJb1M

This method allows for smooth camera movement while retaining the pixel perfection of low resolution rendering.

Usage

  1. Add the bevy_smooth_pixel_camera crate to your project.

    cargo add bevy_smooth_pixel_camera
    
  2. Add the PixelCameraPlugin and set the ImagePlugin to default_nearest.

    use bevy::prelude::*;
    use bevy_smooth_pixel_camera::prelude::*;
    
    App::new().add_plugins((
        DefaultPlugins.set(ImagePlugin::default_nearest()),
        PixelCameraPlugin
    )).run();
    
  3. Add a pixel pefect camera to your scene.

    use bevy::prelude::*;
    use bevy_smooth_pixel_camera::prelude::*;
    
    fn setup(mut commands: Commands) {
        commands.spawn((
            Camera2dBundle::default(),
            PixelCamera::from_size(ViewportSize::PixelFixed(4))
        ));
    }
    
  4. That should be it! Make sure you move your camera via the PixelCamera.subpixel_pos property instead of the Transform component.

Bevy Compatibility

bevy bevy_smooth_pixel_camera
main main
0.13.* / latest 0.3.0 / latest
0.12.* 0.1.0 - 0.2.1
Commit count: 10

cargo fmt