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

Author Topic: Incorrect pixel mapping at 0.5 (again)  (Read 2319 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Incorrect pixel mapping at 0.5 (again)
« on: April 15, 2012, 03:52:20 pm »
Hi,

When using coordinates with a float part of 0.5, it happens that pixels of the texture aren't mapped correctly to the screen. That is, texels outside the sub-rect are rendered, or texels inside are spread over multiple pixels. I have written a reproducing example, where you can move a sprite and see how its appearance changes, although it's moved only in one-pixel steps:

https://legacy.sfmluploads.org/file/130/download

As far as I've observed, it is enough to round coordinates, i.e. making sure that setOrigin() or setPosition() calls don't lead to that coordinates -- for the case where no rotation or scale is involved.

I started some threads about this issue in the past, and I'm not sure if the situation has changed with the new rendering system. Anyway, I just wanted to remind you, in case you want to modify something before the SFML 2 release. I'd recommend to mention this behavior and the workaround at least in the documentation, since the circumstances to cause it are quite common.

My older threads:
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Incorrect pixel mapping at 0.5 (again)
« Reply #1 on: April 15, 2012, 06:15:18 pm »
This is the expected behaviour, and I don't think it can be fixed. There was a thread about it a few months ago, where an experimented user (finally) confirmed my thoughts about this issue.

It should definitely be mentioned in the doc, yes :)
Laurent Gomila - SFML developer