Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sprite Artifacts  (Read 3395 times)

0 Members and 1 Guest are viewing this topic.

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Sprite Artifacts
« 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.


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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Sprite Artifacts
« Reply #1 on: December 04, 2012, 08:11:38 pm »
I had this problem, too, see here.

Unfortunately, this seems to be the expected OpenGL rasterization behavior and cannot be fixed on SFML side.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Sprite Artifacts
« Reply #2 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. :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Sprite Artifacts
« Reply #3 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)).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything