#bevy #graphics #2d #pixels #pixel-art


A simple pixel-perfect camera plugin for Bevy, suitable for pixel-art

8 unstable releases (3 breaking)

0.4.0 Mar 7, 2023
0.3.0 Dec 8, 2022
0.2.1 Oct 31, 2022
0.2.0 Aug 1, 2022
0.1.0 Jun 24, 2021

#105 in Game dev

Download history 27/week @ 2023-01-30 34/week @ 2023-02-06 26/week @ 2023-02-13 60/week @ 2023-02-20 191/week @ 2023-02-27 227/week @ 2023-03-06 59/week @ 2023-03-13 29/week @ 2023-03-20 27/week @ 2023-03-27 45/week @ 2023-04-03 51/week @ 2023-04-10 48/week @ 2023-04-17 102/week @ 2023-04-24 33/week @ 2023-05-01 36/week @ 2023-05-08 12/week @ 2023-05-15

186 downloads per month


407 lines


A simple pixel-perfect camera plugin for Bevy, suitable for pixel-art.

This crates makes it possible to correctly display low-resolution 2d graphics with Bevy's default renderer and sprites.

While it is possible to achieve pixel-perfect rendering with Bevy's own camera and OrthographicProjection, doing so correctly requires to configure it in a specific way (you can't just use OrhtographicCameraBundle).

This plugin provides a camera which can be easily configured by specifying either the size of the virtual pixels, or the desired resolution.

Note that if either the width or the height of your sprite is not divisible by 2, you need to change the anchor of the sprite (which is at the center by default), or it will not be pixel aligned.

Also note that Bevy uses linear sampling by default for textures, which is not what you want for pixel art. The easiest way to change this is to set the default_sampler on the ImagePlugin:


The crate also includes a separate plugin to put an opaque border around the desired resolution. This way, if the window size is not an exact multiple of the virtual resolution, anything out of bounds will still be hidden.

A small example is included in the crate. Run it with:

cargo run --example flappin

Comparison with other methods

There is several possible methods to render pixel-art based games. This crate simply upscale each sprite, and correctly align them on a virtual pixel grid. Another option would be to render the sprites to an offscrenn texture, and then upscale only this texture. There is advantages and drawbacks to both approaches:

  • the offscreen texture method is probably more efficient in most cases;
  • the method in this crate allows for smoother scrolling and movement of sprites, if you're willing to temporarily break the alignment on virtual pixels (this would be even more effective with a dedicated upscaling shader).

Example code

use bevy::prelude::*;
use bevy::sprite::Anchor;
use bevy_pixel_camera::{
    PixelBorderPlugin, PixelCameraBundle, PixelCameraPlugin

fn main() {
        .add_plugin(PixelBorderPlugin {
            color: Color::rgb(0.1, 0.1, 0.1),

fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
) {
    commands.spawn(PixelCameraBundle::from_resolution(320, 240));

    commands.spawn(SpriteBundle {
        texture: asset_server.load("my-pixel-art-sprite.png"),
        sprite: Sprite {
            anchor: Anchor::BottomLeft,

Bevy versions supported

bevy bevy_pixel_camera
0.10 0.4
0.9 0.3
0.8 0.2


Licensed under either of

at your option.

License: MIT OR Apache-2.0


~1M SLoC