Hi, I'm trying to make a spherical billboard using shader.
I have done it via shader. I'm using an inverse of view matrix to canceled the rotation and scaling parts.
The vertical rotation works fine. The problem comes when I rotate around the effect that I want to make it billboard. It get twisted and not face the camera.
The vertices of these billboard effect in nostale is in x,z plane, unlike the normal one that usually on x,y plane. Any idea?
here is the GLSL.
Code:
vec3 right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);
vec3 up = -vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);
vec3 front = -vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]);
vec3 finalPosition = (right * position.x) + (up * position.y) + (front * position.z);
gl_Position = projectionMatrix * viewMatrix * transformationMatrix * vec4(finalPosition, 1.0);