Sign in to follow this  

How to make billboards ?

Recommended Posts

Hi guys, I've been combing the internet for hours and found (as usual) nothing useful. I want to do billboards with c++ and dx9. The reason I chose billboards over point sprites is that I want to rotate them and I heard thats not that easy possible with them and they are just generally to unflexible. Anyway, I managed to display a bunch of objects but now I want to display billboards for some special effects. For that I made a square out of 2 triangles that I display a texture on which works pretty good, but of course I cannot apply my usual matrices because when the camera position moves I look on the billboard from a different angle until it disappears (backface, etc...). The point of the billboard is that its always facing the camera and that is where my problems start. The way I take it I have to rotate every billboard according to the angle it is regarding to the camera, right ? Or is it enough to simply rotate all billboards that they are parallel to the viewing plane ? I am not really sure and would appreciate any help with this, especially as to how I create a new view matrix/matrices for the billboards.

Share this post

Link to post
Share on other sites
I posted a brief description of constructing billboard matrices a while back. However, if you are using many related billboards (i.e. a particle system), you probably want to figure out the billboard rotation in the vertex shader, to reduce CPU workload and CPU->GPU transfer bandwidth.

Share this post

Link to post
Share on other sites
Hi, thanks alot for your reply.

I read your link but unfortunately I don't really understand how to implement it. I created a matrix from the view matrix like you mentioned there which looks like this:

matBillBoard._11 = matView._11;
matBillBoard._12 = matView._21;
matBillBoard._13 = matView._31;
matBillBoard._14 = x;

matBillBoard._21 = matView._12;
matBillBoard._22 = matView._22;
matBillBoard._23 = matView._32;
matBillBoard._24 = y;

matBillBoard._31 = matView._13;
matBillBoard._32 = matView._23;
matBillBoard._33 = matView._33;
matBillBoard._34 = z;

matBillBoard._41 = 0;
matBillBoard._42 = 0;
matBillBoard._43 = 0;
matBillBoard._44 = 1;

I have now 3 questions to this.

1. Is this correct ?

2. what exactly is x,y,z ? I tried putting there some values but to no avail.

3. How do I exactly apply this matrix ?
My usual way of applying matrices is like this:

object->matObject * matWorld * matView * matProj;

How does this new matrix fit into there ?

Thanks in advance...


[Edited by - Zaph-0 on December 27, 2009 6:00:33 PM]

Share this post

Link to post
Share on other sites
Ah, it seems I got it working, but I found a few things a little strange so I'm not sure what to make of this.

1. Instead of using the position x,y,z at m.14, m.24, m.34 they are at m.41, m.42, m.43.
2. The billboard is being displayed clockwise and must be created that way.

Ah well it works, thats all that matters for now...


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this