I have found that many code for multipass rendering is complex and redundant to understand, so I would like to write a post for further reference. The key to multi-pass rendering is, instead of rendering to screen (frame buffer 0), reorient the rendering target to a framebuffer (e.g. frame buffer 1), bind the output of the framebuffer to a texture; in the next pass, bind the rendering target to screen, and bind the texture as the input of the second shader. 



Rendering Pass 1 (to texture):

Rendering Pass 2 (to screen):