Jump to content
  • Advertisement
Sign in to follow this  
vbisme

OpenGL Shared(indexed) vertices and tex coord

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let's say that I want to create a rectangle using indexed vertices. Thus, I would only have 4 vertices and 6 indices or two faces. Assume vertices are setup as follow: 1----3 | | | | 0----2 Index list would be: { 0, 1, 3, 0, 3, 2 } This is all fine until texture coordinates are considered. Let's say I want the texture coordinate for vertex 0 and vertex 3 to be different for the two different face. In Direct3D, the texture coordinate are defined with the vertex information. How would I have to change the texture coordinate before drawing each face? I seen in an MD3 loading example using OpenGL in which texture coordinate indexing are used in assosiation with each face. In OGL, submitting vertex information this way maybe done like so (psuedo code): BeginTri Vertex1(...) Vertex2(...) Vertex3(...) TexCoor(..) EndTri Thus, the texture coordinate does not have to be stored with the vertex and are applied during look up. What are good solutions to this? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I'm currently having big problems exporting datas from Maya to DirectX, just because of the problem you mentioned.
The solution (if you can call this one) is to duplicate your vertices. As you say, in DirectX a vertex contains its position, color, normal, texture coordinates, etc. and if, for the same position, you have 2 different UVs (due to 2 different uv islands for example) then you have to create a second vertex which will have the same position, normal, etc. to store the 2d uv.

Don't know if i'm clear, so don't hesitate to ask again if you don't understand my answer ^^

.:: Paic Citron ::.

Share this post


Link to post
Share on other sites
Makes sense, but the point of using indices to to eliminate vertex duplication?

Anyway, if we duplicate the vertices are pack them into say a vertex buffer, the faces(indices) information have to change as well to compensate for the added vertices.

No better solution?

Share this post


Link to post
Share on other sites
You have to duplicate vertices. It would be convenient to have an seperate index lists for vertex pos, texcoords, colour, and so on, but the overhead isn't worth it. Duplicating a few vertices uses less memory and is a lot more cache coherent than seperate index lists for vertex components.

Share this post


Link to post
Share on other sites
My question for the vertices duplication is, sticking with the original example I posted, the vertex list duplicated would be:

Vertex 0a, Vertex 0b, Vertex 1, Vertex 2, Vertex 3a, Vertex 3b

So vertex 0 and vertex 3 are duplicated, the index(face) this would then have to be changed.

Original:
{
0, 1, 3,
0, 3, 2
}

Changed to:
{
0, 2, 4,
1, 5, 3
}

Am I thinking in the correct way?

How about using dynamic vertex buffer and do the modification. Would probably kill performance by a great deal wouldn't it.

[Edited by - vbisme on February 13, 2005 12:47:51 AM]

Share this post


Link to post
Share on other sites
You're just going to have to duplicate your vertices; no other way around it. You're correct that index buffers are designed to get rid of duplicate vertices, but only when the vertices are entirely identical, which unfortunately includes texture coordinates too. As outRider indicated, it's simply not very useful at the moment to design hardware/drivers in such a way as to allow what you want to do. So just assume that duplicating your vertices is the best way to go. Besides, it shouldn't happen in huge quantities; most of the vertices in models with a significant number of triangles share texture coordinates anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!