Archived

This topic is now archived and is closed to further replies.

UnknownPlayer

Keeping billboards orientated

Recommended Posts

UnknownPlayer    122
I know I can use the inverse of my view matrix to keep my billboard poly''s perfectly aligned towards the camera in my scene, but what do I do if I only want to keep the facing pointed at the camera, without rotating the billboard along its edges - i.e. if the camera spins then the billboard will seem rotated on 2-dimensions to the user, but the image will always be visible.

Share this post


Link to post
Share on other sites
UnknownPlayer    122
Really - is there anyone who could help me or point in the direction of some useful articles? I''ve tried a couple of ways of doing this, one involving LookAt matrices as world matrices, but this only got it done partly (there were glitches as the camera moved about the sprite).

So bump - anyone?

Share this post


Link to post
Share on other sites
assen    145
If I understand you correctly, you want the billboard rotating along a vertical axis through its center?

I do it like this, inside the vertex shader:

let''s assume we work in the XZ plane, and the billboard rotates along the Y axis.

find the vector from the camera to the billboard center in XZ plane; (take just X, Z coords, ignore the Ys)
normalize it;
rotate it by 90 degress (just swap X and Z)

The resulting vector, call it vBillB, is perpendicular to the view direction in the XZ plane. So, just multiply it by +/-1, add the coords of the center, and you''ll get the coords of the vertices.

Share this post


Link to post
Share on other sites