In this article, we look at Presets in Designer 2 and how to take control using Custom Presets. We also investigate how AI tools like ChatGPT can be used to simplify the process of creating new Custom Presets.
Presets in Designer 2
Designer 2 offers a variety of built-in presets which can be applied to groups of fixtures on your project. Ranging from simple gradients to more advanced effects like Perlin Noise and Starfield, these effects are a great place to start when programming dynamic lighting.
Each effect has several properties, giving you control of attributes like colour, speed and intensity. For example, the built-in Chase effect has adjustable properties for the number of steps in the chase and the colour of each step, as well as giving you control over chase direction. These properties allow you to turn a handful of built-in effects into many bespoke looks which you can use to bring effects in line with your brief and make your project stand out in the crowd.

Take Control with Custom Presets
What if built-in effects don’t offer what you’re looking for? Even with so many ways to customise each built-in effect, you might find that the effect you have in mind just isn’t available.
Enter Custom Presets: an advanced feature of Designer 2 which allows you to create your own custom effects from scratch. Behind the scenes, Designer 2 uses the Lua programming language to define presets, with scripts which specify the colour of each pixel in a sequence of animated frames. The Custom Presets feature provides you with the ability to write, import and debug your own scripts written in Lua.

Custom Presets are disabled by default and must first be enabled from the ‘Mapping’ tab of Designer 2. Click the three dots next to ‘Media’ and click ‘Enable Custom Presets’. A new ‘Custom Presets’ tab will appear next to ‘Media’ and from here, you can write or import new Custom Presets.
If you haven’t written an effect in Lua before, our Custom Presets support page is a good place to start. From here, you can explore a library of Custom Presets, all available to download for free. Each Custom Preset is accompanied by a video demonstrating the effect and a .zip file containing the .lua effect script itself, a .pd2 Designer 2 project file already set up with the Custom Preset, and a descriptive Application Note in .pdf format.
Programming Custom Presets
Once you’ve explored a few Custom Presets, you might want to have a go at writing your own.
The ‘Custom Preset Editor’ window in Designer 2 is a bespoke development environment in which you can write, build, debug and preview your presets on the fly. If you’ve not written scripts like this before, there are a few important things to be aware of.
Our Custom Preset Programming Guide in the Designer 2 help pages is the best resource to use when getting started. The guide explains how to use the pixel function, how to animate effects using frames and how to make effects loop seamlessly.
Using AI Tools to Generate Custom Presets
Advances in machine learning, particularly artificial intelligence language models like OpenAI’s ChatGPT provide a way to create Custom Presets for your dynamic lighting projects. Rather than learning how to write in the Lua programming language, it’s possible to show an AI language model a few examples and ask it to write new Custom Presets for you.
We’ve spent some time investigating what these AI tools are capable of and the results were compelling. Read on for the steps we took to create some new Custom Presets, then try it out for yourself.
We’re using ChatGPT for this article, but we had success with Microsoft’s Bing AI and Google Bard too.
First of all, it’s useful to give the AI some examples of Lua scripts which you know work well in Designer 2. To get things started, we gave the AI model an example from the Custom Preset Programming Guide and explained what the effect looks like when rendered. We also explained a few important variables.
Here is an example Lua script which creates an effect with a vertical red wipe on a black background advancing 1 pixel to the right with each frame. There is a function called ‘pixel’, which returns three numbers, between 0 and 255, which represent the red, green and blue components of that pixel. A pixel set to 0, 0, 0 will appear black. The function takes three parameters: ‘frame’ (the number of the current frame in the sequence), ‘x’ and ‘y’ (pixel coordinates). The global variable ‘frames’ is the total number of frames in the effect, allowing a seamless loop. The global variables ‘width’ and ‘height’ represent the size of the canvas. Please use this code to inform your responses to my next questions.
function pixel(frame,x,y)
-- calculate the progress through the animation
local t = frame/frames
-- compare the fraction across the effect with the animation progress
if (x/width<t) then
return 255,0,0
else
return 0,0,0
end
end
Certainly! You've provided a Lua script that defines a function called pixel. This function is responsible for generating pixel values that represent a vertical red wipe on a black background that advances one pixel to the right with each frame. The function takes three parameters: frame (the current frame number), x and y (pixel coordinates). It also uses global variables frames, width, and height to control the animation.
Now that the AI model understands the basics, we can start asking it to make new effects for us. It’s good to be as descriptive as possible with these requests and include details you might not normally think to state explicitly.
Let’s start with something straightforward and ask the AI model to modify the example we’ve already provided.
That script produces a red band moving from left to right on a black background. Can you write a new script which produces a blue band moving from top to bottom on a white background?
Certainly! Here's a Lua script that creates a blue band moving from top to bottom on a white background:
function pixel(frame, x, y)
-- Calculate the progress through the animation
local t = frame / frames
-- Compare the fraction of y divided by height with the animation progress
if (y / height) < t then
return 0, 0, 255 -- Blue color
else
return 255, 255, 255 -- White color
end
end

