Noise can be useful to simulate static or other kinds of electronic interference effects. This recipe is a fun example of that. We'll create the look of night-vision goggles with some noise thrown in to simulate some random static in the signal. Just for fun, we'll also outline the scene in the classic "binocular" view. The following image shows an example:
We'll apply the night-vision effect as a second pass to the rendered scene. The first pass will render the scene to a texture (see Chapter 4, Using Textures), and the second pass will apply the night-vision effect.
Create a Framebuffer Object (FBO) for the first pass. Attach a texture to the first color attachment of the FBO. For more information on how to do this, see Chapter 4, Using Textures.
Create and assign any uniform variables needed for the shading model. Set the following uniforms defined in the fragment shader:
Width: The width of the viewport in pixels
Height: The height of the viewport...