A simple example using the bevy_authentic_pixel_camera plugin to achieve pixel-perfect rendering in a Bevy game.
Most pixel art camera plugins use a modern pixel camera, which doesn't force pixel perfection. Allowing for smooth movement. This is the original chunky style from old consoles.
- Pixel-perfect viewport for authentic pixel art rendering
- Uses Bevy's nearest neighbor image filtering
use bevy::prelude::*;
use bevy_authentic_pixel_camera::PixelViewportPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins(PixelViewportPlugin {
width: 30,
height: 30,
..Default::default()
})
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn((Sprite {
image: asset_server.load("bevy_pixel_dark.png"),
..Default::default()
},));
}- Add
bevy_authentic_pixel_camerato yourCargo.toml. - Use
PixelViewportPluginto set your desired pixel viewport size. - Set Bevy's image plugin to use nearest neighbor filtering for crisp pixel art.