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.

Billboard Heart

The 2D heart rendered in 3D scene.

In fact, to draw a square billboard we only need the position of it’s center and normalized size of the edge (in example: 1.0, 1.5, 3.3 etc.)

We pass the position of the center of the billboard from Vertext Shader straight to the Geometry Shader.

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 square primitive from 4 verticies. On the occasiion, the geometry shader can be used to set the proper UV coordinates of the texture to those verticies.

Because we set only the x and y coordinates of the verticies the created primitive will face the camera and will be perpendicularly to it.

The only thing that the fragment shader is doing is setting the color of the pixels based on the passed texture.

As always, You can check the working application on github (Visual Studio 2015 solution)