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

Author Topic: sf::VertexArray using incorrect texture coordinates?  (Read 2872 times)

0 Members and 1 Guest are viewing this topic.

lezebulon

  • Full Member
  • ***
  • Posts: 235
    • View Profile
sf::VertexArray using incorrect texture coordinates?
« on: January 10, 2015, 02:57:45 pm »
Hi
I'm using a sf::VertexArray to display a tilemap : my array is composed of groups of 4 vertices making a square and each square is set to specific texture subrectangle.
 This works fine and give the intended result using a tileset as a sf::Texture (with smoothing off). However when I un-zoom my view and move it around, it seems that sometimes the subrectangle used for the texture goes 1 pixel off, which has the effect to draw 1 pixel from another tile in the tileset. I attached the picture for visual results of what I get when I move around. Again, this works fine when my view is 1:1 or when I zoom *in* .
Does anyone have an idea about this ? I'm using SFML 2.2 (from the github repo) and I kind of remember seeing this issue being mentionned here but I was unable to find it.

thanks!

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: sf::VertexArray using incorrect texture coordinates?
« Reply #1 on: January 10, 2015, 07:33:39 pm »
Round up or down camera position, in other words, the position of camera needs to be whole number / integer value in order to remove the issue.
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

lezebulon

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: sf::VertexArray using incorrect texture coordinates?
« Reply #2 on: January 11, 2015, 09:26:50 pm »
Even with the camera with a center and size that are integer values, I still have the same issue.
Also it seems that it is only happening on the left / right borders, never on the up / right borders... so I really don't get it

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: sf::VertexArray using incorrect texture coordinates?
« Reply #3 on: January 11, 2015, 09:56:43 pm »
It's an OpenGL rasterization issue and quite tricky to get around it.
The most simplest way would be to add a 1px "border" around each tile, that way you at least won't get artifacts from other tiles, even though you still might get some lines that don't fully match up.

Other solutions include, rounding all tiles to integers. Using only certain zooming steps (power by 2 or similar), adding some random floating point values to each tile, etc.

There are quite a few similar topics on the forum and the web, might want to search a bit to find some more information. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lezebulon

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: sf::VertexArray using incorrect texture coordinates?
« Reply #4 on: January 11, 2015, 10:09:33 pm »
thanks!
however is there any info about what the specific rasterisation issue is ?
If possible I'd like to get around this issue by only allowing specific zoom values, however I don't fully understand the issue so I don't know what zoom values allowing specifically.
For instance, I think there are tons of zoom factors between 1x and 2x that would not cause this rasterization problem, but I have no idea how to find them.

 

anything