3

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.

Sorona
  • 215
  • 3
  • 9
  • Related question: http://gamedev.stackexchange.com/questions/63997/laser-beam-end-points-problems/ – msell May 20 '15 at 18:39
  • Other two related questions: http://gamedev.stackexchange.com/q/73395/41153 and http://gamedev.stackexchange.com/q/83861/41153 – glampert May 20 '15 at 19:49
  • The best thing to do is to simply try something. If it works then stick with it. Experiment first - solve later. – Tom 'Blue' Piddock May 21 '15 at 10:35

2 Answers2

5

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.

János Turánszki
  • 3,079
  • 3
  • 15
  • 22
3

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/

MaKo
  • 306
  • 1
  • 4