I am trying to make Terraria like game using WGPU and rust. There are gaps between tiles. The gaps are bigger and more common as I get far from world center. I've read that nearest filtering should help, hovewer I am already using it.

enter image description here enter image description here

This is my code for calculating tile positions:

    self.world_center.x + chunk_size * 
    (chunk.coords.0 as f32) - 
    chunk_size / 2.0 + self.block_size 
    / 2.0 + self.block_size * (x as 
    self.world_center.y + chunk_size * 
    (chunk.coords.1 as f32) - 
    chunk_size / 2.0 + self.block_size 
    / 2.0 + self.block_size * (y as 

x and y is a position of a tile in a chunk. Tile (0, 0) is on the bottom left.

Thanks for your response!

  • $\begingroup$ can you discribe how you calculate the positions of your tiles? Maybe code would help to understand what happens $\endgroup$
    – Thomas
    Sep 21 at 10:14
  • $\begingroup$ Oh, sorry. It's already there. $\endgroup$ Sep 21 at 16:58
  • $\begingroup$ Does this problem occur only vertically? If so, please check if your tile has the same number of pixels in x and y direction. At the moment I would say that the number of pixels in x-direction is smaller than the number of pixels in y-direction. $\endgroup$
    – Thomas
    Sep 22 at 7:46
  • $\begingroup$ It also occurs horizontally. The player is just not far enough from the world center on a Y axis to see it. $\endgroup$ Sep 23 at 8:34
  • 1
    $\begingroup$ Since you are using floats (f32), I would suggest that you round all resulting numbers up (ceil function) and see if that makes a difference. Another usual (and better) trick is to add "a half-pixel" size and then use the default rounding function. $\endgroup$
    – wychmaster
    Sep 25 at 7:29

1 Answer 1


I've figured it out. It's bug in wgpu, if I use OpenGL backend everything is ok. The problem only occurs when using Vulkan.

  • 2
    $\begingroup$ What makes you so sure that it is a bug? Do you have a related bug report that you can share? Such artifacts can be caused by many things, for example, rounding of numbers. 2 APIs (Vulkan and OGL) might come to different valid results because they process things in a different order or they use different algorithms for the same thing. Doesn't mean it's a bug. $\endgroup$
    – wychmaster
    Sep 25 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.