Andiamo reference manual – Part 5   Leave a comment

This part of the reference manual focus on the filter layers. A filter layer applies an arbitrary image transformation to the composition stack, by using the output of the previous layer as its own input for processing. The result of the filtering operation is rendered into the composition stack, and can be further processed by filters located downstream in the stack.

The filters are implemented as GLSL shaders that run on the GPU, this allows for real-time effects to be applied to full-resolution video. There are two types of filters: simple and custom. Simple filters just apply a one-pass image transformation on the input. Examples of this type of these filters are convolution filters (blur, emboss, edge detection). In terms of the implementation, simple filters can be specified as one shader operating on a single texture and generating a single output. Custom filters, such as a bloom effect or a particle system, are the result of multiple shaders running in conjunction in a specific order.

Simple filters are listed in the data/filters.xml file:

<filters<
    <filter<
        <config<filters/blur.xml</config<
        <icon<icons/filter_layer.png</icon<
    </filter<
    <filter<
        <config<filters/sharpen.xml</config<
        <icon<icons/filter_layer.png</icon<
    </filter<
    <filter<
        <config<filters/scanline.xml</config<
        <icon<icons/filter_layer.png</icon<
    </filter<
</filters<

Each filter entry contains the config xml file for the filter, and its icon. The config xml follows the format of the texture filters of the GLGraphics library.

Custom filter have to be specified within the code of Andiamo as descendants of the FilterLayer class and then added to CustomFilterLayerLibrary (in FilterLayer.pde):

class CustomFilterLayerLibrary
{
    FilterLayer create(String name, LayerManager ilayers, AndiamoState istate, AndiamoResources iresources, AndiamoMessages imessages, AndiamoDynamics idynamics, Anchors ianchors, ScreenRect iinRect, ScreenRect icanvasRect)
    {
        else if (name.equals("custom:bloom"))
        {
            return new BloomFilterLayer("", ilayers, istate, iresources, imessages, idynamics, ianchors, iinRect, icanvasRect);
        }
        else if (name.equals("custom:zoom"))
        {
            return new ZoomFilterLayer("", ilayers, istate, iresources, imessages, idynamics, ianchors, iinRect, icanvasRect);
        }
        return null;
    }

    final String[] names = {
        "custom:bloom",
        "custom:zoom"
    };
}

class BloomFilterLayer extends FilterLayer
{
    BloomFilterLayer(String iconfigFile, LayerManager ilayers, AndiamoState istate, AndiamoResources iresources, AndiamoMessages imessages, AndiamoDynamics idynamics, Anchors ianchors, ScreenRect iinRect, ScreenRect icanvasRect)
    {

...

Filters can be added to the main data/layers.xml configuration file, but also while Andiamo is running using the add/remove filter buttons in the main menu:

andiamo-filterinterface

A filter is completely transparent right after is added added, so the color selector menu of the layer needs to be used to set the transparency to the desired value:

Advertisements

Posted June 6, 2009 by ac in Programming

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: