Archived

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

Lionheartadi

Rendering alot of particles in DirectX.

Recommended Posts

Lionheartadi    154
Hi I have a general wondering about rendering particles in DirectX. I am new to particle engine stuff so I need some help on this mater. I have done some particle exercises in OpenGL, but rendering stuff in OpenGL is a bit different than in DirectX. This is due to the vertex and index buffer, which are good tool. I am wondering how to render alot of particles with the use of the buffers. My first idea was to take a certain amount of particles lets say 100(dunno if it''s alot bu it will do). Anyway, if I would make a particle so that it will consist of two triangles creating a quad that is textured with the desired texture. Now 100 x 2 would make 200 triangles. At my first idea I thought to put all of these triangles in one vertex buffer and rendering them as triangle list, but then I though what will happen when I try to apply a texture or texture on these perticles. I don''t know how to do it the right way. I mean creating for evey particle it''s own vertex buffer and render them that way would be a loss of speed and resources. Is there a way to assign desired textures for desired triangles in the vertex buffer... or something. I really don''t know. Please give me some tips, help, ideas how to render particles in DirectX. Thank you for any help possible.

Share this post


Link to post
Share on other sites
Look up point sprites. There is an example in the DirectX SDK but you may find it too involved and complicated so try google. Basically, point sprites are where you fill your vertex buffer with points (point list). These points are the centre of your individual particles. The texture you have selected is used for rendering the particles and is automatically scaled around each point based on min and max sizes you stipulate. They are billboarded automatically to the camera too.

What I do is load my vertex buffer with 10% the amount of particles in the effect and then draw them to the backbuffer. Keep doing this until you have drawn all the particles each frame. That way neither your CPU or GPU is idling.

Edit: Grammar and clarification.

[edited by - datastream_terrorist on August 14, 2003 6:01:47 AM]

Share this post


Link to post
Share on other sites
Lionheartadi    154
quote:
Original post by datastream_terrorist
Look up point sprites. There is an example in the directx SDK but you may find it too involved and complicated so try google. Basically, point sprites are where you fill you vertex buffer with points (point list). These points are the center of your individual particles. They are rendered based on sizes you stipulate and are billboarded automatically to the camera.

What I do is load my vertex buffer with 10% the amount of particles in the effect and then draw them to the backbuffer. Keep doing this until you have draw all the particles each frame. That way neither your CPU or GPU is idling.


Hmmm Thanks I''ll try that. Need to open more often that DX SDK documentation .

Thanks again.

Share this post


Link to post
Share on other sites
JoeyBlow2    100
Just to expand on point sprites,

On most hardware, they are limited to 64x64 pixels on the screen. The nice part however, is DirectX is very efficient and normally the hardware can handle them very good. You can do 10,000 point sprites with hardly any loss in FPS... 10,000 is normally enough to do most things.

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
quote:
On most hardware, they are limited to 64x64 pixels on the screen. The nice part however, is DirectX is very efficient and normally the hardware can handle them very good. You can do 10,000 point sprites with hardly any loss in FPS... 10,000 is normally enough to do most things.

- Radeon8500 (and above I think) support particle size of 256, Geforce4 and GeforceFX support max size of 8192 (I''m not quite sure the GF4 does it, though I''m certain FX does)

- The number of point sprites you render depends on their size. If you have 10,000 point sprites close-up, at a size of 64x64, you''ll eat up your card''s fillrate.

- As far as I know, you can''t assign UVs to point sprites. They''re always (0,0) top-left, (1,0) top-right, (0,1) bottom-left, (1,1) bottom-right.

- In any way, you''ll need to support billboards for:
1) Hardware with a small point size
2) Situations where you pack a lot of "particle textures" into a single texture, and index them using UVs.

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites