Beam weapon!

Started by
8 comments, last by Source 18 years, 8 months ago
My goal is to draw a beam (remember beam weapons in Star Wars?) - the shiny dashed line produced by a weapon. But still I can't decide which approach to choose. My first thought was to use a particle system, which gives very nice effect, but I'm afraid it would be too slow. Now I think of using sprites but, again, not sure it's gonna work. Any suggestions or references? Thank you
Advertisement
Hi Tokaplan,
Have you looked in to using volume textures?
I havn't used them myself so I can't give you much info, but from a quick look at the SDK docs, they maybe useful for what you need.

From SDK Help file:
Quote:
"You can use volume textures for special effects such as patchy fog, explosions, and so on."


Search on "Volume Texture Resources" in the SDK help file.

HTH,
Cambo_frog

[Edited by - Cambo_frog on July 31, 2005 9:02:34 AM]
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
What you need is a textured polygon from point A (source) to point B (destination), orientated towards the camera at all times. Then you can texture it with a semi-transparent image. To make nicer effects you can reblend several copies at slightly different positions to give a "shimmery" effect, and use more polygons to give neater start and end segments.

Here's one I made earlier ;)

Image hosted by Photobucket.com

That the kind of effect you're looking for?
Yeah, this is exactly what I need! It looks great! Only I'm gonna make it dashed, but I think that would be very much the same. Tank you so much!
Yep - much the same, except on thing you will have to take into account is that the beam segment will be stretched depending on the beam length.

If your beam texture is dashed then if you simply mapped it straight onto the segment, the dashes will be stretched with long beams, and bunched up for short beams.

To correct this you'll need to change the mapping coordinates, dividing by the beam length.

One thing I didn't mention is at the start and end you'll also want to blend some nice billboards, textured with flares or somesuch so that the beam is seamless and doesn't end in nasty-looking blunt ends. Which would be bad :)
Yes, very nice Source.
How did you go about creating the "beam" texture?

TIA,
Cambo_frog
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
I just knocked it up in Photoshop. Its only a line which is almost white in the centre and fades to the beam colour. The alpha channel is solid in the centre, and fades to transparent - except at the end which is a "bulb" shape. The engine takes the top half and puts it at each end of the beam, and copies the bottom part onto the beam length.

The real trick is to make sure you use additive blending so that it appears brighter and lights the landscape more effectively.

Then I just plonk two billboarded lens-flare-like particles at the ends, add some sparks and smoke and bingo you have some beam effects which will hold up even relatively close to the camera - though I created them for an RTS.
Thanks Source,
That is very helpful.

I tried to rate you (twice) but it doesn't appear to be showing.

Cheers,
Cambo_frog
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
What happens if the beam is pointed straight at the camera? It would show as a very thin line if you just use a quad, no?

I think maybe using a capsule or a cylinder might be a bit better, and it shouldn't make it that much more complicated...
Sirob Yes.» - status: Work-O-Rama.
Well, this will only really be a problem if the beam intersects the centre of the camera incredibly closely. This is very difficult to do in practice so usually doesn't become a problem.

You could add cases where a billboard is placed at the intersection of the viewing plane to represent the "thickness" of the beam, though most of the time it isn't really neccasary. Good point though :)

[edit] if you use more complex geometry you are a) adding huge slow-downs to a system which is really wanted for speed, b) introducing much more complicated texture mapping problems - mapping a quad gives you far more control than a cylinder or box. Lastly most laser beams only appear for a couple of frames, so probably isn't really neccasary to do anything about it. [/edit]

This topic is closed to new replies.

Advertisement