• Create Account

## Forget the Index Buffer?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Tispe  Members

1419
Like
0Likes
Like

Posted 05 February 2013 - 11:36 AM

Hi

My model viewer application is getting more and more complex and it starts acting up on me, so I really wish to reduce the complexity to avoid alot of recoding. What I find interesting is that most of my vertices are unique, meaning that indexing the same vertex twice is uncommon since they usually need to have different normals.

What I use now is a ID3DXMesh that I fill with vertices and indices. I optimize it and Generate Adjacency on it. But what is the point of all that when most of the indices are mapped 1:1 on the vertex buffer?

Should I just toss out the ID3DXMesh and roll my own class with only the vertex buffer and not the index buffer?

Cheers!

### #2swiftcoder  Senior Moderators

17816
Like
0Likes
Like

Posted 05 February 2013 - 12:16 PM

What I find interesting is that most of my vertices are unique, meaning that indexing the same vertex twice is uncommon since they usually need to have different normals.

You must have some seriously strange models - any contiguous smooth ares in your surface ought to share vertices.

Are you modelling a sea urchin?

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #3Tispe  Members

1419
Like
0Likes
Like

Posted 05 February 2013 - 12:44 PM

Maybe I misunderstand but arent a triangle supposed to have normals perpendicular to its surface?

If two triangles share a side (neighbours), but are not in parallell then the two shared vertices must have different normals?

Are you saying that in a smooth surface, a vertex which is shared between three triangles will have its normal, equal to the avarage normal of three normals each perpendicular to its triangle plane?

Think of a cube (not smooth), should it have 8 vertices, one for each corner (indexed), or should it have 24 vertices (non-indexed) to contain all normals? If the former, where would the normal vector be pointing?

### #4swiftcoder  Senior Moderators

17816
Like
0Likes
Like

Posted 05 February 2013 - 12:55 PM

Vertices should each have a normal perpendicular to the surface at that point. The only place where you need duplicated vertices is where there is a hard corner (or 'crease') in the mesh.

As a trivial example, all edges on a cube are hard edges, so a cube needs vertices duplicated per-face. A sphere is a continuous surface without hard edges, so none of the vertices should be duplicated.

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #5Tispe  Members

1419
Like
0Likes
Like

Posted 05 February 2013 - 04:20 PM

You might be right. I am fiddling with UV maps and trying to map them to a vertex buffer. The catch is that the vertex buffer might be indexed more then once with different UV coordinates.

It seems like a shortcut to just duplicate all vertices, the downside is that it potentially triples the vertex buffer size. Does that translate into a third of the potential performance?

Also, my characters have may equip different gear, and gear may hide other gears subsets and so on, so there are multiple drawcalls on each piece of gear. I am thinking of batching the character into a single vertex buffer where ranges are draw depending on the texture.

### #6mhagain  Members

12436
Like
0Likes
Like

Posted 05 February 2013 - 07:04 PM

If you have multiple draw calls an index buffer may still be useful as it will allow you to concatenate the different primitives and handle everything with a single draw call.  This may or may not involve having to create a dynamic buffer, which will have it's own overhead, but either way - I'd strongly urge you to profile and see if the perf gain from being able to do a single draw call is worth it nonetheless, rather than making assumptions based on memory usage alone (which is quite often not even a valid benchmark).

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.