Sign in to follow this  
Tispe

Forget the Index Buffer?

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this