UV mapping in D3D

Started by
2 comments, last by jLeslie 23 years, 11 months ago
I just started writing a program to load Truespace .cob files for use with D3D and I was looking through a text version and ran into a little problem. The model I was looking at has 3168 vertices and 3191 pairs of UV coordinates. My question is, if D3D stores 1 pair of UV values per vertex, what do I use the extra UV values for?
Advertisement
What are they used for in TrueSpace? Admittedly I don''t know squat about TrueSpace but I can''t think of any reason why you would need more UV values than vertices. Unless of course you use multiple textures.

The file format must have some reference connecting the UV values to the vertices, use that reference to assing the UV values and ignore the values that aren''t used.

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I am writing a plugin for Truspace and found the same problem. I think the extra vertices are where two or more faces share the same vertex and are using textures. I''m not sure the best thing to do though. In D3D you can either duplicate vertices or use the multiple texture coordinate feature (SetTextureStageState stuff). I''m not too sure how to use the multiple texture coordinate feature of D3D myself. It sounds simple in that you use a vertex structure with more that one u/v pair. However, does this mean you use different vertex formats in an application or use a vertex format that has the maximum number of u/v pairs? Things can get complicated. In order to reduce render state changes, it makes sense to group triangles by texture. Do you then have to group by vertex format within texture?

Sorry, I know I am not helping and just answering your question by asking several more. But these are problems you will have as well, and may be someone out there can help us both.

Regards.

John.
Yes, of course that must be the reason for the extra UV values. Why didn''t I think of that.

To solve this in D3D I would not recommend using multiple texture coordinates, since that would waste a lot of space, and not save much time. If you are using HW T&L you may even loose time this way since the extra values has to be transported to the card as well. Besides, you will most likely want to save the texture coordinates for multitexturing (Lightmapping, Bumpmapping, Detailmapping, etc)

Instead you should duplicate the vertices that have two or more UV values. It would require some more vector transformations but I don''t think the performance impact will be that big.

johnp is right, you should group triangle by texture. In addition to that you don''t want to change vertex format during rendering because that usually requires the command buffer to be empty first, causing a lot of delay.



- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement