Jump to content

  • Log In with Google      Sign In   
  • 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!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


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: 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;

 

http://getintopc.com/wp-content/uploads/2013/04/download-command-and-conquer-generals-free-game-full-version.jpg

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,

 



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 30882

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.



#3 Amr0   Members   -  Reputation: 1129

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



#4 eppo   Crossbones+   -  Reputation: 2507

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