Jump to content


Billboarding using a fiddled world matrix


1 reply to this topic

#1 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 11 July 2007 - 08:41 AM

I've been set a bit of a task. I have an arbitrary point which is part of a triangle, the camera position and a world transform matrix. I've been asked to create a shader that will billboard this triangle.

Is this possible? I've been trying to figure out how i could do this and so far turned up a blank.

The world matrix's position is the center of the billboard so i can get the forward vector quite easily. I'm then a bit unsure of exactly what to do.

In the past when i've done billboarding in a shader i've always added extra information (such as size and a simple 2D vector that describes how i am "pushing" out the vertex positions from the center point). Alas, on this occasion, i must do it without adding extra info (engine limitations :().

I'm probably just being thick. Can anyone give me any suggestions?

#2 juhnu

    Valued Member

  • Members
  • PipPipPip
  • 292 posts

Posted 11 July 2007 - 02:16 PM

Assuming triangle is axis-aligned as otherwise I don't see how you could get the orientation of the plane (unless vertex normals are same as face normal). If you have the the face normal of the triangle you can use cross-product to create a matrix out of it and multiply it with the world matrix at first and then start from 1.


1. Get a scale of the world matrix for the each three axis.
2. Invert the camera matrix and normalize the scaling.
3. Construct a new world matrix using the inverted camera matrix for the rotation part and scale the axis and get the translation part from the original world matrix.

Now if you use this new world matrix to transform the vertices it should work.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users