Trapezoid uvs preservation

Started by
21 comments, last by masterbubu 11 years, 10 months ago
Hi All,

I am trying to create this effect on Opengl ES, without any success.

basically I have created a quad which is built up from two tri's.

my goal is to distort the vertices as I wise, but the uv's needs to react accordingly ( as the link shows ).

I have read lots on information online, but not managed to preform the task.

Any help would be great...

tnx :)
Advertisement
Um, the source code on the linked site is not helping? I don't know about openGL ES, but that link would have been the first link I would have posted. I'd be surprised if ES didn't support r,q coordinates.
Hi,

OpenGL ES does not work with the fixed pipe line. So I can't use glTexCoord4f.
Also, ES does not supports Quads ( Only Tri's ).
Is there a way to achieve this effect on OGL ES ?

I have read about the algorithm "[background=rgb(247, 247, 247)][font="verdana, helvetica, sans-serif"][size="2"][color="#000000"]Direct Linear Transform" but I'm not sure it is possible for a quad that built up from 2 triangles.[/font][/background]
What effect? That page is explaining how texture mapping works, also it's doing so using a quad made out of 2 triangles.
The issues you brought up are not issues at all. A texture coordinate is a texture coordinate, so even if you cannot use glTexCoord, you still have access yo vertex arrays, and whether or not you draw quads or triangles, the effect is still the same given the same coordinates.
I'm sorry, I'm confused... I have read to many resources, and I think I mixed them all.

this is the quad I defined:

<code>

SetPoints( vec3<float>(-20.0f , -10.0f, 0.0f),
vec3<float>(-10.0f , 10.0f, 0.0f),
vec3<float>( 10.0f , 10.0f, 0.0f),
vec3<float>( 20.0f , -10.0f, 0.0f) );

vTxCoords_.push_back(vec4<float>( 0.0f , 0.0f,1.0f,1.0f));
vTxCoords_.push_back(vec4<float>( 0.0f , 1.0f,1.0f,1.0f));
vTxCoords_.push_back(vec4<float>( 1.0f , 1.0f,1.0f,1.0f));
vTxCoords_.push_back(vec4<float>( 1.0f , 0.0f,1.0f,1.0f));

// Populate the indices for 2 triangles
Face s;

s.uIndex[0] = 0; s.uIndex[1] = 1; s.uIndex[2] = 3;
pGeo->vFaces.push_back(s);

s.uIndex[0] = 3; s.uIndex[1] = 2; s.uIndex[2] = 1; // also try s.uIndex[0] = 3; s.uIndex[1] = 1; s.uIndex[2] = 2;
pGeo->vFaces.push_back(s);
</code>

the shader is a simple shader that uses texture2D function (texture2D( DiffuseColor, vOutTxCoords.xy ).rgb;)

I have tried the set the textCoord manually, but failed.
You're not setting the q-value of the texture coordinate as described in the link. I would say the value for the narrow part of the quad should be 0.5, not 1.0, since that part is half the size of the opposite side of the quad.

edit: The s and t coordinates need to be 0.5 as well, not only the q-coordinate.
I tried a brute force method, I denied a key for each coord of the texture ( for each vertex ), and tried to set them manually.

every combination that I do, I get a broken texture. looks like the texture is not interpolated as one quad.

(btw: how can I upload a photo to this forum ? )
If you go to the full text editor (not the one on the bottom of the thread-page; click "More Reply Options") you have the option to attach files to your post.
Well. you can easily spot the two triangles.

I have played with the textCoord of each, but I can't make them to fit right.

This topic is closed to new replies.

Advertisement