#### Archived

This topic is now archived and is closed to further replies.

# Index buffer for particle system

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

## Recommended Posts

My partice system is very advanced, events, emitter, renderers can be swapped in/out so it can use point sprites and quads... Now on the quads - I suppose you need an index buffer to get the triangles to draw right. Can someone just post me how to generate this buffer? I could probably do it myself but don''t have time and what is the point in reinventing the wheel? Thanks in advance.

##### Share on other sites
I wouldn''t use an index buffer, there''s not much point. No vertices are going to be shared, and you''re going to be updating them all each frame, so an index buffer would just generate useless stuff to be sent to the graphics card.

Also, if you can''t be bothered to figure out the indices for drawing squares, then you truly are lazy.

---------------------------------------

Let''s struggle for our dream of Game!

http://andrewporritt.4t.com

##### Share on other sites
1) On the issue of whether or not to index:

Assuming each particle is a billboarded quad, if you're rendering a reasonable number of particles, indexed lists CAN be worth it versus non-indexed lists.

For non-indexed triangles, 6 vertices per quad need to be sent to the GPU and 6 vertices per quad have to be transformed (and lit if you're doing that).

With indexed triangles you get 4 vertices being sent to the GPU and 4 transformed per quad. The indices do take up extra bus bandwidth to transfer, but 2 bytes per index ("useless stuff")is a lot less than (typically) 32 bytes per vertex.

For lower numbers of particles, there won't be much difference between indexed and non-indexed systems; however the advantages of indexed primitives increase the higher the numbers of particles.

If each particle is just a single triangle rather than a quad, then of course indexed primitives don't get you anything (this may have been what f8k8 is thinking of).

2) As for working out the indices

v0    v1 +----+ |    | |    | +----+v2    v3

- add a diagonal, your choice which way, to divide that into two triangles, label the two triangles A and B:
v0    v1 +----+ | \ B| |A \ | +----+v2    v3

- remember that the D3D default is to backface cull any polygons whos vertices are counterclockwise (aka anticlockwise) with respect to the viewer after transformation.

- pick a vertex for your first triangle (A), say vertex v0.

- and then the indices are simply the vertices of that triangle in clockwise order:
v0 +- |  |A  +---+v2   v3

- i.e. v0, v3, v2

- repeat that for the second triangle of the quad:
 v0    v1  +---+   \ B|    \ |     -+      v3

- i.e. v0, v1, v3

- repeat that process for all quads

I do have to admit that I too am a little surprised you've not come across index ordering even though you've implemented an advanced particle system and point sprites. But hey, we all started somewhere.

Simon O'Connor
Game Programmer &
Microsoft DirectX MVP

[edited by - s1ca on June 2, 2004 8:25:59 PM]

##### Share on other sites
If you''re using triangle lists instead of strips, you''re already wasting time by using quads when you could just as easily use triangles.

##### Share on other sites
Just build one index buffer, make it huge (i.e. can hold maxNumParticles), make it static.
All particle system vertex buffers use that index buffer.
For each frame you just need to update the vertex buffers.

I did this for my particle system and works great.

[edited by - yogiwp on June 3, 2004 3:35:09 AM]

##### Share on other sites
quote:
Original post by Etnu
If you''re using triangle lists instead of strips, you''re already wasting time by using quads when you could just as easily use triangles.

I''d disagree .

That is often the case when you''re rendering *meshes*, where you can get reasonably long strip lengths and a reasonably low degenerate to visible triangle ratio. Particle quads tend to never share edges...

So to use strips for quads you either need to use degenerates to stitch particle positions together (degenerates are cheap, but aren''t free, particularly if you end up with say 2 degenerates per quad...) OR have a separate Draw*Primitive() call per quad (performance suicide)

I do agree that if the area used within your texture for all your particles fits a triangle better than a quad, then that could be a more suitable primitive.

But it depends on the texture and where the bottlenecks of your own app are. In my personal experience, with average artist drawn particle textures, more rendered *pixels* are wasted/unused with a single triangle than with a quad! - more pixels wasted means higher fillrate and framebuffer bandwidth consumption - which also tends to be the main bottleneck for particle effects (lots of overdraw, all blended...)

Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

##### Share on other sites
You can get away with 4 vertices per quad if you render each quad seperately as a triangle strip, but that''s 1 draw call per quad, which catches up to you quite fast because of the overhead of the draw calls.

If you have a lot of particles use an index buffer.

------------
- outRider -

##### Share on other sites
Yeah, of course I know about indexes, but as I mentioned, I don''t have much time with all my GCSE coursework on.

##### Share on other sites
completely off topic. sorry.

hey Simon, this may be a bit belated because i dont frequent the boards as much, but glad to see you''re back. When searching the forums for a specific subject any pertinent post''d you''ve made are always very helpful.

Dredd
________________________________________

"To die with your sword still in its sheath is most regrettable" -- Miyomoto Musashi

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633298
• Total Posts
3011256
• ### Who's Online (See full list)

There are no registered users currently online

×