Jump to content
  • Advertisement
Sign in to follow this  
patrrr

How to billboard

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by patrrr
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?


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 this post


Link to post
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();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!