Large amount of small shapes, drawing effecently

Started by
2 comments, last by ChristianFrantz 10 years, 8 months ago

I have a large amount of very small shapes(most under 10 vertices) that are created and destroyed constantly. Many of the shapes are just repeats and there are only a small number of shape types, but they all move and rotate independently. Think Geometry Wars style game.

Would Vertex/Index Buffers be most efficient way of handling this? Should I have 1 large buffer that points are added to and removed from constantly, and the objects simply hold a reference to the points to update their positions? Or have a smaller buffer with only one of each type of shape and each object can hold a different translation matrix for drawing the shape at the proper location and angle? Or should each object be given its own buffer from a pool of preexisting buffers.

Are Vertex/Index Buffers not even the best choice in this case?

Advertisement
You should look into hardware instancing in Xna. You'll find a huge ammount of tutorials online.

Co-Founder of Tesseract Interactive.

Check out our project Excubitor on http://excubitorgame.com and http://www.indiedb.com/games/excubitor

start with brute force (just draw them all), and if its not fast enough switch to hardware instancing, unless you already know brute force won't be fast enough.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I'm in the same situation you are. As an example, I use cubes. I gather all vertices and indices from each cube and store them into a SINGLE vertex buffer. Doing this will help a lot with frame rate. I wouldn't use hardware instancing if you're going to be updating the objects frequently, but I'm only saying that based on my project. I don't know what kind of shapes you're using so it could be helpful. I've never used hardware instancing so don't take my word for it. In my opinion, storing everything in a single buffer is the way to go

And as Norman said, brute force could work best for you. If objects go outside the screen, just remove them. Drawing each object individually would give you easier control over how each object is interacted with, but too many objects will kill your FPS. I had 30,000 vertices with 55-60 FPS. It all depends on how many objects you draw.

If you see a post from me, you can safely assume its C# and XNA :)

This topic is closed to new replies.

Advertisement