Sign in to follow this  

Particle explosions

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I added particles to my engine, the only trouble is I have no clue how to direct my particles so they make good looking explosions. Can anyone point me in the direction of a DirectX tutorial that might help me out with that?

Share this post


Link to post
Share on other sites
Does +velocity away from point not look good?

How about +velocity away from point followed by constant small -velocity?

[I've not tried with my own particle system, but that's what I've seen used]

Share this post


Link to post
Share on other sites
The funny thing is:
From my experience what looks best is NOT creating a whole lot of particles and endlessly play with the parameters.

But instead: render 30+ frames of an explosion in 3D studio or whatever (in 3DS there's a fire effect which looks quite nice), use this animation as a texture for your particles, create just a few (like 10 per second) but make the particles really big. Optionally use additive blending.

I'd say that's the way most games do it. Even the movie industry often uses filmed explosions in CG stuff (the fire of the balrog in LOTR1). That's also the method nvidia has chosen for it's balrog like fire demo (and they explain it in great detail in gpu programming gems).

Share this post


Link to post
Share on other sites
The last explosion I did with particles was pretty simple yet looked effective. I started by creating a host of particles of slightly different sizes at a given point. Each particle was given a life around a certain time (some would be longer, some smaller) and a velocity (again, added some randomness). As the particle aged, it shrunk and faded in colour (velocity stayed constant). What happened was a bright centre of particles that dispersed as expected, the fading and shrinking of the particles ensured that only the biggest ones lasted until the end.

You could expand this system by placing a pseudo shockwave effect, essentially a rapidly expanding sphere that travels faster than the explosion itself (and fades) and by adding secondary explosions - and debris. The debris could fly out at a random tragectory and is affected by gravity, it could even cause a mini explosion when it impacts something.

Share this post


Link to post
Share on other sites
This is one that I used. It's a TGA with RGBA (eg: Alpha channel).. It's fairly simple, I'll probably experiment with other textures when I have time, but I think the key is to having it rendered with several different scales and getting the colour blend right.

EDIT: For some reason the TGA wouldn't download from my GDNet+ space, so I put a BMP up.

Share this post


Link to post
Share on other sites
@evalutional
it seems like your particle is different than the one i downloaded
here's the one i downloaded: http://www.microsqft.com/files/particle.png
can it be useful for explosions? fire? or its not a good particle?
i didn't made any particle effects (like explosions or fire) yet so i have no idea

thanks,
Amir.

Share this post


Link to post
Share on other sites
If you're doing an explosion, you probably want to have fire and smoke. That means additive blending for the fire and alpha blending for the smoke. If you use pre-multiplied alpha textures you can render both blend modes in one go. Just sort the particles back-to-front and render them all in one batch. You'll probably want two images - one for the fire; one for the smoke. Pack these together into a single texture so they can be rendered in one batch. Also, if you can, use an animation for each one rather than a static image.

As for motion, try firing a few (5?) particles out and have them spawn other particles as they move. Randomise stuff like size, velocity; make them spin, etc.

HTH

Matt

Share this post


Link to post
Share on other sites
My texture is a simple one I jammed together, you can use pretty much any texture you want - it's a good idea to experiment and try things out.

As Matt said, you definitely need Additive blending to get the correct effect, the colours blend together and brighten when several are over one another, giving the effect of a white hot core which dissipates into fire and smoke. I don't use smoke in many of mine, mainly because my stuff is mostly space based (and smoke doesn't seem to be a feature of space explosions). It is good if you give an explosion as a whole an 'energy' value, each time the explosion breaks into particles, split this energy between them and again, if the energy is above a certain threshold, make the particle explode slightly again, breaking up it's energy until it's exhausted. This way, as Matt pointed out, you'll get a nice cascade effect and several smaller explosions.

I think creating effects for games can be really good fun, the best thing you can do is try and implement a particle system you can control/manipulate and then play with the results. When I got my first plasma systems going, I spent literally hours just playing with it :)

Share this post


Link to post
Share on other sites
this r a nice ref may they help

