3
\$\begingroup\$

I am creating this little 3d space shooter and am somewhat unsure on how to implement the laser beams.

I'm thinking about something along Star Wars and the like where mostly you shoot rather short laser beams but very many of those.

Should I create a "tube" for each of the beams, render them via instancing and give them a better look just with the shader?

How would you go on about this? I was rather perplexed that there was no good tutorial on this matter out there.

\$\endgroup\$
3
\$\begingroup\$

You can also assume that "laser beam" is cylinder, and create a billboard for that:

http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/

\$\endgroup\$
  • \$\begingroup\$ This is the superior answer IMO! \$\endgroup\$ – Alan Wolfe May 21 '15 at 0:55
5
\$\begingroup\$

I would do this by rendering textured quads. A single laser beam would be two rectangles intersecting each other at the center by a perpendicular angle, each sharing the same texture of the laser beam.

enter image description here

Not very much to it, you can use instancing for them, with a very simple pixel shader which just samples the texture, oh and additive blending.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.