I have been using billboards before without issues. I just calculated a point coordinate and added a 2D quad at that location in the vertex shader and it worked fine.
But this time, I am rendering in space and to render a sun, I don't render a sphere, but I render a 2D quad at a specific location and shade it so that it looks sunny, which is far nicer than anything I have created with a sphere before.
When I rotate with my ship (yaw / pitch), everything works fine. The sun moves up/down/left/right accordingly. But my ship can also roll around its Z-axis (forward). The billboard correctly rotates or stays at the same position when the ship is on the exact same axis, but, the image on the billboard doesn't rotate with it. I understand why this happens: the 2D quad isn't rotating around that axis (as it doesn't rotate around any axis), but it should in this case.
Can anyone help me with the math? I understand that I should do some part of the rotation to the vertices or the texture coordinates. I just don't know how to get it from the view matrix, or any other way to calculate this.
The view matrix comes from a quaternion which is not built up from yaw/pitch/roll to prevent gimbal lock, otherwise it would be possible to just take the roll factor I guess.
I don't think it is necessary to post my vertex shader code, but here it is anyways. I double the unit quad in size because I need to render transparent radiance around the sun itself. The fragment shader understands this.
#version 400
layout(location = 0) in vec2 aUnitQuad;
uniform mat4 uProj;
uniform mat4 uView;
uniform float uScale;
uniform vec3 uPos;
out vec2 vCoord;
void main(void)
{
vec4 p = uView * vec4(uPos, 1);
gl_Position = uProj * vec4(p.xy + uScale * aUnitQuad * 2.0, p.z, 1);
vCoord = aUnitQuad * 2.0;
}