good muzzle flashes

I'm working on a 3D war game, and it's going well, but I need to know of any good methods for creating convincing muzzle flashes, one possibility I was considering was having 3 planes: 2 forming an X that are both a side view of a muzzle flash (like how trees are done sometimes) and a front view of a muzzle flash on a plane perpindicular to the other planes toward the side near the gun barrel.
I have a feeling this won't look very good though, I've seen some games where Muzzle Flashes seem very convincing, and was wondering if anyone knows of any good techniques.

I'm not sure I know what a real muzzle flash looks like, but I doubt it looks much like the ones we see in some gamesÖ

I'm not sure the 3-plane thing would look good as it stands, but (and this is just an idea), you could have the 3 planes as described and only show those planes which are not nearly edge-on to the camera. It might well look ok - I imagine that with a bit of tinkering to the "nearly" value, you could get something that looked fairly convincing.

I'd make the textures very bright, but draw them fairly transparent, and have particle sparks and/or smoke if I felt I needed (and could afford) them.

Now I come to think of it, how about the 3-plane solution, but fade their transparencies according to their orientation - edge-on planes become transparent, planes precisely facing the camera have the greatest alpha(which still may not be that high), and those in between have alpha values in between.

But do try anything you think of - experimentation reaps great rewards when trying to create visual effects.

When I was making a "Special Ops" movie with some friends I had the job of creating muzzle flashes on the computer. I watched Die Hard 2 pretty much frame by frame and noticed that the muzzle flashes were very bright and they all had a glow around the edge. For the most part they were completely white, except for the glow, which had a slight blue tint (think blue flame). Also, the flashes were quite large, in this case, about equal to the length of the gun. They seemed fairly opaque though this could vary from gun to gun. Hope this helps...

I was thinking more like vast tongues of fire jetting out of the gun - not realistic, perhaps, but whenever people do muzzle flashes in games they're a bit overblown, and I see no reason for these not to be :-).

Speaking of overblown - have you seen the Warthog machinegun in Halo? Now there's a muzzle flash for you :eek:.

Thanks for the suggestions, basing the alpha of the planes on how close to edge-on they are sounds like it could work out well. What exactly is the math for this, or a site that has an example of this? (sorry if it's easy, because I always hated people in my math classes who asked stupid questions)

The easiest way and I think the best is just to draw the three quads, two forming a cross parallel to the gun and the third as a billboarded (not perpendicular to the others) quad right at the end of the barrel.

A realistic muzzleflash pretty much doesn't exist. In real life most of the time you can't see muzzle flashes except occasionally as faint light spots. Flamy flashes are fun though

Let V be the cross product of the unit vectors in the directions [normal to the plane you're interested in] and [pointing forward from the camera]. Try multiplying the alpha of the plane by (1 - size(V)).

Note: I'd give you the formula properly, but I'm on a pc, so the keyboard's all wrong. Where [ x ] means 'modulus of x', A and B are vectors, t is the angle between them and N is a unit vector perendicular to both:

A x B = N[ A ][ B ]sin(t)

So if A and B are already normalised, we get [ A x B ] = sin(t), and the nearer sin(t) is to one, the nearer your plane is to being edge-on to the camera.

Quote:Originally posted by w_reade Let V be the cross product of the unit vectors in the directions [normal to the plane you're interested in] and [pointing forward from the camera].

you are probably thinking of dot product. Cross product returns a vector perpendicular to all the parameter vectors. If we are talking about 3D vectors and C = A cross B then C is a vector that is perpendicular to both A and B. If A and B are unit length, then so is C.

if A = normal to the plane you're interested in and B = unit vector pointing forward from the camera, then A dot B tells you how 'edge-on' you are. The closer A dot B is to zero - the closer to 'edge-on' while the closer the absolute value of A dot B is to one - the closer to 'face-on' you are.

There's a definition of the dot product in terms of cos, and a definition of the cross product in terms of sin (as I gave). So, "dot product close to zero" is equivalent to "modulus of cross product close to one".

So, either would give you the results you wanted - although I accept that doing it in terms of the dot product will indeed be more computationally efficient.

Thanks for pointing it out though :-).

[edit: ps - try taking the cross product of two parallel unit vectors, and then try telling me that it's always equal to one. However, if a and b are perpendicular unit vectors, then c = axb will indeed also be a unit vector.]

I think I'll just point out that muzzleflash method would probably work better, because unless the two X quads are using GL_SRC_ALPHA,GL_ONE and have an alpha of 1, the cross will be pretty obvious where the two quads overlap.

unfortunately I have a lot to do this weekend, and I just wasted the last 6 hours playing Medal of Honor online (those objective matches are great, anyone else here play, maybe we've killed eachother ?).