The first pass renders all of the scene's geometry of sending the output to a texture. We select the function pass1, which simply computes and applies the Blinn-Phong reflection model (refer to Chapter 3, The Basics of GLSL Shaders).
In the second pass, we select the function pass2, and render only a single quad that covers the entire screen. The purpose of this is to invoke the fragment shader once for every pixel in the image. In the pass2 function, we retrieve the values of the eight neighboring pixels of the texture containing the results from the first pass, and compute their brightness by calling the luminance function. The horizontal and vertical Sobel filters are then applied and the results are stored in sx and sy.
We then compute the squared value of the magnitude of the gradient (in order to avoid the square root) and store the result in g. If the value of g is greater than EdgeThreshold, we consider the pixel to be on an edge and we output a white pixel. Otherwise, we output a solid black pixel.