Billboarding using Quaternions

Started by
3 comments, last by dmatter 17 years, 10 months ago
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.
[size=2]Darwinbots - [size=2]Artificial life simulation
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.
f@dzhttp://festini.device-zero.de
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.
[size=2]Darwinbots - [size=2]Artificial life simulation
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.
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.

This topic is closed to new replies.

Advertisement