All of the particles of a particle system are typically billboarded to always face the camera. At first, you do this by calculating a model matrix for each particle and send it to the instance buffer. You could also just send the particle's position and calculate the model matrix in the vertex shader:
mat4 model = mat4(1); //Identity matrix model = translate(model, position);
This requires a function to translate a matrix, which GLSL doesn't have, so you provide one.
mat4 translate(mat4 m, vec3 p) { m[3][0] = m[0][0] * p.x + m[1][0] * p.y + m[2][0] * p.z + m[3][0]; m[3][1] = m[0][1] * p.x + m[1][1] * p.y + m[2][1] * p.z + m[3][1]; m[3][2] = m[0][2] * p.x + m[1][2] * p.y + m[2][2] * p.z + m[3][2]; m[3][3] = m[0][3] * p.x + m[1][3] * p.y + m[2][3] * p.z + m[3][3]; return m; }
You then multiply this model matrix with the camera (view) matrix. It is the resulting modelView matrix that you want to billboard by removing the rotation from it:
mat4 billboard(mat4 m) { m[0][0] = 1; m[0][1] = 0; m[0][2] = 0; m[1][0] = 0; m[1][1] = 1; m[1][2] = 0; m[2][0] = 0; m[2][1] = 0; m[2][2] = 1; return m; }