# Which should be faster: 10 flat shaded polygons or 2 with a transparent texture

I have particle system, and I want to the individual particles to take the shape of a star. Which should be faster: Drawing the 10 polygons using a flat shader, or 2 polygons (a square) with a partially transparent texture?

• Any answer is going to vary so widely based on hardware, your particle code, and whether the room is hot or cold as to be useless. All you can do is create test cases and measure the performance on the hardware you want to support. (This is one reason why game devs LOVE consoles, you have exactly one hardware configuration to support and optimize these kinds of things for). Nov 21 '11 at 23:13
• Agreed. Profile it and find out! Nov 21 '11 at 23:33
• @TrevorPowell That kinda depends on what kind of star he's drawing =) Also, depending on the number of particles, this question might be irrelevant, as both methods have rather low requirements per primitive. Nov 22 '11 at 7:06
• @Trevor if T-junctions are allowed, only four triangles are required. Nov 22 '11 at 11:23
• @Sam I feel a little silly for not seeing the four triangle solution, before. Well spotted! xD Nov 22 '11 at 20:15

10 flat shaded polygons is pretty much guaranteed to be faster than the 2 transparent textures from a GPU pov. Especially true when you don't have unified shader architecture, as you'll almost always be bottlenecked by pixel shader throughput for particle systems. Unless you're doing anything fancy, your vertex shader in this case is likely fewer cycles than a single pixel, and that doesn't even account for the alpha blend.

Two polygons with a texture is faster.

Why?

Because it is the typical way to do things. If you're working in 2D then you can just use SpriteBatch. And for 3D, here is a sample that you could reuse (one of many you could find online). By reusing this existing method and perhaps code, you will save yourself a lot of time researching, designing, and implementing an alternative system.

You'll also be saving your artists time. Making a texture is much easier than making a model, even a simple one.

... oh you meant runtime performance ...

• Runtime performance? Good luck with rolling something as heavily optimized as SpriteBatch. Your argument still holds. Nov 22 '11 at 11:21
• Yeah, i guess I should have mentioned that I meant runtime performance when i said faster Nov 22 '11 at 23:34
• Actually that was pretty clear... I figured the subtle sarcasm was a nice alternative to the usual rant about premature optimisation. Nov 23 '11 at 2:18

I'm just going to chime in with my POV on this.

As you mentioned in a comment, there is a 4-triangle star,

Now the question is whether to use this 12-vertex, 4-face star (I wouldn't use an index buffer because that would only be a savings of 2 vertices/prim the way I've constructed it here), or to use a square polygon with 2 triangles and use a texture on top.

I'd bet your horses that untextured polys will give you much better performance. But going with the textured quad is probably a better idea for the reason of flexibility alone: Using a texture gives you additional flexibility to change your mind about the shape of the object, with no runtime performance change, if you were to change the texture.

You could also use your same particle engine with different textures to achieve different effects. For example, the traditional "ball-shaped" particle will plug into your texture-based particle engine quite easily without requiring you to make many changes. So using a texture makes your particle engine easier to reuse in that way.