# [Resolved]Spherical billboarding using matrices

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

## Recommended Posts

From the spherical billboarding tutorials I have seen, they involve complex math functions. I'm trying to make my particle system as fast as possible, so I was wondering, what is the fastest way to do spherical billboarding, preferrably with matrices, and still keeping the Z value? Using a point sprite style matrix is really fast, but it always renders with z=1. Thanks [Edited by - CadeF on April 4, 2006 8:49:53 AM]

##### Share on other sites
I'm not sure I entirely understand what you mean, but for simple proper billboarding, just use the vector from the particle to the camera as the "front" vector and build a local frame matrix for the particle from that. It certainly isn't the fastest of methods, but it does produce good results.

##### Share on other sites
Spherical billboarding is when the sprite rotates on the x,y and z axis to face the camera (normal billboarding does not rotate on the y axis). I'm not really sure what you mean by local matrix, could you please elaborate?

##### Share on other sites
I understand, since there is no "normal" billboarding, I assume spherical (rather than cylindrical).

The "local frame matrix" is just the transformation matrix that describes the frame of the particle (frame being a local coordinate system). They take the form:

[Sx Ux Fx Px][Sy Uy Fy Py][Sz Uz Fz Pz][0  0  0  1]

Where S is the side vector, U is the up vector, F is the front vector (the three orthogonal basis vectors that describe the frame) and P is the position of the frame.

This would be the transformation matrix to use for the particle.

##### Share on other sites
Thanks for the matrix. So, given a quad in object space, and P is object space(-32,-32 32,32 32,-32 -32,32), can I apply the matrix to the 4 points in object space and then add the particle position to them for world space?

##### Share on other sites
Well, P in that matrix is relative of course. It defines the position of the frame relative to another frame. You can concatentate the transformations, however you need to *eventually* get the vertices into world space.

When you say "P is in object space", I presume you mean that P is not relative to the world frame - but instead some other frame (of course, if P is relative to the space that the vertices are in, then it'd just be zero). In that case, you need another transformation to transform the vertices in "P-Space" to be in world space.

An example:

You have a quad, as shown. The vertices are defined in object space.
    A       B    +-------+    |   P   |    |   +   |    |       |    +-------+    C       D

A, B, C and D are the vertices of the quad (so, [-1, 1], [1, 1] ... ), P is the position vector of the origin of the frame, relative to another frame.

To make this simple, lets say that P is relative to the world frame, it would literally be the position of the particle in world-space.

To transform the particle, you'd build the matrix I posted further up, and load it into the transformation pipeline.

If P is not relative to the world-frame, you'll need more matrices to load in sequence, until the vertices have been transformed into world space (from there you can do your camera transformations, projections and so forth).

One thing to note, that matrix is for OpenGL - you'd have to transpose it to use with D3D ( different handedness to do with row-major/column-major difference ).

[Edited by - python_regious on April 3, 2006 8:28:35 AM]

##### Share on other sites
P, is the center of the particle,
P-space, its 0,0
World space, its the particle's position

One last question (I hope), do you know how to construct this matrix as left-handed, in D3D?

Sorry, but my brain is sort of slow right now. :)

##### Share on other sites
[Sx Ux Fx Px]T[Sy Uy Fy Py][Sz Uz Fz Pz][0  0  0  1]=[Sx Sy Sz 0][Ux Uy Uz 0][Fx Fy Fz 0][Px Py Pz 1]

[Edited by - python_regious on April 3, 2006 9:55:52 AM]

##### Share on other sites
Oh God, I just turned my brain on and realised I spread a bit of mis-information. The transpose of the matrix isn't to do with the handedness of the system, but rather the fact that D3D transforms are represented using row-major matrices, rather than column major. Hence the transpose.

##### Share on other sites
So in DirectX, which matrix do I use?

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631415
• Total Posts
2999965
×