Jump to content
  • Advertisement
Sign in to follow this  
utkua

multiple uv for each vertex?

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

Hi, I have written an exporter using max script to be able to use models in my program. In d3d there are one uv coordinate for each vertex, but in max each face have different uv coordinates for each vertex it have which means a vertex in max have multiple texture coordinates for a single map! To create the same effect I have to export each map face with different mesh vertexes, which will lead multiple vertexes at the exact same location. This seems ridiculous to me... Am I missing something here? Is there a way to make max use a single uv for a mesh vertex, as we do in d3d.

Share this post


Link to post
Share on other sites
Advertisement
Well, D3D doesn't require you to only have one uv per vertex, it's all dependant on how you present your vertex format to it. Change your vertex structure/class to store an additional uv then alter your vertex declaration to reflect this.

A simple example (excluding normals and such):


struct Vertex
{
Vector3 Position;
Vector2 TC[ 2 ];
}


D3DVERTEXELEMENT9 Decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
D3DDECL_END()
};




BTW, next time post a D3D question in the the DirectX forum.

Share this post


Link to post
Share on other sites
thanks for the reply,

Even I keep different coordinates within a vertex it does not seem possible to match face's member with the right texture coordinates of vertex without additional info. Keeping texture coordinates on face information is much more convenient. But if I do that I have to draw faces by iterating. So I can not use DrawIndexedPrimitive for more than 1 face, this will make it slower.

> BTW, next time post a D3D question in the the DirectX forum.

Sorry, I was not sure if I am missing someting spesific to d3d or texture mapping.

What I am looking for is what kind of approach is used for arbitrary mapping for each face needed when performance is an issue. And how it is done in games. Or do they avoid this bu not using at all.

Sorry if my confusion makes me saying someting totally irrelevant :)

Share this post


Link to post
Share on other sites
Sorry to inform you, but multiple vertices at same location are unavoidable.

While exporting you'll need to find out how many different texture coordinates there are for each vertex and then you'll have to make as many copies of the vertex as there are coordinates.

It sucks, but that's the way the GPU's work.

Cheers!

Share this post


Link to post
Share on other sites
> Sorry to inform you, but multiple vertices at same location are unavoidable.

You are right. I have started redefining my structures to make faces hold its vertices.

Share this post


Link to post
Share on other sites
i don't use max myself but i heard of an interface (i thnk it's just CGame or sth like that) that already arranges your vertices in an d3d friendly way.

Share this post


Link to post
Share on other sites
There is I think little confusion here... There are two reasons you would have multiple UVs for a single position..

If there is a "seam" in the model, for examlpe the case of a cube with different textures on each face. Then each corner point will have three UVs, once for each face that intersects that point (as that point will have different UV mapping for each face). The usual way this is handled (at least in DirectX) is, in the export process, generating three vertices for each corner point, each vertex will still have one UV however.

The other situation is when you need multiple textures, with different UV mappings (e.g a lightmap that has a different UV mapping to the diffuse map). In this case you need multiple UVs per vertex.

Share this post


Link to post
Share on other sites
Thanks for making it clear, so the additional UVs on a vertex are for texture blending. Also I have noticed that trying to use single uv for each vertice is simply impossible while texture is not suitable for tiling, becouse if i use single uv for each vertex texture have to become mirrored in the following side.

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!