Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jLeslie

UV mapping in D3D

This topic is 6918 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 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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • 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!