View Full Version : billboarding with a roll

Joe Montana

07-22-2005, 03:36 PM

I have my multi textured cloud billboards working nicely as long as i am not doing a roll.pitch and yaw work fine. The billboards are rotating with me on a roll which is wrong. I cant seem to figure out how to calculate a rotation to keep the billboard level with the scene.

Any help would be appreciated.

Im using the side and up vector to compute new postions of the quads on each pass.

It seems i need to counter the billboard rotation with the amount i am actually rotating about in my roll.

Thanks

Joe Montana

07-22-2005, 04:30 PM

I think ill suggest something to myself I just thought of :D

If i check the angle(dot product) of the side vector of my camera with a known fixed vector thats keeping the billboard (clouds)aligned with the ground, this should give me the angle to do the rotating.

right? i think.

zeckensack

07-23-2005, 12:29 AM

IMO you're tackling this from the wrong direction (forgot the proverb involving the horses, dammit).

A billboard is defined as facing the camera. Extract the "forward" vector and make the billboard perpendicular to that.

Using camera "up" and "sideways" vectors to construct the billboard geometry achieves this, too, but this is more of a side-effect and brings with it the problems you're seeing.

So just make it perpendicular to "forward". Now you'll quickly notice that this is not a complete definition. You need either an "up" vector or a "sideways" vector to fully define the billboard plane. Just pick one you like and stick with it. You could simply use "up" in world space, but this way you can also design/animate your billboards to have a certain roll or whatever. But don't derive this from the camera. It is not inherently billboardish, so it shouldn't be done.

edit:

I just came up with something that should sound quite professional :D

A billboard has four degrees of freedom in camera space (up/down, left/right, forward/backward, roll). By throwing in an extra camera-derived vectors to nail down the billboard, you're restricting it to three degrees of freedom.

RigidBody

07-23-2005, 01:21 AM

"das pferd von hinten aufzäumen" = "to put the cart before the horse" :)

ZbuffeR

07-23-2005, 06:05 AM

"mettre la charrue avant les boeufs" in french :D

that reminds me of a song i wrote

Am C F E

im a good ol' kiwi boy

busted my cherry down on the farm

.. etc (7-8 minutes worth even bubbles and micheal get a mention)

A billboard is defined as facing the camera. Extract the "forward" vector and make the billboard perpendicular to that.

Using camera "up" and "sideways" vectors to construct the billboard geometry achieves this, too, but this is more of a side-effect and brings with it the problems you're seeingnice one, ild been using the side/up vectors until now but definitly just using the forward with a crossproduct is much better, thanks for that

bonzaj

07-24-2005, 01:14 AM

Joe: I think I undestand what is your problem.

And the answer is simple. Don't rotate the billboard! Just rotate the texture coordinates. Simple and without special thinking. More over You can rotate these texture coordinates in GLSL.

Joe Montana

07-24-2005, 02:46 AM

A billboard is defined as facing the camera. Extract the "forward" vector and make the billboard perpendicular to that.

Using camera "up" and "sideways" vectors to construct the billboard geometry achieves this, too, but this is more of a side-effect and brings with it the problems you're seeing Ok. So the crossproduct of my forward vector with my world fixed "up" vector defined by the position of that quad(s) will give me the side vector so i can define my coordinates for my billboards. Note that this is different from my camera up which can be always changing. I think ill try this first. My quads are placed on a sphere(earth) so their up vector is position dependant, plus they move so its varying.

Omaha

07-25-2005, 01:18 PM

For billboards I just grab the modelview matrix...

[ m0 m4 m8 m12 ]

[ m1 m5 m9 m13 ]

[ m2 m6 m10 m14 ]

[ m3 m7 m11 m15 ]

...take the upper left 3x3 submatrix as...

[ x0 y0 z0 ]

[ x1 y1 z1 ]

[ x2 y2 z2 ]

Then calculate X=|<x0, x1, x2>|, Y=|<y0, y1, y2>|, Z=|<z0, z1, z2>| and replace the upper left with:

[ X 0 0 ]

[ 0 Y 0 ]

[ 0 0 Z ]

...and then reload that on top of the modelview stack.

Omaha

07-26-2005, 05:00 AM

Originally posted by Omaha:

For billboards I just grab the modelview matrix...

...

...and then reload that on top of the modelview stack.Of course once you perform this transformation you just rotate along the Z axis to do the roll.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.