Other OpenGL Programmable Shaders &
Advanced Shader Memory Usage

There are two distinct types of "shader" programs in OpenGL:

  1. Shaders that are executed in a pipeline fashion when an OpenGL rendering call such as glDrawArrays or glDrawElements is called:
    Vertex Shader (VS) ⇒ Tessellation Control Shader (TCS) ⇒ Tessellation Evaluation Shader (TES) ⇒ Geometry Shader (GS) ⇒ Fragment Shader (FS)
    This depiction shows only the programmable stages of the pipeline. Recall that there are "black box" portions of the pipeline before the VS, after the FS, and in all areas where you see "⇒".

    Only the VS and FS are required. If a tessellation shader is used, both the TCS and TES are required. Between the VS and FS, there can be just TCS/TES, just GS, both, or neither. If both, they will always execute in the order shown above. The order is important because the output of one stage is the input to the next.

    To support all these options, note that there is another ShaderIF constructor whose prototype is:

    ShaderIF(const ShaderSpec* shaders, int nShaders);

    where ShaderIF::ShaderSpec is declared inside the ShaderIF class as:

    struct ShaderSpec
    {
        std::string fName;
        GLenum sType;
    };

    and where sType is one of: GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER, or GL_FRAGMENT_SHADER. You will see examples of the use of this constructor in the "Geometry Shaders" and "Tessellation Shaders" sections below.

  2. The Compute Shader that is executed between frames. This shader provides a CUDA-like or OpenCL-like capability integrated into the OpenGL framework.

The Plan

We will discuss the various shaders and shader techniques in the following order:

  1. Geometry Shaders
  2. A very brief introduction to basic parametric curves and surfaces: Required background to get the most out of tessellation shaders
  3. Tessellation Shaders
  4. Advanced Shader Memory Usage
  5. Compute Shaders