Getting ready

Start by setting up for rendering to a framebuffer object (FBO) with a color texture attached; we'll render the raw pre-filtered image to this texture. Create a second texture to receive the output from the edge-detection filter. Bind this latter texture to unit 0. We'll use this as the output from the compute shader. Bind the FBO texture to image texture unit 0, and the second texture to image texture unit 1 using glBindImageTexture.

Next, set up a vertex/fragment shader pair for rendering directly to the FBO, and for rendering a full-screen texture.

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.