-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
glitches with tilemap graphics in some zoom levels #188
Comments
Could be caused by aliasing? All artifacts seem appear on the same corner tile. |
I have the same issue and I noticed that it can be fixed by tweaking the size of the source rectangle, as is done in macroquad tiled: fn sprite_rect(&self, ix: u32) -> Rect {
let sw = self.tilewidth as f32;
let sh = self.tileheight as f32;
let sx = (ix % self.columns) as f32 * (sw + self.spacing as f32) + self.margin as f32;
let sy = (ix / self.columns) as f32 * (sh + self.spacing as f32) + self.margin as f32;
// TODO: configure tiles margin
Rect::new(sx + 1.1, sy + 1.1, sw - 2.2, sh - 2.2)
}
[...]
draw_texture_ex(
tileset.texture,
dest.x,
dest.y,
WHITE,
DrawTextureParams {
dest_size: Some(vec2(dest.w, dest.h)),
source: Some(Rect::new(
spr_rect.x - 1.0,
spr_rect.y - 1.0,
spr_rect.w + 2.0,
spr_rect.h + 2.0,
)),
..Default::default()
},
);`` This will cut off ~one pixel around your tile, however, so creating tilesheets with padding around the tiles, might be an idea. I believe it is due to float rounding and nearest neighbor filtering, but I am not sure.... |
my fix was so everything is drawn pixel accurate and there are no sub-pixel problems |
Beautifully simple. I will try this as well. Had some way more intricate solutions in mind, but simple is better. |
I posted another reply, based on some incorrect assumptions, so I deleted it. I would go through my code, step by step, and look for anything that might cause off-pixel positioning. |
The complete code in order to reproduce this issue is in the first post. |
This problem is happening with my own game as well. It appears the more zoomed in you are the more prevalent it is. Rounding it helps but causes camera stuttering and does not completely rid it of the issue. I am making an 8x8 pixel art game. Should I scale up the game? Should I put a gap between tiles in my atlas? |
I adjusted camera and zoom level from examples/platformer.rs and noticed a graphic glitch in the background tiles with some zoom levels, as can be seen in this video clip. The same issue is seen both on Windows and macOS.
The issue goes away at zoom level 2 and 3.
reprod_bug.2021-04-07.10-58-29.mp4
source
The text was updated successfully, but these errors were encountered: