Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am building a game in XNA that features colored laser beams in 3D space.

The beams are defined as:

  1. Segment start position
  2. Segment end position
  3. Line width

For rendering, I am using 3 quads:

  1. Start point billboard
  2. End point billboard
  3. Middle section quad whose forward vector is the slope of the line and whose normal points to the camera

The problem is that using additive blending, the end points and middle section overlap, which looks quite jarring. However, I need the endpoints in case the laser is pointing towards the camera!

See the blue laser in particular: XNA Laser Demo Screenshot

share|improve this question
    
Wouldn't the laser end point only be placed on top of an object? Or are lasers ending in the middle of open space? It seems like the problem would be what to do when the camera slices a laser. –  Byte56 Oct 25 '13 at 16:30
1  
They end in open space. The game takes place in a tron-like environment. –  user36159 Oct 25 '13 at 16:42

2 Answers 2

I'm afraid there is no "correct" solution to this problem without using multipass rendering, which would probably be awfully slow.

What you can do is draw an oriented hemicircle in both ends. See the picture below: Laser with hemicircle endpoints

This should give pretty good results overall. Where this approach fails is when the laser is pointing towards the camera, especially if the projection of the line is smaller than the radius of the circle. See the picture below for what would happen:

Bad case

Even with this issue, this should be a better solution than the one you are currently using. There is no overdraw, yet there is still some effort to draw the end points the way you want.

share|improve this answer

You could use normalized vectors to check to see if the laser is pointing at the camera, and then only draw the end points if it is. If the angle allows you could stop drawing the mid section the instant it starts pointing at the camera and drawing the end section.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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