https://github.com/doonv/bevy_smooth_pixel_camera
Smooth pixel-perfect camera for Bevy
https://github.com/doonv/bevy_smooth_pixel_camera
bevy bevy-plugin camera pixel pixel-perfect rust smooth
Last synced: about 2 months ago
JSON representation
Smooth pixel-perfect camera for Bevy
- Host: GitHub
- URL: https://github.com/doonv/bevy_smooth_pixel_camera
- Owner: doonv
- License: apache-2.0
- Created: 2023-11-04T13:56:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-04-17T18:20:07.000Z (about 2 months ago)
- Last Synced: 2026-04-17T20:27:33.100Z (about 2 months ago)
- Topics: bevy, bevy-plugin, camera, pixel, pixel-perfect, rust, smooth
- Language: Rust
- Homepage: https://docs.rs/bevy_smooth_pixel_camera/latest/bevy_smooth_pixel_camera/
- Size: 184 KB
- Stars: 40
- Watchers: 1
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_smooth_pixel_camera
[](https://crates.io/crates/bevy_smooth_pixel_camera)
[](https://docs.rs/bevy_smooth_pixel_camera)

[](https://bevy.org/learn/quick-start/plugin-development/#main-branch-tracking)
A bevy plugin that adds a simple smooth pixel camera.
It works by rendering the main camera to a small viewport which is then rendered by a second camera spawned by the plugin.
This allows for hybrid rendering of both a pixelated world and high resolution assets on top.
This plugin has a [smoothing] feature, which makes the camera's movement appear smooth while keeping the world itself locked
to a pixel grid. It works by moving the canvas in the opposite direction of the world camera's subpixel position. See the
[`how_smoothing_works`] example for a demonstration of how it works behind the scenes.
| Smoothing OFF | Smoothing ON |
| :-----------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: |
| ![The camera is locked to the pixel grid, causing jagged motion][smoothing_off] | ![The camera moves smoothly while the world itself stays locked to a pixel grid.][smoothing_on] |
## Usage
1. Add the `bevy_smooth_pixel_camera` crate to your project.
```sh
cargo add bevy_smooth_pixel_camera
```
2. Add the [`PixelCameraPlugin`] and set [`ImagePlugin`] to [`default_nearest`].
```rust
use bevy::prelude::*;
use bevy_smooth_pixel_camera::prelude::*;
App::new()
.add_plugins((
DefaultPlugins.set(ImagePlugin::default_nearest()),
PixelCameraPlugin,
))
.run();
```
3. Add a [`PixelCamera`](https://docs.rs/bevy_smooth_pixel_camera/latest/bevy_smooth_pixel_camera/components/struct.PixelCamera.html) to your world.
```rust
use bevy::prelude::*;
use bevy_smooth_pixel_camera::prelude::*;
fn setup(mut commands: Commands) {
commands.spawn(PixelCamera::from_size(ViewportScalingMode::PixelSize(4.0)));
}
```
4. That's it!
## Features
`picking` **(default)** - Enables [picking] through the viewport.
## Bevy Compatibility
| bevy | bevy_smooth_pixel_camera |
| ------ | ------------------------ |
| 0.18.* | 0.4.x - [`main`] |
| 0.13.* | 0.3.0 |
| 0.12.* | 0.1.0 - 0.2.1 |
[smoothing_off]: https://raw.githubusercontent.com/doonv/bevy_smooth_pixel_camera/main/assets/smoothing_off.avif
[smoothing_on]: https://raw.githubusercontent.com/doonv/bevy_smooth_pixel_camera/main/assets/smoothing_on.avif
[`how_smoothing_works`]: https://github.com/doonv/bevy_smooth_pixel_camera/blob/main/examples/how_smoothing_works.rs
[`main`]: https://github.com/doonv/bevy_smooth_pixel_camera
[`PixelCameraPlugin`]: https://docs.rs/bevy_smooth_pixel_camera/latest/bevy_smooth_pixel_camera/struct.PixelCameraPlugin.html
[`ImagePlugin`]: https://docs.rs/bevy_image/latest/bevy_image/image/struct.ImagePlugin.html
[`default_nearest`]: https://docs.rs/bevy_image/latest/bevy_image/struct.ImagePlugin.html#method.default_nearest
[smoothing]: https://docs.rs/bevy_smooth_pixel_camera/latest/bevy_smooth_pixel_camera/components/struct.PixelCamera.html#structfield.smoothing
[picking]: https://docs.rs/bevy/latest/bevy/picking/index.html