Jump to content
  • Advertisement
Sign in to follow this  
VanKurt

Vertex Shader for Billboards

This topic is 3783 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 guys! I'm currently working on a little vertex shader (cgFX) for rendering billboards. All it should do is to rotate the quads I pass in towards the camera (along all axis). But somehow I can't get it to work... the code must actually be pretty simple ;-) Can anyone give me a hint or ssome sample code? thx!

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure myself, but it looks like this is helpful:

http://www.gamedev.net/community/forums/topic.asp?topic_id=154890

Share this post


Link to post
Share on other sites
Assuming your billboards are already oriented in object space such that they're facing forward, you don't need to rotate them at all. All you need to do is not rotate them when you transform them to view-space.


float4x4 matWorldView = mul(matWorld, matView);
float3 vPositionVS = in_vPositionOS + float3(matWorldView._41, matWorldView._42, matWorldView._43);
out_vPositionVS = mul(float4(vPositionVS, 1.0f), matProj);


This is assuming column-major matrices, for row-major you'd have to flip the mul's and use the ._11, ._21, and ._31 elements of the worldView matrix.

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!