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 pixels
  • Height: The height of the viewport in pixels
  • Radius: The radius of each circle in the binocular effect (in pixels)
  • RenderTex: The texture containing the render from the first pass
  • NoiseTex: The noise texture
  • RenderPass: The subroutine uniform used to select the functionality for each pass

Create a noise texture with high-frequency noise and make it available to the shader via ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.