Skip to content
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

Tilemap rendering incorrectly when positioned exactly on .5 #76517

Open
Tracked by #86837
blDraX opened this issue Apr 27, 2023 · 11 comments · May be fixed by #97891
Open
Tracked by #86837

Tilemap rendering incorrectly when positioned exactly on .5 #76517

blDraX opened this issue Apr 27, 2023 · 11 comments · May be fixed by #97891

Comments

@blDraX
Copy link

blDraX commented Apr 27, 2023

Godot version

v4.0.2.stable.official [7a0977c]

System information

Windows 11

Issue description

When using typical settings for obtaining pixel-perfect rendering (texture filter nearest, stretch mode viewport), tilemaps do not render correctly when they (or the camera) are exactly positioned on a half-pixel (e.g. 0.5). Looks like the left-most column is duplicated and the right-most column is cut off. Only tested for a horizontal .5 coordinate.

Aufzeichnung.2023-04-27.194721.mp4

Steps to reproduce

Set up new project with a tilemap. Build a simple tilemap. Set texture filter to nearest and stretch mode viewport. Make resolution very small to make issue more apparent.

Minimal reproduction project

tilemap_rendering.zip

@groud
Copy link
Member

groud commented Jun 21, 2023

I checked the code, but could not find anything wrong on the TileMap side. I think there's likely an issue with the rendering code but I have no clue what would cause that.

As a workaround, it seems like disabling Use texture padding helps with it.

@Cerno-b
Copy link
Contributor

Cerno-b commented Jan 6, 2024

Is it related to #82696?

@adamscott
Copy link
Member

I cannot reproduce, either on 4.0.4 or 4.3.dev, with the supplied MRP.

Can you confirm that the issue is still relevant, @blDraX?

@blDraX
Copy link
Author

blDraX commented Jan 17, 2024

@adamscott: Yes, I can still reproduce this with the minimal example I've attached on v4.2.1.stable.official [b09f793].

In fact, while also testing this on my pixel art project, I found that the camera being close to .5 does not only do weird things to the tilemap but to my animated sprites as well. Check out this clip:
https://www.youtube.com/watch?v=J7paPFCq0H8

The diamonds moving up and down is not a change in position but implemented as animated sprite with three frames. Attaching the texture I'm using as well. When the camera is on .5, the pixels are doing.. super weird stuff? Attaching the png as well.

diamond

(in the video you can also see the problem on the tilemap again. Check out the side of the cliffs for example. Outmost pixel column is duplicated and on the other side, one column is cut off; also attaching a marked screenshot)
tilemap_issue

@adamscott
Copy link
Member

@blDraX What should I see then in the MRP you joined?

@blDraX
Copy link
Author

blDraX commented Jan 17, 2024

@adamscott: Sorry, I probably didn't choose a good texture in the MRP that easily shows the issue. But you should see essentially what I've also shown in the first video back in April last year. Change the camera position between 0 and 0.5 for example. You will see the tile texture wandering by one pixel column.

Here a recording using the MRP:
https://www.youtube.com/watch?v=aDwzO_K3U9I

@blDraX
Copy link
Author

blDraX commented Mar 15, 2024

@adamscott @Cerno-b @groud I would like to bring attention to this issue again as it is still unsolved for me.

@groud previously mentioned that disabling texture padding can be used as a workaround. It's true that this prevents this specific rendering issue from happening but instead, a new issue arises: It seems like in the situations where the bug previously occured, the respective rows/columns are now instead not drawn at all:
image

It's hard for me to understand what is going on here and why only certain tiles are affected. I also have the issue attached on video which should make it a bit more clear what is going on.

I also want to add that this issue is apparently not limited to tilesets but also applies to ohter kinds of tiles images like for AnimatedSprite2D. In the second part of the video, you see the player sprite getting weirdly distorted as the camera moves diagonally, following the movement of the player up the slope:
image

For example, the lines appearing above the player sprite sometimes is actually the bottom row of one of the frames of the animation (the feet of the player sprite):
image

For reference, this is a part of the respective sprite sheet I'm using (tiled 32x32):
image

Here is the video:
https://github.com/godotengine/godot/assets/51884888/c27fd49b-4c4a-4189-951d-88ed0437fdbb

@RandomGamingDev
Copy link

I can confirm that this issue is still present on the latest stable release (4.3-stable)

@RandomGamingDev
Copy link

RandomGamingDev commented Oct 6, 2024

I've published a PR (#97891) which fixes this issue whose scope seems to include things like Sprite2D outside of the original Tileset issue, meaning that it encompasses other issues outside of this one, although I wasn't able to check them all.

Would you be able to check which specific issues regarding pixel rendering were fixed for your project @blDraX?

@adamscott
Copy link
Member

cc. @markdibarry

@markdibarry
Copy link
Contributor

Hm. I get a segfault when trying to load the MRP, both in PR branch and in master. I'll tinker a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
7 participants