2

I am using Direct3D to display a number of I-sections used in steel construction. There could be hundreds of instances of these I-sections all over my scene.

I could do this two ways:

I-Sections

Using method A, I have fewer surfaces. However, with backface culling turned on, the surfaces will be visible from only one side. If backface culling is turned off, then the flanges (horizontal plates) and web (vertical plate) may be rendered in the wrong order.

Method B seems correct (and I could keep backface culling turned on), but in my model the thickness of plates in the I-section is of no importance and I would like to avoid having to create a separate triangle strip for each side of the plates.

Is there a better solution? Is there a way to switch off backface culling for only certain calls of DrawIndexedPrimitives? I would also like a platform-neutral answer to this, if there is one.

4

4 回答 4

1

In OpenGL you can switch of backface culling for each triangle you draw:

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
// or
glCullFace(GL_BACK);

I think something similar is also possible in Direct3D

于 2008-10-27T09:13:36.947 回答
1

First off, backface culling doesn't have anything to do with the order in which objects are rendered. Other than that, I'd go for approach B for no particular reason other than that it'll probably look better. Also this object probably isn't more than a hand full of triangles; having hundreds in a scene shouldn't be an issue. If it is, try looking into hardware instancing.

于 2008-10-27T09:13:50.863 回答
1

If your I-sections don't change that often, load all the sections into one big vertex/index buffer and draw them with a single call. That's the most performant way to draw things, and the graphic card will do a fast job even if you push half a million triangle to it.

Yes, this requires that you duplicate the vertex data for all sections, but that's how D3D9 is intended to be used.

于 2008-10-27T09:32:33.647 回答
1

I would go with A as the distance you would be seeing the B from would be a waste of processing power to draw all those degenerate triangles.

Also I would simply fire them at a z-buffer and allow that to sort it all out.

If it get's too slow then I would start looking at optimizing, but even consumer graphics cards can draw millions of polygons per second.

于 2008-10-27T13:35:39.867 回答