Skip to content

Post-Process Pass

You'll render your scene into a texture instead of the window, then push it through full-screen passes for blur, bloom and edge detection without touching the scene itself.

About

Nearly everything a renderer does after the first triangle is draw into a texture, then read that texture in another pass. Shadows, deferred lighting and tone mapping all rest on it, so this is the weekend to get framebuffers working. You'll draw your cube scene offscreen, then draw it to the window through a second shader that can see every pixel's neighbors, which is what a blur or an edge detector needs. The trap is a framebuffer that isn't complete, which gives you a black window and no error unless you ask for the status. The thing nobody tells beginners is that a Gaussian blur splits into a horizontal pass and a vertical one, so two passes of 9 reads beat one pass of 81.

At a glance

Per requirement
25 XP
Completion bonus
150 XP
Requirements
6
Takes
One weekend
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
With other people
Locked for now
Earn two more Common badges in Graphics Programming to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Render the scene to an offscreen texture and draw it back to the window. Make a framebuffer with a color texture and a depth attachment, check its status before you use it, draw your scene into it, then draw that texture on two triangles that cover the window. It should look exactly as it did before, which is the point. Take a screenshot with the offscreen texture also drawn at quarter size in a corner so the extra pass is visible. Photo
  2. 2
    Run a 3 by 3 kernel and show sharpen, box blur and edge detection. Sample the eight neighbors at an offset of one over the texture size, multiply by the kernel weights and sum. If the whole screen goes dark or blows out to white, your weights don't add up to what you think. Take a screenshot of the three kernels side by side on the same frame. Photo
  3. 3
    Blur with a separable Gaussian in two passes. Blur horizontally into a second texture, then vertically into a third, with weights from a Gaussian rather than all equal. Count the texture reads per pixel for the two-pass version and for a single pass of the same radius, and compare the frame times. Take a screenshot of the blur with both counts in the post. Photo
  4. 4
    Add bloom by blurring only the bright pixels and adding them back. Keep the pixels over a brightness threshold, blur that texture, and add it on top of the original. Put one bright object in the scene and move it. Film a few seconds of the glow following it. Video
  5. 5
    Resize the window without the picture stretching or going blank. Every texture you created has to be thrown away and rebuilt at the new size, and the viewport reset to match. Film yourself dragging the window corner from small to large with the scene still correct. Video
  6. 6
    Put each effect on a key and hand the keyboard to someone else. Blur, bloom, edge detection and off, each on a number key, with the frame time on screen. Give it to someone who hasn't seen it, film them flipping through the effects, and tell us which one they stopped on. Video