Jump to content
  • Advertisement
Sign in to follow this  
adoado

Face Camera, A bit different

This topic is 3801 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 all ^^ I have a rather specific problem I cannot seem to solve. Basically inside a mesh I have several planes (a quad). Mind, these are all one mesh. I basically want to align all the quads to face the camera in the vertex shader. My problem is, each vertex must be aligned - and each vertex only has information about itself, not the quad as a whole, so how can I achieve this camera-facing technique without having to write a special program to generate the specifically-designed model? Thanks, Adoado

Share this post


Link to post
Share on other sites
Advertisement
Assuming your quads are already "facing forward" in object space, all you need to do is ensure that the vertices get to view space without ever being rotated. Doing this is easy: just get the translation component from your combined worldView transform (or modelView transform, in OpenGL lingo) and add it to the vertex position. This will position the quad in the right place, but it will always be facing forward. So in DX HLSL it would look something like this in the vertex shader...


float4x4 matWorldView = mul(matWorld, matView);
float3 vPositionVS = vPositionOS + float4(matWorldView._41, matWorldView._42, matWorldView._43);
float4 vPositionCS = mul(float4(vPositionVS, 1.0f), matProjection);


There are other variations on this technique as well, which you should be able to find if you search around for "billboarding"

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!