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
    Commented Sep 21, 2023 at 10:14
  • $\begingroup$ Oh, sorry. It's already there. $\endgroup$ Commented Sep 21, 2023 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
    Commented Sep 22, 2023 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$ Commented Sep 23, 2023 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
    Commented Sep 25, 2023 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.

  • 3
    $\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
    Commented Sep 25, 2023 at 7:22

Your Answer

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

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