# How to billboard

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

## Recommended Posts

Hello, I have a question regarding billboarding and billboarding particles especially: How do you apply the billboard-rotation? Set the model matrix for each particle? (probably not...) Update the vertex buffer with particles or through a vertex shader? Which method is the fastest/prefered method on modern hardware?

##### Share on other sites
Build the inverse of the viewing matrix and insert the inverse's rotation vectors into the world transform matrix:

...

invView = matrixInverse( View )

World.xAxis = invView.xAxis
World.yAxis = invView.yAxis
World.zAxis = invView.zAxis

...

##### Share on other sites
If you are using up/forward/right vectors to store your camera's orientation you can simply set the orientation part of the world matrix of your particles to be the negative of those three components.

To rotate the particles simply do a rotation around Z before you apply the matrix above.

##### Share on other sites
Yes, but what if you have a huge particle system and all particles have to be billboarded, you wouldn't have one matrix for each particle, would you?

##### Share on other sites
Quote:
 Original post by patrrrYes, but what if you have a huge particle system and all particles have to be billboarded, you wouldn't have one matrix for each particle, would you?

This is the problem I ran into and the best solution I saw (and ended up using) involves building a 'basis billboard' from the camera, and then using it to translate each particle's vertices in a way that faces the camera. You still have to do per-particle processing but not per-particle rendering, which is a big difference, and you're probably updating your particles anyways (to apply velo, gravity, etc.)

The 'basis' billboard just has the 4 points of a quad at the origin based on the current camera orientation, then a copy is translated to each particle's position (which you might have to project). Search these forums if you need a better explanation, I found it here somewhere...

##### Share on other sites
The easiest way to render billboards is to copy the modelview matrix, set the x and y rotations to the ones you'd find in the identity matrix, then use that modelview matrix to render all of your billboards.

In Open GL, it'd look like this:
  glPushMatrix();  GLfloat matrix[16];  glGetFloatv(GL_MODELVIEW_MATRIX,matrix);  matrix[0] = 1.0f; matrix[1] = 0.0f; matrix[2] = 0.0f;  matrix[4] = 0.0f; matrix[5] = 1.0f; matrix[6] = 0.0f;  glLoadMatrixf(matrix);    //render your billboards here    glPopMatrix();

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634088
• Total Posts
3015453
×