Apply a pixelation effect to any Bevy mesh or scene without post-processing.

Overview

Pixelate Mesh

crates.io docs.rs

Apply a pixelation effect to any Bevy mesh or scene without post-processing.

Pixelated foxes

Usage

  • Add the PixelateMeshPlugin, where you specify a component that tracks the main camera.
  • Add this tracking component to your camera.
  • Add the Pixelate component to any entity that you want to pixelate.

The tracking component is needed because the plugin draws the textures on 2D canvases that need to rotate to always face the main camera.

Compatibility

bevy pixelate_mesh
0.10 0.1

Examples

The following is an annotated minimal example. More can be found in the examples folder.

use bevy::prelude::*;
use pixelate_mesh::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Add the plugin
        .add_plugin(PixelateMeshPlugin::<MainCamera>::default())
        .add_startup_system(setup)
        .run();
}

// Create a component for the main camera
#[derive(Component)]
struct MainCamera;

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn((
        // This cube will render at 64x64 pixels
        Pixelate::splat(64),
        PbrBundle {
            mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
            material: materials.add(Color::WHITE.into()),
            ..default()
        },
    ));

    commands.spawn((
        // Add the tracking component to the camera
        MainCamera,
        Camera3dBundle {
            transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
            ..default()
        },
    ));
}

Inspiration

The plugin tries to emulate the effect as seen in Prodeus:

Prodeus.-.Models.vs.Sprites.mp4
Source

Shortcomings

  • The current setup does not work with multiple main cameras. Feel free to comment on the issue if you have an idea for how to fix this!
  • The plugin deactivates MSAA globally.
You might also like...
NeosPeeps is tool that allows for listing your NeosVR friends quickly, without having to actually open the whole game
NeosPeeps is tool that allows for listing your NeosVR friends quickly, without having to actually open the whole game

Neos Peeps NeosPeeps is tool that allows for listing your NeosVR friends quickly, without having to actually open the whole game. It also has a bunch

Terminal-based Snake game written in Rust without dependencies (for educational purposes).
Terminal-based Snake game written in Rust without dependencies (for educational purposes).

RustSnake This is a simple terminal-based Snake game implemented in Rust without dependencies. To start the game type cargo run. Control the snake usi

A Bevy plugin for loading the LDtk 2D tile map format.
A Bevy plugin for loading the LDtk 2D tile map format.

bevy_ldtk ( Tileset from "Cavernas" by Adam Saltsman ) A Bevy plugin for loading LDtk tile maps. Usage use bevy::prelude::*; use bevy_ldtk::*; fn mai

Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

An ergonomic physics API for bevy games.

Heron An ergonomic physics API for 2d and 3d bevy games. (powered by rapier) How it looks like fn main() { App::build() .add_plugins(DefaultPlug

Inspector plugin for the bevy game engine
Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

A plugin for Egui integration into Bevy
A plugin for Egui integration into Bevy

bevy_egui This crate provides a Egui integration for the Bevy game engine. Features: Desktop and web (bevy_webgl2) platforms support Clipboard (web su

Crossterm plugin for the bevy game engine
Crossterm plugin for the bevy game engine

What is bevy_crossterm? bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users

A 4X style camera for bevy.

A 4X style camera for bevy. Demo Default Key Bindings: W / A / S / D / Arrow Keys / Mouse Left - Move along the horizontal plane Q / E / Mouse Right -

Comments
  • WIP: Add support for removing pixelation effect

    WIP: Add support for removing pixelation effect

    I've fixed some bugs in the code where the cameras and canvas entity was compared with the pixelated entity instead of the target of Canvas and Camera.

    I haven't really figured out what is left do do. Maybe We need to store the Original Handle<Mesh> And reinsert it in despawn_dependent_types.

    I could use some help on this one @janhohenheim

    opened by naasblod 3
  • Support Orthographic Projection

    Support Orthographic Projection

    I was looking at this as a way to generate what looks like a 2D sprite based game easily by using 3D meshes and this plugin to simulate sprites but with dynamic lighting.

    Much like the transform is being copied from the main camera, I think it would be possible to also copy the projection from the main camera onto the pixelation camera.

    enhancement 
    opened by orclev 3
Owner
Jan Hohenheim
Currently mainly doing gamedev stuff in @bevyengine
Jan Hohenheim
Use sprites in a 3d bevy scene.

bevy_sprite3d Use 2d sprites in a 3d bevy scene. This is a pretty common setup in other engines (unity, godot, etc). Useful for: 2d games using bevy's

null 46 Apr 24, 2023
A feature-rich, production-ready, general purpose 2D/3D game engine written in Rust with a scene editor.

A feature-rich, production-ready, general purpose 2D/3D game engine written in Rust with a scene editor.

rg3d engine 5.4k Jan 4, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

研究社交 208 Dec 27, 2022
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023
String processing with file/line/col information and the regular rust `str` API

Simple span handling for str and &[u8] This crate exposes some of the methods that exist on str or bstr. If you are missing any you need, please open

Oli Scherer 3 Oct 30, 2023
A Rust library for reading asset files and resource packs for any version of Minecraft

minecraft-assets A Rust library for reading asset files and resource packs for any version of Minecraft. Example use minecraft_assets::api::AssetPack;

Ben Reeves 7 Aug 14, 2022
rust-browser-game but native and rendered with ncurses in C without the Browser

Spin-off of rust-browser-game-but-sdl but with ncurses Nothing much to say. Just see rust-browser-game-but-sdl and rust-browser-game. Quick Start $ ma

Tsoding 8 Apr 21, 2022