godot icon indicating copy to clipboard operation
godot copied to clipboard

Region taken from AtlasTexture is inaccurate if taken from edge

Open jgodfrey opened this issue 5 years ago • 5 comments

Godot version: 3.2.stable.official

OS/device including version: Windows 10

Issue description: I've seen a few instances where extracting a manually defined region from an AtlasTexture "extends" pixels found at the edges of the texture. See attached image for an idea of what I mean here.

Steps to reproduce: Add a Sprite to a scene and then manually define a region from an AtlasTexture for the sprite's texture. Be sure the defined region is at the top edge of the atlas. Now, manually extend the region above the (apparent) top edge of the atlas. The sprite will show a smear of pixels extending from the ones that touch the top edge (I think?).

image

Minimal reproduction project:

jgodfrey avatar Feb 09 '20 20:02 jgodfrey

Actually, in the attached image, you'll notice a similar smear off the 9'oclock position, as that edge of the region also extends slightly off the left-edge of the atlas...

jgodfrey avatar Feb 09 '20 21:02 jgodfrey

Can you provide a minimal reproduction project? to speed up the resolution of the issue :)

dankan1890 avatar Feb 10 '20 22:02 dankan1890

Can reproduce in 3.2.2.stable on linux mint 18.3.

Screenshot: Godot36059_Screen

Minimal reproduction project: 36059.zip

Is this a bug in practice? You can avoid the smear by ensuring you properly frame the subsprites (or have a pixel width's clearance), which normally you would do anyway, or alternatively choose one of the repeat/mirror modes.

tom-jk avatar Jul 13 '20 15:07 tom-jk

We should find a suitable place to document this limitation (which tends to be common to all 2D renderers out there, not just Godot). Which page/class should this information be added to?

Calinou avatar Aug 03 '20 12:08 Calinou

Region editor now displays texture bounds:

Image

(although it's poorly visible with grid enabled)

What happens when you exceed that region is a typical behavior when texture is sampled beyond its size. Depending on settings, it can result in stretching or repeat. You can observe the same behavior with Sprite2D's region etc. I wonder if we could have something like clamped mode, where the texture is simply cut at the edges.

KoBeWi avatar Feb 18 '25 20:02 KoBeWi