The GLSL shader provides a simple way to perform highly parallelized processing. On top of the texture mapping shown previously, we will demonstrate how to implement a simple video filter that postprocesses the end results of the buffer frame using the fragment shader. To illustrate this technique, we implement the Sobel Filter along with a heat map rendered using the OpenGL pipeline. The heat map function that was previously implemented in Chapter 3, Interactive 3D Data Visualization, will now be directly ported to GLSL with very minor changes.
The Sobel operator is a simple image processing technique frequently used in computer vision algorithms such as edge detection. This operator can be defined as a convolution operation with a 3 x 3 kernel, shown as follows:
and are results of the horizontal and vertical derivatives of an image, respectively, from the convolution operation of image I at the pixel location (x, y).
We can also perform a sum of squares...