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

Author Topic: Polygon shape - problem with mapping textures coords.  (Read 1777 times)

0 Members and 3 Guests are viewing this topic.

maassk

  • Newbie
  • *
  • Posts: 2
    • View Profile
Polygon shape - problem with mapping textures coords.
« on: July 15, 2018, 06:10:59 pm »
Hi,

I took the code from this official tutorial (tile map example): https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php

I manipulated a little bit only the part defining quad 4 corners position , so now i have polygons shapes instead of perfect squares. To be more precise, i just skewed each tile.
(i didnt change this part defining textures coordinates).


Now i see that there is a problem with mapping textures.  Left and right bound of my polygon tile takes additional 1 pixel from textures on the left and on the right in my tileset png image. So if nearest tiles have very different colors, it looks like having a borders on the left and right.


My texture is 320x32 pixels png image  (only 1 row with 10 tiles 32x32).

Please give me any clues why it takes this additional pixels.

maassk

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Polygon shape - problem with mapping textures coords.
« Reply #1 on: July 15, 2018, 08:34:21 pm »
As a temporary solution i had to remake all of my tiles to 34x32   (added 2 collumns of pixels, one on the bigining and one at the end of each tile. Then i had to copy "old" first and last column of pixels to them).

Dunno why skewed lines take pixels outside of the location i indicated in texture.
Any ideas?

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Polygon shape - problem with mapping textures coords.
« Reply #2 on: July 16, 2018, 07:39:42 am »
I don't see any images if you attached them. Also, post your code.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Polygon shape - problem with mapping textures coords.
« Reply #3 on: July 16, 2018, 06:17:40 pm »
I don't know if this is the case but it sounds like one of those times where OpenGL choosing which pixel to choose could be either 1 of two.

If all of your tiles are skewed all the time, why not use actual skewed textures too? It would likely be easier to edit the tiles since you see the as they are displayed and might fix this to boot.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*