Jump to content
  • Advertisement
Sign in to follow this  
FordPrefectA

Using texture Coordinates per vertex or per triangle vertex?

This topic is 2780 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

I've been reading Frank Luna's DX10 book and he defines a new vertex for every vertex in a triangle even when it means having two or more vertices overlapping at the corners of intersecting triangles. This allows him to define a unique uv for each overlapping vertex so that each triangle has a unique set of UV's.

When I import data using the FBX SDK I get vertices, indices, and texture coordinates unique to every vertex in a triangle- in other words I get all the data I need to render it properly. However there are no repeats in the vertices so I would have to go through each poly and make unique new vertices for every new instance a vertex is used. I was wondering if this is a good idea or not since it seems to nullify one of the advantages of having indices in the first place, so that you can reference vertex data instead of duplicating it, but the way DirectX is setup UV's have to be passed with the vertex.

Share this post


Link to post
Share on other sites
Advertisement
You want to repeat data where you can, and duplicate data where you must.

Most triangles will be fine sharing a vertex, because their UV's are the same. However in some cases you will need to duplicate vertices, say on edges where different faces have different textures. If your data in the file format is organized a different way, you'll have to do some rearranging to get it in the correct format. This is the same whether you're using DX9/DX10/DX11/OpenGL/etc, all graphics hardware works this way regardless of API.

Share this post


Link to post
Share on other sites
Does that mean there's something wrong with the data I'm getting or how I'm getting it since the same vertex on different triangles sometimes has a different UV but there is only one texture applied to the whole mesh with a uvw unwrap applied?

Share this post


Link to post
Share on other sites

Does that mean there's something wrong with the data I'm getting or how I'm getting it since the same vertex on different triangles sometimes has a different UV but there is only one texture applied to the whole mesh with a uvw unwrap applied?


No. Karwosts provided an example, but it is not the only case. If one of your vertices has faces that are pulling from different areas of a texture they may well need different UV cords.

Share this post


Link to post
Share on other sites
For mesh data, you will often see a list of vertices, a list of normals, and a list of UVs. They can all be different sizes. Models have edge splits to control smoothing and UV seams.

You can unwrap a cube and get it to a nice 't' shape inside the texture map, but that wastes a hell of a lot of image space. If you cut seams into the cube, each face can have it's own unique UV space, and use 1/6th of the texture map. You don't waste texture space this way, and you get to use more texels per face! So you'd have 8 vertices, but 24 UVs. If you used edge splits to keep the sides sharp, you can also have 24 normals.

A complex more model might have tons of seams and edge splits.

Random example image from google: http://goanna.cs.rmit.edu.au/~gl/teaching/Interactive3D/2011/images/uv-unwrap.jpg <-- seams galore!

Lots of architectural models will also share UVs because they are made of repeating sections. The modeler will make a few modular parts, texture them with the same file, and then repeat them and merge them into one model. In this case you may have more vertices than UVs!

Share this post


Link to post
Share on other sites
Posted · Hidden
Hidden

This is the same whether you're using DX9/DX10/DX11/OpenGL/etc, all graphics hardware works this way regardless of API.


Well not really...once you get into DX10 territory you have many more options available to you through the use of geometry shaders and generic buffer/texture reads. So for instance you could have position data at the per-vertex level, and UV's at the per-triangle-vertex level.

Share this post


Link to post
Thanks for the replies. I tried making a new vertex for every single instance of a vertex in a polygon where each has its own unique normal and UV. It works fine for a cube but if I take a cube and extrude a side then map that, the geometry appears warped in DirectX. If I apply a Turn to Mesh modifier and re-export the geometry loads successfully but the texture appears warped. Does anyone know what may be happening? I have a feeling it may have something to do with edge splits, control smoothing, and UV seams like you said but I'm not sure how to deal with those.

Share this post


Link to post
Share on other sites

Thanks for the replies. I tried making a new vertex for every single instance of a vertex in a polygon where each has its own unique normal and UV. It works fine for a cube but if I take a cube and extrude a side then map that, the geometry appears warped in DirectX. If I apply a Turn to Mesh modifier and re-export the geometry loads successfully but the texture appears warped. Does anyone know what may be happening? I have a feeling it may have something to do with edge splits, control smoothing, and UV seams like you said but I'm not sure how to deal with those.


warped is not a very descriptive term... perhaps post an image?

Share this post


Link to post
Share on other sites
How it should look (from max)
warp01.th.jpg

Loaded in DirectX
warp02.th.jpg

After applying a turn to mesh modifier and loading in DirectX
warp03.th.jpg

After taking these shots I also noticed that it loads mirrored in one axis for some reason. When exporting the FBX from max I chose to convert the up axis to Y as it is in DirectX.

Share this post


Link to post
Share on other sites

When exporting the FBX from max I chose to convert the up axis to Y as it is in DirectX.

Minor point, but 'y' isn't actually up in DirectX; DirectX doesn't specify an 'up' axis for world space.

The y axis is up in view space, but that's a different issue.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!