Billboards with geometry shader

Billboards in video games are the 2D planes in 3D scene that are always pointed perpendicularly at the camera. They can be used to draw distance objects that doesn’t require much details, to draw particles or they can be used as a part of the editor interface. Normally the plane is rotated by transforming metrices so it face the camera, but there is another, easier way – by using the goods of geometry shader. In fact, to draw a square billboard we only need the position of it’s center and normalized size of the edge. We pass the position of the center of the billboard from Vertext Shader straight to the Geometry Shader. in vec3 inPosition; out vec4 inoutPosition; void main() { // Just pass the position to the geometry shader. inoutPosition = vec4(inPosition,1); } After that we calculate the screen position of the center of the billboard by using the world position of the center of the billboard and the view-projection matrix. This position can be used to generate a...