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).

Open
#95,050 7 comments 4 reactions 0 assignees View on GitHub
bug topic:2d topic:rendering
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.

![sheet](https://github.com/user-attachments/assets/e6b89535-5396-470c-821d-bebbd1faa097)

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.

![still](https://github.com/user-attachments/assets/08cf18e9-64f1-40ad-8965-6ca0a35b0c7c)

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.

![sprite_artifact](https://github.com/user-attachments/assets/72e63af9-5860-4445-8742-a47aebb41768)

### 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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.