1) The Ocean Spray In Your Face (old one for basic stuff)
PDF: http://www.darwin3d.com/gamedev/articles/col0798.pdf

2) Advanced Particle Systems by john van der burg
PDF :http://www.mysticgd.com/misc/AdvancedParticleSystems.pdf
HTML: http://www.gamasutra.com/features/20000623/vanderburg_pfv.htm

3) Particle Chamber( nice source code) <<=== best one
ZIP:http://www.gamedev.net/reference/articles/article1043.asp

Share this post


Link to post
Share on other sites
There's a column on Drunken Hyena that talks about additive blending.

The most simple way in DirectX is (from the tutorial above):


g_d3d_device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
g_d3d_device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
g_d3d_device->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);



Experiment by playing around with your blend factors to see what effects it produces.

Share this post


Link to post
Share on other sites
What are my options as far as tweaking blending? Setting texture states is one of the things I haven't learned fully yet. Right now I get some blending but stacks of particles turn a bright yellow, I'd like it to go all the way to white where there are the most sprites. Is there any way to tweak this? I couldn't really figure out how to change how it blended. Here's all my render states

 
m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

m_pD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );

m_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );

m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);

m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);



//
// Set up the render states for using point sprites...
//

m_pD3DDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE ); // Turn on point sprites
m_pD3DDevice->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE ); // Allow sprites to be scaled with distance
m_pD3DDevice->SetRenderState( D3DRS_POINTSIZE, FtoDW(1.0) ); // Float value that specifies the size to use for point size computation in cases where point size is not specified for each vertex.
m_pD3DDevice->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(1.0f) ); // Float value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering.
m_pD3DDevice->SetRenderState( D3DRS_POINTSCALE_A, FtoDW(0.0f) ); // Default 1.0
m_pD3DDevice->SetRenderState( D3DRS_POINTSCALE_B, FtoDW(0.0f) ); // Default 0.0
m_pD3DDevice->SetRenderState( D3DRS_POINTSCALE_C, FtoDW(1.0f) ); // Default 0.0





Here's a screenshot of my explosion how it is now:
Click here


I want it to get more white the closer it is to the center instead of just turning light yellow and staying there. Anything I can tweak?

Share this post


Link to post
Share on other sites
by the way, you don't add colors for smoke, that'll just increase the brightness and make it look like steam. You set the source to source alpha (texture and/or diffuse), destination to one, and the operation to reverse subtraction to darken what's already in the background.

Share this post


Link to post
Share on other sites
Yes I am setting blue to zero. I bet that'll fix it. Thanks.

By the way, what should I do with particles after the initial burst? If I let them keep moving at the current speed they get way too spread out. I'm thinking maybe after a short period of time divide the velocity of all the particles by something, I noticed real explosions stop expanding outwards after a second or so and just shift and fade from there.

Share this post


Link to post
Share on other sites
they turn the acceleration to a negative amount, which changes the velocity, which changes the speed to slow down. Obviously they have the initial velocity to some high number, so the acceleration is never positive...

you also give your particles some vector direction, don't try and change the actual vector on each particle and then (worst) renormalize them, that'll slow the game down. To have it change direction to kind of drop to the floor, subtract the y by gravity - which increases by another acceleration. So as the particles slow down from the point they explode, they'll slowdown and drop like some kind of firework.

you should also have them fade of course: (currage/maxage)*255 on each particle. If they all have the same max age, then before the loop, set a variable like "t" to the reciprocal of max age (1.0f / maxage) and multiply everything instead of dividing. I'm used to doing that, whether or not I gain a single frame per second.

Share this post


Link to post
Share on other sites
I just realized how many spelling and grammar mistakes I made from typing too fast, oh well. You should add to the gravity velocity by the constant acceleration... then set a max velocity cap. Then add the position by the velocity each frame. I like to subtract a positive gravity strength, some like to add a negative strength, it's up to you. You could even accelerate the acceleration if you wanted to. It may not be true physics, but it's good enough.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this