Adobe Pixel Bender Effects – Donut Shader

Introduction

This is good news for donut lovers. We will develop a pixel shader to pixelate an input image and tile it with donut like shapes. We can control donut shape by specifying inner radius and outer radius. We can also specify the donut density which in turn determines the number of donuts used and their size.

Adobe Pixel Bender

If you want to write an image shader for your Flex or Flash application it is recommended that you install Adobe Pixel Bender Toolkit. It includes the Pixel Bender kernel language and graph language, the Pixel Bender Toolkit IDE, sample filters, and documentation needed for developing and debugging shaders. Once you finish developing your shader you can export the binary code and use it in a regular Flex/Flash application.

Donut Shader

The idea is simple, we just need two circles, an inner circle and an outer circle. If a pixel is inside the inner circle or outside the outer circle we color it using the background color of choice otherwise we keep the original color of the pixel at the donut center. The trick is to create a grid of circles across the image, here is the full source code:

Live Demo

In order to use the shader above in a Flex/Flash application you need to compile and export the shader using Pixel Bender Toolkit mentioned earlier. Here is the shader in action. Try to play with it to get a feeling of what it does.

[kml_flashembed movie=”https://www.8bitavenue.com/wp-content/uploads/2012/05/pixel_bender_donut_shader.swf” height=”400″ width=”550″ /]

Flex Source Code

You can download the full Flex source code here. Thanks for reading.

Add a Comment

Your email address will not be published. Required fields are marked *