I've read that texture coordinates are applied on a triangle/face basis. I've been storing them on a polygon mesh basis and referencing them from face indices.
Wouldn't applying texture coordinates per face, create a lot of vertex duplicates? Not only does that increase the size of the file but I would think it decreases rendering effecientcy by supplying vertex duplicates.
The problem with my current setup is, when I actually need seperate uvs or normals, I have to use the polygonmesh itself as a face.
Any advice? I'm hoping the vertex duplicates aren't as bad as they sound.
Texture Coordinate Storage within Model
Can you try to explain this more?
I'm not familiar with your terminology, or what you mean to use a 'polygonmesh itself as a face'
Typically you store UV coordinates per vertex, and face indices point to unified vertices (position,normal,texcoord). Data duplication is required anytime any part of the unified vertex varies to use hardware buffers on GPU.
Quote:
I've been storing them on a polygon mesh basis and referencing them from face indices.
I'm not familiar with your terminology, or what you mean to use a 'polygonmesh itself as a face'
Typically you store UV coordinates per vertex, and face indices point to unified vertices (position,normal,texcoord). Data duplication is required anytime any part of the unified vertex varies to use hardware buffers on GPU.
This is pretty much a simplified version of what I'm doing
+ PolygonMesh/ Triangle Mesh
--Vertices
--Material Data etc..
-+Faces
---Indices
Here's a version of what I think is more common
+Mesh
--Material Data etc...
-+Faces
---Vertices
---Indices (if faces are not triangle only)
I would need duplicate data whever parts of the vertices change but with the second setup I'm guaranteed duplicate data. But of course if that isn't a big deal I don't really mind.
Lots of things seldom need seperate uvs and normals, like character models.
+ PolygonMesh/ Triangle Mesh
--Vertices
--Material Data etc..
-+Faces
---Indices
Here's a version of what I think is more common
+Mesh
--Material Data etc...
-+Faces
---Vertices
---Indices (if faces are not triangle only)
I would need duplicate data whever parts of the vertices change but with the second setup I'm guaranteed duplicate data. But of course if that isn't a big deal I don't really mind.
Lots of things seldom need seperate uvs and normals, like character models.
Hi,
In OpenGL, normals, texture coordinates, color, etc. are all specified per-vertex--the intermediate calls simply change OpenGL's state. If you want to specify per-face texture coordinates, OpenGL will simply specify the same texture coordinate at all three vertices.
In code:Is exactly the same as:In both cases, the texture coordinate (1,0) will be applied for each vertex--each vertex storing its own copy of (1,0), which was the current state of OpenGL at the time.
You can make your own optimized model loader that only changes the OpenGL state when necessary (i.e., the second block of code), but generally, each of the parameters you're using are specified per-vertex.
Ian
In OpenGL, normals, texture coordinates, color, etc. are all specified per-vertex--the intermediate calls simply change OpenGL's state. If you want to specify per-face texture coordinates, OpenGL will simply specify the same texture coordinate at all three vertices.
In code:
glTexCoord2d(1.0,0.0); glVertex3d(0.0,0.0,0.0); //Sets the texcoords to (1,0), then issues vertex with the current texture coordinate (1,0)glTexCoord2d(1.0,0.0); glVertex3d(1.0,0.0,0.0); //Sets the texcoords to (1,0), then issues vertex with the current texture coordinate (1,0)glTexCoord2d(1.0,0.0); glVertex3d(1.0,1.0,0.0); //Sets the texcoords to (1,0), then issues vertex with the current texture coordinate (1,0)
glTexCoord2d(1.0,0.0); //Sets texcoords to (1,0)glVertex3d(0.0,0.0,0.0); //Issues vertex with the current texture coordinate (which is (1,0))glVertex3d(1.0,0.0,0.0); //Issues vertex with the current texture coordinate (which is (1,0))glVertex3d(1.0,1.0,0.0); //Issues vertex with the current texture coordinate (which is (1,0))
You can make your own optimized model loader that only changes the OpenGL state when necessary (i.e., the second block of code), but generally, each of the parameters you're using are specified per-vertex.
Ian
There seems to be a consensus that uvs are stored per vertex. My source is actually wikipedia so it's definitely possible the article could be wrong in a general sense.
Do all graphics APIs internally do that? I'm using XNA which is probably the same for DirectX. If that's the case, my point would be more or less moot.
Quote:
UV coordinates are applied per face[2], not per vertex.
Quote:
In OpenGL, normals, texture coordinates, color, etc. are all specified per-vertex--the intermediate calls simply change OpenGL's state. If you want to specify per-face texture coordinates, OpenGL will simply specify the same texture coordinate at all three vertices.
Do all graphics APIs internally do that? I'm using XNA which is probably the same for DirectX. If that's the case, my point would be more or less moot.
The texture coordinates should be per vertex. However if you want two faces that share vertices to use different texcoords, than just duplicate the vertices to achieve the same thing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement