Multiple UV's and Normal's per Vertex

Started by
2 comments, last by WedgeMan 13 years, 4 months ago
Hi All,

I'll use a basic example where I'm loading an OBJ file of a cube that has a texture applied.

The Cube has 8 vertices to create the geometry, however this particular cube has 14 sets of UV coordinates. So the vertex should use UV set X when rendering Triangle X and UV set Y when rendering Triangle Y.

The issue is that with Shader programming, I can only upload vertices and indices to their respective buffers. There doesn't seem to be any way to assign multiple UV's to the same vertex and pass in a "Face" buffer.

Am I missing something here or is the correct architecture decision to store the 8 Vertices and store the UV's separately and then have a Face buffer that holds the relations between them.

Then when I send that object to the GPU to be rendered, the vertex buffer will actually have duplicated Vertices (in terms of x,y,z) but with different UV's and the index buffer will essentially be my face definitions?

I can't think of any other way around it, but it seems to be eliminating the whole point of vertex/index buffers in the first place which is to reuse existing vertices.

Thoughts? Thanks!
Advertisement
You can reuse existing vertices when they are the same vertex, and when I say vertex, I'm talking about ALL properties of the vertex (position, color, uv's) must all be the same.

This is quite common, most often a vertex will be shared by multiple faces and the uv/normals/color/position will be the same for each face.

However your case is different, what you really have is 14 vertices, if you have 14 unique texcoords. You can't really reuse them in this case, because a cube is pretty minimal. If you have a cube that's tessellated 100 times on each face, then you can reuse most of the vertices.

There's no such thing as a 'face' buffer. You have an index buffer, and a vertex buffer (which contains ALL properties of each vertex). So you have to duplicate your positions in this case.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
This is one of the oddities of the Wavefront OBJ format.

The correct way to load these OBJ files is to build a list of faces and generate a final list of verticies duplicating norms/tc's as required.

you should also know, the OBJs Face's are not guaranteed to be triangles, they are allowed to be arbitrary-n polygons.
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
Right, ok so that's what I thought but just wanted to be sure.

Appreciate the quick replies!

This topic is closed to new replies.

Advertisement