Forget the Index Buffer?

Started by
4 comments, last by 21st Century Moose 11 years, 2 months ago

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!

Advertisement

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. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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?

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. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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.

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).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement