To get the best performance out of using the Hap video codec within VDMX we also recently added another new feature making it possible to use GLSL shaders to perform composition between layers. While the standard 'OpenGL- Add' and 'OpenGL- Over' modes are the most efficient options when it comes to rendering, when more complex composition modes such as 'Difference' or 'Multiply' are needed shaders are the best alternative when playing back movie files, particularly when you're not using CoreImage or Quartz Composer based FX on the layer.

One of the other benefits of using GLSL shaders for composition is that it is very easy to write your own and add them to VDMX as a way to further customize your output to your own visual style.

In this two part tutorial we'll look first at the basics of adding new 3rd party shaders to the VDMX assets folder on your Mac, and then move on to the intermediate level step of creating new custom blend modes.

Basics: Installing and using new GLSL Composition Modes

From the 'Help' menu within VDMX, you can quickly access the special directory where the GLSL shaders are installed. Copy the downloaded .fs files ('Threshold' and 'ThresholdRGB') into the 'glslCompModes' sub-folder.

Launch VDMX and choose the new option from the Layer Composition Mode pop-up menu.

Choosing the 'Show Assets Folder in Finder' menu option.

Viewing the contents of the glslCompModes assets folder in the Finder.

Installed GLSL shaders listed in the Composition Mode menu.

Intermediate: Creating your own GLSL Composition Modes for VDMX

To create a new GLSL composition mode, first create a new plain text file in TextEdit, BBEdit, or any other plain text editor. Save the file with the path extension ".fs" to the assets folder as indicated in the earlier part of this tutorial.

When creating a composition shader for VDMX, only three functions are needed, one for each potential render situation between the layers: top only, bottom only, top and bottom mix.

In this example we'll be making a basic 'threshold' style composition mode in which pixels in the top layer whose brightness is above the 'topAlpha' input variable show through to the background. To begin first create a "Threshold.fs" file and place it in the assets folder.

Then in your text editor, enter the GLSL code below, or replace with your own.

Finally, test all the shader within VDMX by creating a test project with two layers and setting the composition mode of the top layer to your new blend mode. Load some sample movies or Quartz Composer patches and try setting the opacity of each layers to a variety of different values including both on, both off, top visible, bottom visible, and both at 50% opacity to see how it behaves at different settings.