Advertisement

Creating lasers (and other projectiles)

Started by February 04, 2005 07:04 AM
8 comments, last by leggyguy 19 years, 9 months ago
My little space game (which I posted a question about a few days ago) is going nicely. In my game, I have old fashioned ships (galleys, sloops, etc) floating around space fighting. Currently they fire textured cannon-balls, and ai, collision detection, everything works. Problem 1/ I want to change the cannonballs now, so that they aren't plain. I would like to have the cannon-balls have an animated texture, with little lightning effects going accross the surface, etc. But I don't know how to go about it. Problem 2/ I want to implement a laser style of weapon. But am not sure how to make the laser projectile look good. I am after something like starwars blaster fire. You know, a fairly long, red laser beam. I could so this with a billboarded bitmap, I guess, but it doesn't seem the right way in my mind to do it. I would search, but Gamedev's stupid search still isn;t working!!!! Come on Gamedev, get the search sorted out.
Sounds fun.
Animated lightning effects hmm. Perlin noise and other types of noise can do this, http://freespace.virgin.net/hugo.elias/models/m_perlin.htm. But it might be a bit complicated, I might just get some lightning in photoshop, make it tileable and then rotate it around the surface of the sphere (maybe a couple of semi-transparent layers to make it look cool). You can do this by setting different texture channels and changing texture transforms (you can change texture coordinates without locking the buffer with these).

(warning random googled links!)
For a red laser I think a billboard would be fine personally, just have a gradient texture from a bright color to totally transparent (this texture could be 1px wide):
http://jedisurf.free.fr/ie/wallpapers/characters/sith/Darth%20Maul%201024.jpg
I would also create rounded 'end' sections for the laser:
http://www.virtix.com/fcp/doc/VirtixEffects/images/LaserP2P100.jpg
Could do this with a spherical gradient tool.
I guess you could go all out and createsome sort of tube, but I doubt there would be much difference in quality.

Hope it goes well.
Advertisement
Let me first tell you: I'm not an OpenGL but a DirectX developper, so maybe my comments will make no sense at all.

- I think using billboards is a good and simple solution.
You can have a set of small textures, and by assigning a different texture every certain time step, you could create a very decent animated laser.
If you would use colored vertices to "hold" the billboard, you could change their colors from say, dark blue to light blue to create really cool effects.

- I don't know if you have something like point sprites in OpenGL, but they could really useful as well.

- Using a mesh to create bullets or lasers is an option, but to me it seems a bit over the top, unless you would have huge bullets/lasers where the detail is very important (and actually visible).
A must for lasers are one one blended textured polygons with depthwriting turned off, once you got that you could pretty mutch do anything, add a coupple of billboards or pointsprites at the head of the blast and make a tail with two or more crossed doublesided polygons(make shure the texture is totaly dark at it's edges though).

You could even model the laser core if you want it more defined and such.
One thing about the lasers is you can't use typical billboarding, you have to axil billboarding. This means the quad is aimed in the right direction, and you just rotate around the long par of the lazer so it is facing the camera.
One problem with axil billboarding is if you look straight at it in the same direction the billboard rotates, it will become pretty darn thin.
To solve this add atleast one regular billboard at the front of the blast to hide it.
Advertisement
..as to the lasers, try and have to concentric screen-facing quads, aimed (rotated) in the beam direction, and have them blend additively (like dark red + dark red = light red with the middle one being bright red in the end)
The world isn't unpredictable. It's CHAOTIC.
Sounds like a nice theme, and you could make some decent enough lazer effects that fit the theme well by using regular billboarded particles. Emit them at a constant rate and vary the color and intensity of each particle, set a life for specific color particles so only one color remains at the end of the lazer - say red. The only problem with this method is that the source and target objects have to be slow moving. If they are too fast there is a noticeable drift to the particles.

Static images don't do this method justice, but here is what I mean.

clicky1
clicky2
clicky3

[Edited by - Fahrenheit451 on February 4, 2005 7:08:37 PM]
I am doing a series of tutorials on how to make a spaceshooter game. It has a pretty decent particle system with code you can use. Hope it helps. Email me if you have any questions.

http://www.cs.ucf.edu/~hastings/index.php?id=opengl
I used an axial billboarded system in the end for my laser beems. I really like the way it is working out, and am now finished with it.

Thanks for the advice.

Flippy, your partical system is nice and pretty. It won't suit my laser beem, but I will certainly find a use for some of the techniques you use, especially one which looks a lot like an explosion, which I like.

The ring emitter is a very nice effect, too.

This topic is closed to new replies.

Advertisement