godotengine / godotengine/godot
Region-selected Sprite2Ds, or AnimatedSprited2Ds created from spritesheets, sometimes show artifacts by rendering a part of their adjacent neighbor from the spritesheet (Easily reproducible).
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
-Reproducible in Godot 4.3.rc2, 4.3rc1, all 4.3 betas, and 4.2.2.stable
### System information
Windows 10 - v4.3.rc2.official - Vulkan (Forward+)
Windows 10 - v4.3.rc2.official - Compatibility
Windows 10 - v4.3.rc2.official - Mobile
### Issue description
Let's say you have a spritesheet with 32x32 sprites. By creating a sprite or animated sprite from this sheet, if you choose to make your sprites exactly 32x32, this causes for the sprite above this one to sometimes appear for a moment, especially if you have a smoothing camera.
Here is an example spritesheet with two 32x32 sprites, that is, a yellow block, and red spikes.

Now, in the still image below you can see the glitch on the 3 left spikes. These spikes have their region set to width and height of 32, so they touch the yellow sprite above in the sheet. But the two spikes on the right have a height of 31, so they have one pixel separation to the yellow sprite, and they don't show the artifact.

Now, this glitch doesn't happen all the time. I'd say it happens 1 out of every 20 times or something, but still, it happens a lot, and is clearly noticeable. Here's the gif of the above experiment, although sometimes you have to let the gif repeat to see the glitch.

### Steps to reproduce
Create a project for pixel art games (nearest neighbor default and stretch mode set to viewport).
Create a jumping player with a camera attached and smoothing enabled for the camera.
Create a sprite from the a spritesheet, making sure it exactly touches the sprite right above it in the sheet (enable pixel snap).
Create a ground and jump around the screen and behold the glitch!
Maximizing the window or making it fullscreen, I think, makes it more visible or frequent.
### Minimal reproduction project (MRP)
[Sprite Artifact Test.zip](https://github.com/user-attachments/files/16464219/Sprite.Artifact.Test.zip)
Contributor guide
Research direction
Start with the attached Minimal reproduction project and reproduce the artifact using the exact spritesheet regions, pixel snap, smoothing camera, and viewport stretch settings. Compare Vulkan Forward+, Compatibility, and Mobile rendering; done means adjacent sprites no longer appear intermittently during movement or resizing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100