Skip to content

ShaderLesson5

mattdesl edited this page Dec 25, 2012 · 25 revisions
start » Shaders » Lesson 5: Blurring & Bloom

This series relies on the minimal lwjgl-basics API for shader and rendering utilities. The code has also been Ported to LibGDX. The concepts should be universal enough that they could be applied to Love2D, GLSL Sandbox, iOS, or any other platforms that support GLSL.


Setup

This lesson requires understanding the Frame Buffer Object (FBO), so read up on them if you haven't already. Also ensure you are well-versed on the basics of sprite batching.

The lesson will demonstrate a gaussian blur technique in GLSL inspired by this article. The blur is applied in two passes -- horizontally and vertically -- however, our implementation will only require a single fragment shader.

Here is a visual overview of the two-pass blurring process:

Overview

You can follow along with the source here. We first load some textures, as usual, then we set up our frame buffers:

//create our FBOs
blurTargetA = new FrameBuffer(FBO_SIZE, FBO_SIZE, Texture.NEAREST);
blurTargetB = new FrameBuffer(FBO_SIZE, FBO_SIZE, Texture.NEAREST);

Other APIs

work in progress

Clone this wiki locally