Clockworkcoders Tutorials

 




OpenGL Shading Language Overview

 

Programmable Graphics Hardware Pipeline

 

pipeline

 

Programmable Vertex Processor

The vertex processor is a programmable unit that operates on incoming vertex attributes, such as position, color, texture coordinates, and so on. The vertex processor is intended to perform traditional graphics operations such as vertex transformation, normal transformation/normalization, texture coordinate generation, and texture coordinate transformation.
The vertex processor only has one vertex as input and only writes one vertex as output. Topological information of the vertices is not available.

Programmable Geometry Processor

The greometry processor allows access to the geometry (lines, triangles, quads etc.). It is even possible to create new geometry. However, the geometry shader is not part of the OpenGL Shading Language specification. It is a multivendor extension and currently available (for developers) on NVidia GeForce 8 series graphics cards. Because this is a very important extension to the OpenGL Shading Language it is mentioned here and in some tutorials. (If you don't want or can't use Geometry Shaders, simply ignore this and let the fixed function pipeline do it!)

Programmable Fragment Processor

The fragment processor is intended to perform traditional graphics operations such as operations on interpolated values, texture access, texture application, fog, and color sum.

 

Language

The OpenGL Shading Language is similar to C. Vertex Shaders, Geometry Shaders and Fragment shaders must have a main-entry function "void main()".

I could write a specification of the whole language here but I believe the better approach is to learn by example. In the next section a simple shader source code is introduced. Every section has a simple source code to download. A good way to learn GLSL is to download those example and modify it, do your own "experiments"!

You should also download the official GLSL language specification. You can get it here (under "Miscellaneous Documents").

 

Back To: Using OpenGL Extensions

Next: Loading and compiling GLSL programs