Combining meshes to save performance

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm programming some simulation software (not game, but Managed DirectX-based) which has to display a produced 3d-model. This model is built of lots of small meshes, 8 vertices each. There are so many anyway, that the programs gets very slow FPS or even runs out of memory. As the most of those meshes build up simple planes, sometimes with holes or so, i want to combine them into ones (like logical "OR" in 3D-Editing software) and remove vertices which are connected and not needed. Does someone have and algorithm or a library for this? I'm getting really short on time by now... Thank you

Share on other sites
Usually programs like Maya, Max or LightWave does have tools, otherwise plugins, for that.

But besides that, you said you render everything with little meshes of ~8 vertices. That's not really an effective way to do it. Just like in the industry, we like big batches. If possible, try to sort your meshes on material. If everything would have had the same material/texture, you apply the material only once, and then pass 1 big array of vertices (and eventually additional array's with normals/texcoords/...) to the graphical card.

In case each little mesh has different material options, you might want to think of combining materials. You can put multiple textures into 1 bigger texture and modify the texture coordinates so you still access the texture like you originally did. In case of vector/scalar shader parameters, you can make an additional array and put them there and pass along with the vertices, instead of changing paramters for each mesh that's going to be rendered. The less materials/texture switching, and the bigger the vertex array's, the better. I think you can win ALOT with that (how many polygons is your model anyway)?

If you manage to make relative big batches, you can also think about using Vertex Buffer Objects, compiled lists (don't know the DirectX name for that), or using indices. The VBO technique puts your geometry data into the graphical card memory. So instead of pushing these (huge) array's each time from RAM to Video Memeory (with the help of CPU), you just call the VBO and it can be directly accessed from the Video Card memory.

Indices is a technique that allows to work with less polygons. Imagine a cube. 6 faces = 12 polygons. Each polygon has 3 vertices, so you have 12*3=36 points in total. Somewhat of a waste, isn't it? I only count 8 points if I look at a cube... With indices, you seperate the polygons and vertex coordinates. First you pass a list of (unique!) coordinates (that would be 8 for a cube). Then you pass a list with integer numbers that are index to that vertex-array. This array has 36 integer numbers. For somewhat bigger batches, you save memory and pass less data = faster.

Greetings,
Rick

Share on other sites
There are no materials at all, it's just color, and I use index buffers in meshes. But as there are about 14000 those 8-vertices meshes a layer, x like 30 layers, there is no way to display it like that. Instead I want to calculate a mesh that looks the same as those meshes together, for example it can be a simple box built of all those meshes (they are parallel and overlapping each other in a lair), so i would like to see just the box with its 8 vertices instead of every single mesh..

And Maya isn't an option coz I have to deliver a complete software which can show a ready-to-use model..

Share on other sites
Easy peasey:

psuedo, assuming indices are used:
vArray = new vertex array;iArray = new indices array;for each object as OBJ{  vArray.push(OBJ.vertices);  for each OBJ.indices as IND    iArray.push(totalIndicesSoFar + IND)  totalIndicesSoFar += OBJ.indexCount}

This would make one giant mesh that you send/store as a VBO and render all at once.

Vertex reduction ("several boxes in formation creating only 8 vertices") you should google around, since I don't have a clue. ;)
The basic priciple, I guess, is to combine triangles that are within a certain threshold based on angle, height variation etc.

/Robert

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• Forum Statistics

• Total Topics
631419
• Total Posts
2999983
×