Creating a night-vision effect
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 of this:
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 5, Using Textures), and the second pass will apply the night-vision effect.
Getting ready
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 5, 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 pixelsHeight
: The height of the...