Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

laser/electric effect

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 cebugdev   Members   -  Reputation: 413


Posted 05 May 2013 - 09:43 PM

Hi all,


How do lasers drawn using directx 10/11, are they drawn using particles?

by laser i ment things like this;



or this



what are the technical knowhow that needs to be learned and look at for these kind of effect?





#2 Hodgman   Moderators   -  Reputation: 42274


Posted 06 May 2013 - 01:29 AM

The terminology differs a bit with special effects. I'd call them an "oriented billboard" or a "ribbon".


You've got a start point A and an end point B for the beam, and you want to draw a quad from A to B. The problem is the orientation of the quad. If, say you choose your 4 points of the quad to be slightly to the left & right of A & B, then when viewed from perfectly side-on, the quad won't be visible. When viewed from side on, you want to choose your 4 points to be slightly above & below of A & B...

So, you need to procedurally calculate some offset, which you can add to A & B to expand this line into a quad, so that it look good from every view angle. We want our offset to be tangental to the direction of the line (i.e. the direction "normalize(B-A)" should be pointing 90º from our offset direction), but also tangential to the direction that the camera is looking.

You'd want to be comfortable with the basics of linear algebra to make these kinds of effects, some specific tools you'd use are the dot product and cross product.

If you calculate the cross product of the direction of the laser and the direction of the view (and normalize the result), this will produce the tangential direction that you're looking for, which can be used as an offset to expand your line into a quad.

#3 Amr0   Members   -  Reputation: 1433


Posted 06 May 2013 - 02:10 AM

They are also called volumetric lines sometimes. There was an NVidia paper about them, and I had written a C++ DX9 sample based on it. The sample is here, and the paper is in the Nvidia SDK here (search for volume lines).

#4 eppo   Crossbones+   -  Reputation: 3347


Posted 06 May 2013 - 03:11 AM

Also called 'cylindrical billboards'.


They work similar to standard billboards, in that you want one specific vector of the billboard's orientation (say its y-axis) to always point in the direction of the camera. The difference is you also want the laser to keep pointing in the direction of its tangent line (say the z-axis). Because of this you only have the freedom to reorient the billboard around its z-axis. So towards whatever direction you re-orient the y-axis, it needs the be orthogonal in respect to the z-axis. You can do this by orthonormalizing the camera-vertex vector in respect to the tangent vector.


So the three vectors that form a billboard matrix' orthogonal base are:


y: normalize(cameraVertex - tangent * dot(tangent, cameraVertex))

z: tangent
x: cross(y, z)

Edited by eppo, 06 May 2013 - 03:14 AM.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.