GLSL Shader Pipeline

Introduction

The SoShaderPipeline modules offer an extensible GLSL shader pipeline, which is based on the SuperShader concept. The fragment and vertex shaders are subdivided into a dynamic shader pipeline which allows for an interactive addition of custom shader code. A pipeline step is modeled as a subset of several shader pipeline functions, which contain the GLSL shader code.

The main advantage over bare-metal GLSL shaders is that different aspects of the shader can be extended/exchanged without requiring to adapt other parts of the shader. You can e.g. add a new light model without having to handle the different number of fixed function lights that are the scene.

The basic shader pipeline incorporates the following OpenInventor/OpenGL fixed function state:

  • lighting (supporting all Open Inventor lights)
  • fixed function texturing
  • fog

Both the surface shading and the lighting model can be exchanged/extended separately.

Usage

The shader of a shader pipeline is generated and activated by placing a SoShaderPipeline module into the scene graph. If no other extensions are in the Open Inventor state, the generated shader will just contain GLSL code that implements the fixed function state of OpenGL at that position in the scene graph.

Any number of extensions can be placed in front of a SoShaderPipeline module and will be incorporated into the generated GLSL code. Extensions that are placed after a SoShaderPipeline module do NOT affect the created shader at all.

Since the shader pipeline is based on the GLSL shader framework, extensions can make use of the SoShaderParameter*, SoSampler*, SoImageFileSampler and SoVertexAttribute* modules and use the resulting uniforms and vertex attributes in the extensions.

Typical use-cases for pipeline extensions are:

Debugging/Development

The SoShaderPipelineDiagnosis module can be placed in front of a SoShaderPipeline module and will show the resulting shaders, errors/warnings and all pipeline steps and includes.