SFML community forums

Help => Graphics => Topic started by: jmcmorris on December 04, 2012, 07:28:15 pm

Title: Sprite Artifacts
Post by: jmcmorris on December 04, 2012, 07:28:15 pm
Hello, I am running into some odd graphical issue with rendering sprites. I am willing to make a minimal code to reproduce but before I do I was curious if anyone knows of a solution for this issue offhand.

The issue itself looks like the image is having its left or right side moved to the opposite side. Here is one example with the shield's left side being moved to the right side. The right image is the original shield.
(http://grab.by/i0ja)(http://grab.by/i0WO)

For those familiar with Moonman (using SFML as well), you can reproduce this issue in it as well. Eigen (of Pioneers) noted it in a reply to the Moonman devlog (http://forums.tigsource.com/index.php?topic=21997.msg818998#msg818998). Eigen says that he fixed this issue by padding all of his images with empty pixels. This makes sense but it is really just a work around. One I'm not too fond of this since it would require changing 100+ images.

Does anyone know what the problem is here? I appreciate the help and let me know if a minimal code to repro is needed.
Title: Re: Sprite Artifacts
Post by: Nexus on December 04, 2012, 08:11:38 pm
I had this problem, too, see here (http://en.sfml-dev.org/forums/index.php?topic=7607).

Unfortunately, this seems to be the expected OpenGL rasterization behavior and cannot be fixed on SFML side.
Title: Re: Sprite Artifacts
Post by: jmcmorris on December 04, 2012, 08:21:39 pm
Ah, so it is a problem with the position (or origin) being a float. I had half suspected that. I will floor these values when I set them and see if that fixes my problem. Thanks Nexus. :)
Title: Re: Sprite Artifacts
Post by: Nexus on December 04, 2012, 08:31:04 pm
Many parts in your SFML code can eventually lead to such a border case in pixel mapping, for example also sf::View.

And maybe you should round instead of floor the coordinates (i.e. floor(x+0.5f)).