Jump to content
  • Advertisement
Sign in to follow this  
Numsgil

Billboarding using Quaternions

This topic is 4465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically I want to specify a view vector and an up vector, and get a quaternion to orient the billboard towards the view vector (or away, depending on how you see it). A third optional parameter could "lock" a certain axis defined by a vector. I think I understand billboarding using matrices. While I could just take the resulting matrix and read it into a quaternion, there seems to me to be a better way, and I'm just not seeing it. All the tutorials on billboarding online use matrices, so I suppose I should also ask if I should even be using a quaternion of billboard orientation.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Numsgil
Basically I want to specify a view vector and an up vector, and get a quaternion to orient the billboard towards the view vector (or away, depending on how you see it).


Seeing how no API I know natively works with "transformation quaternions", it would be incredibly pointless to convert the matrix you already have to a quaternion, just to convert it back so you can feed it to the API. Unless you plan for static situations where you don't have to recalculate all the time (or so many billboards that you can only do some of them each frame). In that case you could use "I need to save every byte I can by storing 3 floats instead of 9" as an excuse for using quats.

Let's say x,y,z are right/up/forward and "forward" is the side you want to face, then obviously (your examply sounds like for trees with a fixed "up"), the matrix you want is made up by cross(up,bill_fwd)|up|cam_pos-bill_pos (aka. bill_fwd). If you don't mind a bit of skewing you could just calculate the relative position of the billboard(s) to the camera, load the identity and render it without any rotation at this position. For a smallish field of view you most likely couldn't even tell the difference anyway.

Keep in mind that matrices and quaternions are completely equivalent. None of them has magical abilities to do something the other can't. Just some calculations are nicer with quats and others with matrices.

Share this post


Link to post
Share on other sites
I'm just a little more comfortable with quaternions over matrices. If it's not really any easier qith quaternions, I'll just store the matrix. If they're equally easy, I'd prefer to use Quaternions, which is why I asked.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well using matrices for billboarding is fairly simple anyway. But if you haveto billboard hundreds of thousands of particles per frame, then the overhead of converting matrix->quat->matrix will become horrendous.

The effort of converting between the two formats is likely greater than just using the matrices directly.

Its not difficult to stick with matrices in this case.
Quaternions are usually used for orientation during animations, such that the orientation needs to be interpolated between keyframes.

Share this post


Link to post
Share on other sites
Well using matrices for billboarding is fairly simple anyway. But if you have to billboard hundreds of thousands of particles per frame, then the overhead of converting matrix->quat->matrix will become horrendous.

The effort of converting between the two formats is likely greater than just using the matrices directly.

Its not difficult to stick with matrices in this case.
Quaternions are usually used for orientation during animations, such that the orientation needs to be interpolated between keyframes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!