Page 1 of 1

Having a simple plane always facing camera

Posted: Sun Jan 24, 2021 6:01 pm
by kubatp
I was trying to find a guidance for this functionality but I didn't find anything what would provide an answer.

I am trying to create a 3D model, which would have a "pedestal" similar to a chess piece and a simple plane on top of it.
Image

Such model would be placed in 3D space and the plane would "roll" according to the angle to camera. Basically the lower part of the plane would keep its vertices' positions and the top two vertices would change its location so the texture/plane would always faces the camera directly (the texture would not be skewed).

I know that I need to use a vertex shader to modify the vertices positions but I cannot figure out how. Did anyone try to solve similar functionality?
Thank you for any advice.

Re: Having a simple plane always facing camera

Posted: Mon Jan 25, 2021 12:24 am
by paroj

Re: Having a simple plane always facing camera

Posted: Mon Jan 25, 2021 4:28 pm
by kubatp
Hello paroj,
I am familiar with billboards, yet I haven't really used them (except for particles).

I understood from your reply that it is probably a very beginner's question (since you posted just a link) but I am still not sure what exactly do you recommend.

Wouldn't it be better to just correctly set the position of the two upmost vertices in the vertex shader?

Re: Having a simple plane always facing camera

Posted: Mon Jan 25, 2021 8:11 pm
by paroj
it doesnt really matter where you change the vertices. Its just that Ogre already provides the functionality that you need (as linked).

Re: Having a simple plane always facing camera

Posted: Tue Jan 26, 2021 4:24 am
by sercero
The problem with a billboard is that it faces the camera at all times and I think that @kubatp needs something a bit more sophisticated.

If I were to do this, my approach would be to have the plane on the pedestal change its orientation according to the position of the camera relative to the pedestal/plane setup.

So you should have a vector v = (camera - pedestal), proyect that vector onto the xz plane and then you have a direction to set for the plane on the pedestal.

Of course I am assuming here that the plane can only move in y axis, but that is how I am imagining the situation.

Correct me if I am mistaken.