views:

144

answers:

3

Hello!

Right my own 3d engine (which I'm currently developing) has a very limited abilities in terms of geometry rendering and I want to expand it.

What I'm interested in is how-it-should be done in terms of storing the geometrical objects and drawing them.

For now my abstraction only supports rendering geometry as generic lists of triangles (D3DPT_TRIANGLELIST in Direct3D terms). There are couple other ways of representing the objects - such as triangle strips (D3DPT_TRIANGLESTRIP) or triangle fans (D3DPT_TRIANGLEFAN).


My question is - are they actually used when drawing geometry in modern 3d engines?

How can their usage benefit and do they somehow fit in the game creation pipeline? (I mean, like, can artists develop their models so that they're utilizing these strips/fans techniques?)

+4  A: 

Triangle strips are extremely common, since they can represent surfaces more efficiently than triangle lists. Also, you can stitch together triangle strips that are visually separate so that entire disjoint geometries can be rendered as a single strip. You can do this by duplicating the last vertex of the first strip and the first vertex of the second strip, thus creating two degenerate triangles that bridge the gap but don't render.

Fans aren't so common. They can come in handy for drawing convex polygons, but even those can usually be done just as efficiently with strips.

Marcelo Cantos
Also now graphics APIs expose special indice values that avoid you to do such tricks, see my answer.
Stringer Bell
+2  A: 

The benefit is that they reduce the amount of data that must be transferred to the rendering engine. To send N triangles in a list would require specifying 3*N points; if they can be represented as a strip or fan, then you only need to specify N+2 points

Mike Seymour
+2  A: 

There are couple other ways of representing the objects - such as triangle strips (D3DPT_TRIANGLESTRIP) or triangle fans (D3DPT_TRIANGLEFAN).

My question is - are they actually used when drawing geometry in modern 3d engines?

TriangleStrip are used frequently for terrain rendering or other type of meshes with conjuction of restart strip indices (0xFFFF or 0xFFFFFFFF) or degenerated strips. They offer the best ratio in terms of triangles per indices storage. And if you have good vertex cache optimized meshes, they will totally rule the world.

TriangleFan are present in D3D9 but have been removed from D3D10 and D3D11. My advice, avoid using them. The reason they are no good anymore is because they do an awful job as far as attributes interpolation are concerned (such as texcoord or normals), because you can do very thin and elongated triangles with them.

You can argue you can do that too with strips or triangle lists, yes of course, but actually the ability to do fans lead to not friendly (artefact wise) meshes. By removing it from D3D, content creation tools will probably output tesselation that avoid lenghty triangles that have acute angles.

Long and thin triangles are also bad (performance wise) because it generates suboptimal quad fragments during rasterization process (see excellent Humus post on triangulation).

Of course this advice apply if you are coding a high performance/ high quality rendering engine, if you are doing hobby code, you want maybe not care of this that much.

Stringer Bell