Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Situation: I've been trying to gradually get a lower and lower level of understanding of how games work, and lately I've been following Rastertek's DirectX 11 tutorials. Of course, I started branching off on my own and experimenting, like a good little programmer.

I noticed that the tutorial had a set of 3 vertices for each triangle, even if that meant duplicating vertices that were there anyway. So a cube would have 12 triangles * 3 vertices/triangle = 36 vertices, when it only needed 8. This seems like it could reduce performance by quite a bit in more complicated models.

However, when I tried setting the indices to reuse vertices, I ran into problems because the normal and UV coords are assigned to each vertex. I averaged the normal vectors, which resulted in smoothing the lighting where it probably shouldn't have been smooth, and UV coords...well...right now they overwrite each other as they're importing, which results in crazy things, like so: http://i.stack.imgur.com/Rr6aB.jpg

My thoughts: Right now, I see one reasonable solution. When UV mapping in Blender, I had to create "seams", which the model was unwrapped around and blah blah, I'm sure you know what that is. Anyway, I could duplicate the vertices on these seams only, which would solve both performance and texturing quite nicely.

This wouldn't require much change in the code I currently have, but Blender's exporting algorithms don't seem to cooperate with this approach. At least not with the .obj format. Getting this approach to work correctly looks entirely possible, but also annoyingly difficult.

Finally, the question: So now I'm here, typing to you people. Am I on the right track? Or is there an entirely different approach I haven't thought of yet? What is the normal way of doing this?

Of course the other question is, will duplicating vertices like that really have a significant impact on performance? My very premise could be mistaken.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Performance shouldn't be affected at all, it'll just take up a small amount of extra memory. The hardware draws triangles independently, the only difference between the two is that the one without duplicates will just be reading multiple times from the same memory address while the one with duplicates will read from separate memory addresses.

While it may seem like a waste, it's necessary because those vertices are unique. There's more in a vertex than just the position. Two vertices with the same position but different texture coordinates/normals are not the same vertex.

share|improve this answer
    
I was almost hoping that wasn't the case, so I wouldn't look like an idiot, but that does make sense. And I haven't seen memory be much of a limiting factor since the WinXP days, so I don't see a need to worry about that. –  Icy Defiance Feb 9 '13 at 21:14
    
Creating seams means adding more draw calls, which are hugely expensive. You're over-thinking and solving a problem that doesn't exist. Robert's answer is correct in all cases. –  Patrick Hughes Feb 9 '13 at 21:16
    
Yeah, most machines have more than enough VRAM, and you could always just load lesser detailed meshes on machines without enough memory. –  Robert Rouhani Feb 9 '13 at 21:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.