spherical and cylindrical billboarding

Started by
3 comments, last by winsrp 10 years, 8 months ago

Hi all,

I seem to get the theory behind this, first put 4 points at the same spot, map some coord, have the HLSL stretch those coord so that we make a quad, put texture in the middle.

For cylindrical:

Then on HLSL we calculate the position of the point, by taking the position and multiplying it by the world matrix only.. ? not sure here.

Then we create the lookat vector by taking the position - camera position.

We have our up vector which is like (0,1,0)

And I think we do a cross between the lookat vector and the up vector, so that we find the normal to both vector... this seems to be like a side looking kind of vector, and Normalize that side vector.

we then stretch the 4 points, into the final position.

-by adding a fix amount to the x cord and multiplying it by the side vector

-by adding a fix amount to the y cord and multiplying it by the up vector.

get view/projection matrix, and multiply the final position by the view projection matrix.

Finish it up by sending it the pixel shader and applying the texture.

Now, how do I do the same thing for the spherical billboard?

-tx

winsrp

Advertisement

As you said, cross the lookat with 0,1,0 to get a side vector that will be used to move the points horizontally.

But for a spherical billboard to move the points vertically, instead of using 0,1,0, use the cross of lookat and side

So I have to do it twice first the lookat vector with the up vector to find the side vector and then, the lookat again with the side vector right?

it works!! now the only thing is that I'm putting the points for the billboards at 0,0,0, and I want to translate them to different positions each frame (making a little sun that moves around), but no matter what I put in the world matrix it always sets it in 0,0,0. Any ideas?

decided to ignore the world matrix, send in matrix identity and create the vertices every frame... besides, for the sun and the moon are just 12 vertices total, and I change the position of the vertices on the creation based on camera position, I just did a refinement since my sun image keep flipping when reaching high in sky, I just did a quick check with the upVector to keep it looking at the same place.

Thanks for the help.

This topic is closed to new replies.

Advertisement