Jump to content
  • Advertisement
Sign in to follow this  
winsrp

spherical and cylindrical billboarding

This topic is 1745 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

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

Share this post


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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

Edited by winsrp

Share this post


Link to post
Share on other sites

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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!