What can geometry shader do for a Billboard?

What can geometry shader do for a Billboard?

Now that we understand the concept of geometry shaders let’s see how they can help us implement a very useful and popular technique called billboarding. A billboard is a quad which always faces the camera.

Can a geometry shader be used without a GS?

Geometry shaders are optional. If you compile a program without a GS the primitives will simply flow directly from the vertex shader down to the fragment shader. That’s why we’ve been able to get to this point without mentioning them. Triangle lists are constructed using trios of vertices.

How does the Billboard function work in OpenGL?

This function enables the billboard technique, sets the required state into OpenGL and draws the points that are turned into quads in the GS. In this demo the billboards are laid out in strict rows and columns which explains why we multiply them to get the number of points in the buffer.

What is the function of the billboardlist class?

The BillboardList class encapsultes everything you need in order to generate billboards. The Init () function of the class takes the filename that contains the image which will be texture mapped on the billboard.

How to make a Billboard always face the camera?

The GS will take care of turning the quad to face the camera and will attach the proper texture coordinates to each outgoing vertex. The fragment shader will only need to sample the texture and provide the final color. Let’s see how we can make the billboard always face the camera.

How to create a quad using a fragment shader?

Taking advantage of triangle strips we will create a quad using 4 vertices: The GS will take care of turning the quad to face the camera and will attach the proper texture coordinates to each outgoing vertex. The fragment shader will only need to sample the texture and provide the final color.