I'm trying to draw an element always facing camera. I've read some articles about billboard in shaders, the problem is that I need to compute rotation out of shaders and with different objects (circles, square, mesh, …).
So, I'm trying to compute model's rotation only (not matrix, something similar to Transform.LookAt in Unity engine) but I don't know how to do, here is what I've got:
// Camera data
mat4 viewMatrix = camera->getMatrix();
vec3 up = {viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]};
// Compute useful data.
vec3 look = normalize(camera->getPosition() - model->getPosition());
vec3 right = cross(up, look);
vec3 up2 = cross(look, right);
// Default: Compute matrix.
mat4 transform;
transform[0] = vec4(right, 0);
transform[1] = vec4(up2, 0);
transform[2] = vec4(look, 0);
transform[3] = vec4(position, 1);
// What I want : Compute rotation from look, right, up data and remove "Default: Compute matrix" part.
// ???
My framework compute model's matrix from his attributes (position, scale, rotation), so I can't override it, I just want to compute rotation.