That worked pretty well! The AI model has modified the colours as per our request and altered the direction in which the effect moves. Now let’s try asking it to generate a completely new effect.
Based on those examples, write a script for an effect which is a rainbow bursting outwards from the center of the canvas in a circular fashion.
To create an effect that resembles a rainbow bursting outwards from the middle of the canvas in a circular fashion, you can use the following Lua script. This script will generate a rainbow gradient:
function pixel(frame, x, y)
-- Calculate the center of the canvas
local centerX = width / 2
local centerY = height / 2
-- Calculate the distance from the current pixel to the center
local dx = x - centerX
local dy = y - centerY
local distance = math.sqrt(dx * dx + dy * dy)
-- Calculate the maximum radius for the circular burst
local maxRadius = math.sqrt(centerX * centerX + centerY * centerY)
-- Calculate the progress through the animation
local t = frame / frames
-- Check if the current pixel is within the bursting circular region
if distance < maxRadius * t then
-- Calculate the angle of the pixel
local angle = math.deg(math.acos(dx / distance))
-- Adjust the angle based on the quadrant
if dy < 0 then
angle = 360 - angle
end
-- Normalize the angle to the range [0, 360]
if angle < 0 then
angle = angle + 360
end
-- Calculate the hue value based on the angle
local hue = angle
-- Convert hue to RGB
local r, g, b = hsvToRgb(hue, 1, 1)
return r, g, b
else
return 255, 255, 255 -- White background
end
end
-- Function to convert HSV to RGB
function hsvToRgb(h, s, v)
local c = v * s
local x = c * (1 - math.abs((h / 60) % 2 - 1))
local m = v - c
local r, g, b
if h >= 0 and h < 60 then
r, g, b = c, x, 0
elseif h >= 60 and h < 120 then
r, g, b = x, c, 0
elseif h >= 120 and h < 180 then
r, g, b = 0, c, x
elseif h >= 180 and h < 240 then
r, g, b = 0, x, c
elseif h >= 240 and h < 300 then
r, g, b = x, 0, c
else
r, g, b = c, 0, x
end
return (r + m) * 255, (g + m) * 255, (b + m) * 255
end


Dealing with Errors
For the example above, the AI model initially produced a script which didn't work in Designer 2. Thankfully, Designer 2’s Custom Preset Editor provides a debugging tool which helps find what’s going wrong. Clicking ‘Build’ in the Custom Preset Editor indicated that the script was compiling without any issues, but clicking ‘Run’ presented an error message: [string "script"]:18: attempt to call a nil value (field 'atan2')
This message informs us of an error on line 18 of the script, where the AI model had used the function atan2 which isn't available within Designer 2. All we need to do is give the model a helping hand and ask that it replaces this function with something different. A simple prompt such as "I don't have atan2" is all it takes for the AI model to understand what's going wrong and generate a new script which works in Designer 2.
We may have had to give the AI model a little bit of help along the way, but we’ve now got the effect we asked for. It’s good to have a simple understanding of Lua scripts so that you can assist the AI model when it doesn’t get things quite right, but leveraging the ability of AI tools to cut out the majority of the complex coding required is certainly a powerful addition to any lighting designer’s toolbox.
AI Generated Custom Presets
We’ve created a handful of Custom Presets using AI which you can browse and download below.
Spectral Waves

Dynamic Sinusoidal Curves

Colourful Rotating Bars
