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

Author Topic: How to draw a texture to a quad without weird deformation  (Read 3607 times)

0 Members and 1 Guest are viewing this topic.

Alex-Mart

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to draw a texture to a quad without weird deformation
« on: May 18, 2018, 02:42:01 am »
I want to draw a sf::Texture to a simple sf::VertexArray/ sf::Quad, like the attached image shows, but if i simply map the quads vertexes to the texture it doesn't draw my quad like the image because the quad is divided into two triangles and that deforms the texture, causing a split in the middle, how can I avoid this?
Thank you in advance.

P.S: I've also tried to draw 4 difrent triangles and a triangle fan with 6 points with the 0 in the middle and the vertex 1 being equal to the 5th
« Last Edit: May 18, 2018, 02:45:16 am by Alex-Mart »

AlejandroCoria

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • alejandrocoria.games
    • Email
Re: How to draw a texture to a quad without weird deformation
« Reply #1 on: May 18, 2018, 03:44:43 am »
I think that in order to have the correct deformation 3d is needed. You should look Sprite 3D from SelbaWard.

Alex-Mart

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to draw a texture to a quad without weird deformation
« Reply #2 on: May 18, 2018, 03:49:08 am »
I think that in order to have the correct deformation 3d is needed. You should look Sprite 3D from SelbaWard.

I don't actually want to do a 3D transform on the texture, just to have it interpolate between all 4 vertexes instead of 3, maybe a shader could do that?
I'm not sure...

AlejandroCoria

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • alejandrocoria.games
    • Email
Re: How to draw a texture to a quad without weird deformation
« Reply #3 on: May 18, 2018, 03:59:17 am »
I think ElasticSprite of SelbaWard does it in 2d. You should check their code.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: How to draw a texture to a quad without weird deformation
« Reply #4 on: May 22, 2018, 12:10:10 am »
can't you just use TriangleStrip? add vertices to the VertexArray in this order:
A: -1, -1
B: 1, -1
C: -1, 1
D: 1, 1
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to draw a texture to a quad without weird deformation
« Reply #5 on: May 24, 2018, 05:24:22 pm »
Yes, Selba Ward's Elastic Sprite does just this - interpolates the texture using four points instead of three.

For examples,

Bi-linear interpolation (default):


Perspective interpolation (if required instead):
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*