Creating a night-vision effect
Noise can be useful to simulate static or other kinds of electronic interference. 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, Rendering to a Texture), and the second pass will apply the night-vision effect.
Getting ready
Create an 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, Rendering to a texture.
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 viewport in pixels...