• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

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.

3 replies to this topic

#1cebugdev  Members   -  Reputation: 324

Like
0Likes
Like

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

http://www.videogamer.com/xbox360/command_conquer_3/screenshot-51.html

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

thanks,

#2Hodgman  Moderators   -  Reputation: 30926

Like
3Likes
Like

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.

#3Amr0  Members   -  Reputation: 1130

Like
2Likes
Like

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).

#4eppo  Crossbones+   -  Reputation: 2508

Like
1Likes
Like

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.

PARTNERS