Skip to main content
GameDev.net gamedev.net
🔒 Locked

texcoord count is different than vertex count

Started by afraidofdark Apr 19, 2011 at 3:21 PM 7 replies 3.6k views
Original Post
afraidofdark
afraidofdark
Hello,
I try to export a model from 3dmax, but when I try to export the model, I saw that, model's texture coordinate count is more than its vertex count. I believe the reason is, artists make an unwrapping process to best fit the polygons on the texture, during this process they may split or merge some faces, this cause the difference in texcoord count and vertex count. What should I do to render this kind of meshes ? do I have to split or merge actual faces in the mesh too ?
www.lostchamber.com
rouncer
rouncer
Yeh definitely sounds like obj to me.
if you check youll see theres 2 sets of faces, one is for the vertices without texture coordinates, one is for the texture coordinates, you have to convert it all to the same point list using this double face list, you see vertices are being doubled at wrap seams. you can actually load the model up textured or non textured.
SimonForsman
SimonForsman

Hello,
I try to export a model from 3dmax, but when I try to export the model, I saw that, model's texture coordinate count is more than its vertex count. I believe the reason is, artists make an unwrapping process to best fit the polygons on the texture, during this process they may split or merge some faces, this cause the difference in texcoord count and vertex count. What should I do to render this kind of meshes ? do I have to split or merge actual faces in the mesh too ?


this is quite normal, triangles tend to share vertices but don't necessarily share texture coordinates.

Consider for example a cube, it has 8 vertices and 12 triangles, and can easily have 3 texture coordinates per triangle, or 36 texcoords total. (Making a texture that wraps perfectly around a cube is possible but you'll get quite a bit of empty space in the texture as it will effectivly need to be shaped something like:

XXOX
OOOO
OXXX

With the X:es being empty spaces just wasting memory and the O:s represent each side of the cube.

by using more texture coordinates you can make a texture that looks like:
OOO
OOO
Thus being smaller and more efficient.

Thus most model formats will store texture coordinates separatly or per triangle rather than per vertex.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
afraidofdark
afraidofdark
now I am looking at a obj loader to understand how to draw an object using a vertex and index buffer which has more texture coordinate then its vertexes. Here is an output I got from max.

I could easily draw this object if there were 8 texture coordinate by creating a buffer with vertex definition : "vertex|normal|textureCoordinate", however in this case I can't do this, because there are 24 texturecoordinate but 8 vertex. How should I construct a buffer to draw this object ? or what should I do with extra texture coordinates ? I study an obj loader to over come the problem.


by the way I use directx 11 for drawing.

thank you for your replies.


























































































www.lostchamber.com
rouncer
rouncer
hmm, actually i dont know either, is this the "ase" format? obj is easier to understand for me because it has two sets of faces, i dont even know what to do with what youve got!
afraidofdark
afraidofdark

hmm, actually i dont know either, is this the "ase" format? obj is easier to understand for me because it has two sets of faces, i dont even know what to do with what youve got!


I looked at a obj loader, I got the point there must be another index list which is used to select proper texture coordinate. The file I wrote above, is not a known format, I wrote a max script that out put these data. Now I will add another index list for texture coordinates.

However main problem is still remaining, even though I understand that I need another index set for texture coordinates, I don't know how to construct a vertex & index buffer in directx 11 to draw the object. But I'll keep searching example codes.

thank you for replies.
www.lostchamber.com
Burnt_Fyr
Burnt_Fyr

[quote name='rouncer' timestamp='1303244951' post='4800495']
hmm, actually i dont know either, is this the "ase" format? obj is easier to understand for me because it has two sets of faces, i dont even know what to do with what youve got!


I looked at a obj loader, I got the point there must be another index list which is used to select proper texture coordinate. The file I wrote above, is not a known format, I wrote a max script that out put these data. Now I will add another index list for texture coordinates.

However main problem is still remaining, even though I understand that I need another index set for texture coordinates, I don't know how to construct a vertex & index buffer in directx 11 to draw the object. But I'll keep searching example codes.

thank you for replies.
[/quote]

I think perhaps your object has three sets of UV's per vertex, and they are indexed as normal.
afraidofdark
afraidofdark
I solve the problem, I just simply hold all required data per face {3 vertex, 3 texture coordinate, 3 normal for each face}, then reconstruct the faces from that data. I don't use a drawIndexed command, instead I use draw, since all vertexes, normals, texture coordinates are held together in the vertexbuffer, I don't even need to use an indexing mechanism to look up right vertex or texture coordinates. However this approach really increases the buffer size anyway.
www.lostchamber.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.