-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example for pixel-perfect grid snapping in 2D #8112
Add example for pixel-perfect grid snapping in 2D #8112
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
d127d27
to
26bf8f3
Compare
Very nice stuff. I only have a few nits. |
26bf8f3
to
dcafb04
Compare
dcafb04
to
b21f76a
Compare
Solid work. In the future, adding more commits rather than rebasing will make it slightly easier for reviewers to tell what's changed :) |
Got it, thank you for the swift review! |
I'm not asking for this change right now, but what do we think about combining this example That example seems to exist solely to have a place to put |
It does seem like this example covers the other one. I also realized that the sprite in |
# Conflicts: # examples/2d/pixel_perfect.rs
…ture_2d # Conflicts: # Cargo.toml # examples/2d/pixel_perfect.rs
# Conflicts: # assets/pixel/bevy_pixel_dark.png # examples/2d/pixel_perfect.rs
Objective
Provide an example of how to achieve pixel-perfect "grid snapping" in 2D via rendering to a texture. This is a common use case in retro pixel art game development.
Solution
Render sprites to a canvas via a Camera, then use another (scaled up) Camera to render the resulting canvas to the screen. This example is based on the
3d/render_to_texture.rs
example. Furthermore, this example demonstrates mixing retro-style graphics with high-resolution graphics, as well as pixel-snapped rendering of aMaterialMesh2dBundle
.