GLSL Image Processing

I had a play around doing some image processing earlier using GLSL shaders from chapter 17 of the OpenGL SuperBible (4th Edition, I’m not seeing them in the 5th) and the results aren’t too shabby. I’m rendering the skybox plus torus’ with ambient/diffuse/specular lighting and cubemap texture lookup to a FBO, then rendering a full-screen quad textured with the result of the previous pass, and it’s this full-screen quad that I’m processing to get these effects.

Pretty easy & kinda fun – next up depth of field

Image Processing Vertex Shader

Image Processing Fragment Shader

The only other bit of code worth mentioning is the generation of the texture coordinate offsets, which is accomplished with the following C++ code (yes, it’s kinda ugly – no, I didn’t write it – yes, it works):

You can then draw your full-screen quad something like this:

Job’s a good ‘un.

8 thoughts on “GLSL Image Processing”

    1. Cheers! Tis indeed a good book – 4th edition covers fixed-pipeline (glBegin(); …… glEnd();) and some shaders (but older version of GLSL), 5th edition is all shaders and pretty much up to date, so it’s a little bit harder to get started as you’re doing things the new way from day 1, but it sets you up nicely for the future!

    1. Looks nice, but no joy in Linux or Win7 via Virtual Box – will have to give it a shot next time I’m in Windows!

      Also, thanks for the credit (although it really goes to Richard Wright of Superbible fame!) :-D

Leave a Reply

Your email address will not be published.