I need the quads to alway face the camera advanced

Hello dear patchers, this is a follow up of this old thread->

There is a demo patch showing a billboard like effect with transformations.
That is working nice until you change the scale of the quad. Then it distorts.

How to make the quad face the camera properly when it is non square?

billboard demo 2.v4p (7.8 kB)

phew, that was a lot fiddeling, but also a great learning on transformations.
so that is an approach that satisfies my needs. actually it is two examples, one in world space and the other translating the 3d coordinates to screen space.

I need the quads to alway face the camera.v4p (41.6 kB)

instead of the Inverse and the evil Decompose in the word space example its much better to use the Inverse Rotation output of the camera, it also works in corner cases and does not flicker.

Thanks for the advise. just wanted to make it more general, for example when you do not want to use the camera but make your own view and projection (like with LookAt (Transform) and Perspective (Transform) ).
about the flickering, i guess it has something to do with the up vector? can i add something clever to avoid it?
Also very curious about the corner cases you mention? And why is decompose evil?

ok the flickering is gone with the quaternion versions of decompose and rotate.

I need the quads to alway face the camera 2.v4p (42.8 kB)

this super easily done with a shader code instead of decompose, u can replace mul(pos, mul(tW,tVP)) with mul (pos,tW) done…

antokhio got a point here, in a shader its that simple.

decompose can potentially fail and is expensive to calculate. its often a sign that there is a conceptual problem in the patch. but that might just be a mathematical detail.

Thanks for the input. I am not that into shaders but that was kind of straight forward, nice. What i see with that snippet is behaviour like with the 3d to screen space translation. The quads stay the same size on screen no mattaer how far away. I can not figure out how to make them just face the camera but stay 3d ish… Sure something easy when you are a shader guy :P