Building a Retro CRT Effect: From Shadertoy to Baselight Matchbox Shader

Hey everyone, lately, I've been asked to dive back into the world of retro aesthetics, and one thing that always stands out is the look of old CRT (Cathode Ray Tube) monitors. That characteristic scanline flicker, the subtle noise, and the slight color fringing – it's all part of a nostalgic visual language. I wanted to bring that look into Baselight (last time I did this it was for Mistika. https://www.johndaro.com/blog/2020/10/28/vhs-shader), so I built a custom Matchbox shader that accurately simulates these CRT artifacts. This post breaks down the process, from finding inspiration to creating a user-friendly tool.

The Inspiration: Shadertoy

My journey started on Shadertoy, a fantastic resource for exploring and learning about GLSL shaders. I found a great CRT effect shader (https://www.shadertoy.com/view/Ms3XWH) that captured the essence of the look I was after. It used clever techniques to generate scanlines, add noise, and even simulate chromatic aberration (that slight color separation you see at the edges of objects on old TVs).

However, Shadertoy shaders are self-contained and designed for a specific environment. To make this useful in Baselight I needed to adapt it for the Matchbox framework.

From Shadertoy to GLSL Standard

The first step was to "translate" the Shadertoy-specific code into standard GLSL. This involved a few key changes:

  1. mainImage to main: Shadertoy uses a function signature mainImage(out vec4 fragColor, in vec2 fragCoord). Standard GLSL, and Matchbox, use void main(void). We also replace fragCoord with the built-in gl_FragCoord and output the color to gl_FragColor.

  2. Uniform Inputs: Shadertoy provides inputs like iResolution (screen resolution) and iChannel0 (the input texture) automatically. In Matchbox, we need to explicitly declare these as uniform variables: adsk_result_w, adsk_result_h, and src, respectively. We also added iTime as a uniform to control animation.

  3. Texture Sampling: Shadertoy's texture function becomes the standard texture2D in GLSL.

Here's a snippet illustrating the change:

Shadertoy:

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 uv = fragCoord.xy / iResolution.xy;
    // ...
    vec4 tex = texture(iChannel0, uv);
    fragColor = tex;
}

Standard GLSL (for Matchbox):

uniform float adsk_result_w;
uniform float adsk_result_h;
uniform sampler2D src;

void main (void)
{
    vec2 uv = gl_FragCoord.xy / vec2(adsk_result_w, adsk_result_h);
    // ...
    vec4 tex = texture2D(src, uv);
    gl_FragColor = tex;
}

Making it Controllable: Matchbox XML

The real power of Matchbox comes from its ability to expose shader parameters as user-adjustable controls. This is done through an XML file that describes the interface. I wanted to give users control over the key aspects of the CRT effect:

  • Scanline Width: How thick the scanlines appear.

  • Noise Quality: The granularity of the vertical noise (lower values create more distinct lines).

  • Noise Intensity: The amount of horizontal jitter.

  • Scanline Offset: The intensity of the vertical scanline displacement.

  • Chromatic Aberration: The strength of the color fringing.

  • Time: The speed of the animation.

To achieve this, I did the following:

  1. GLSL Changes: In the GLSL code, I replaced the const float variables that controlled these parameters with uniform float variables. This is crucial – it tells Matchbox that these values can be changed externally.

// Before (hardcoded):
const float range = 0.05;

// After (Matchbox controllable):
uniform float scanlineRange;

XML Creation: I created an XML file (with the same name as the GLSL file) that defines the controls. Each control is specified using a <Uniform> tag. The most important attribute is Name, which must match the corresponding uniform variable name in the GLSL code.

<Uniform Max="0.1" Min="0.0" Default="0.05" Inc="0.001" ... Name="scanlineRange">
</Uniform>

The XML also includes attributes like DisplayName (the label in the Baselight UI), Min, Max, Default, Tooltip, and layout information (Row, Col, Page). These define how the control appears and behaves in Baselight.

Putting it All Together

The final step was to place both the .glsl and .xml files in the usr/fl/shaders directory. Baselight automatically recognizes the shader and makes it available in the Matchbox node. Pro tip, my shaders directory is a link to a network location. This way all the Baselights can share the same shaders and it makes updating easier.

Now, when I add a Matchbox node and select the CRT effect, I get a set of sliders and controls that let me tweak the look in real-time. I can easily adjust the scanline thickness, add more or less noise, and dial in the perfect amount of retro goodness.

Download the Files

You can download the complete GLSL and XML files for this Matchbox shader here:


Conclusion

This project was a great upgrade to my GLSL knowledge, demonstrating how to take a cool shader effect from a platform like Shadertoy and adapt it into a practical, user-friendly tool for Baselight. The combination of GLSL's power, speed, and Matchbox's flexibility opens up a world of possibilities for creating custom effects that can be used through out the entire post pipeline. It might be old tech but still very useful today. I hope this breakdown inspires you to experiment with your own implementation. Let me know what you think, and feel free to share your own shader creations!

How To - AAF and EDL Export

AAF and EDL Exporting for Colorists

Here is a quick howto on exporting AAFs and EDLs from an Avid bin. Disclaimer - This is for colorists, not editors!

Exporting an AAF:

First, open your project. Be sure to set the frame rate correctly if you are starting a new project or importing a bin from another.

First, open your project. Be sure to set the frame rate correctly if you are starting a new project or importing a bin from another.

Next, open the bin that contains the sequence you want to export an AAF from.

Next, open the bin that contains the sequence you want to export an AAF from.

Select the timeline and right click it. This sequence should already be cleaned for color. Meaning, camera source on v1, opticals on v2, speed fx on v3, vfx on v4, titles and graphics on v5.

Select the timeline and right click it. This sequence should already be cleaned for color. Meaning, camera source on v1, opticals on v2, speed fx on v3, vfx on v4, titles and graphics on v5.

After you right click, go “Output” -&gt; “Export to File”

After you right click, go “Output” -> “Export to File

Navigate to the path that you want to export to.. Then, click “Options”

Navigate to the path that you want to export to.. Then, click “Options”

In the “Export As” pulldown select “AAF.” Next, un-check “Include Audio Tracks in Sequence” and make sure “Export Method:” is set to “Link to(Don’t Export) Media.” Then click “Save” to save the settings and return to the file browser.

In the “Export As” pulldown select “AAF.” Next, un-check “Include Audio Tracks in Sequence” and make sure “Export Method:” is set to “Link to(Don’t Export) Media.” Then click “Save” to save the settings and return to the file browser.

Give the AAF a name and hit “Save.” That’s it! Your AAF is sitting on the disk now.

Give the AAF a name and hit “Save.” That’s it! Your AAF is sitting on the disk now.

Exporting an EDL:

We should all be using AAFs to make our conform lives easier, but if you need an EDL for a particular piece of software or just want something that is easily read by a human, here you go.

Setup the project and import your bin the same as an AAF. Instead of right-clicking on the sequence, go -&gt; “Tools” -&gt; “List Tool” and it will open a new window. I’m probably dating my self, but back in my day, this was called “EDL Manager.” Li…

Setup the project and import your bin the same as an AAF. Instead of right-clicking on the sequence, go -> “Tools” -> “List Tool” and it will open a new window. I’m probably dating my self, but back in my day, this was called “EDL Manager.” List Tool is a huge improvement since it lets you export multi-track EDLs quickly.

Select “File_129” from the “Output Format:” pull-down. This sets the tape name to 129 characters (128+0 =129) which is the limit for a filename in most operating systems. Next, click the tracks you want to export.

Select “File_129” from the “Output Format:” pull-down. This sets the tape name to 129 characters (128+0 =129) which is the limit for a filename in most operating systems. Next, click the tracks you want to export.

Double-click your sequence in the bin to load your timeline into the record monitor. Then click “Load” in the “List Tool” window. At this point, you can click “Preview” to see your EDL in the “Master EDL” tab. To save, click the “Save List” pull-dow…

Double-click your sequence in the bin to load your timeline into the record monitor. Then click “Load” in the “List Tool” window. At this point, you can click “Preview” to see your EDL in the “Master EDL” tab. To save, click the “Save List” pull-down and choose “To several files.” This option will make one EDL per video track. Choose your file location in the browser and hit save. That’s it. Your EDLs are ready for conforming or notching.

Alternate Software EDL Export

That’s great John, but what if I’m using something else other than Avid?

Here are the methods for EDL exports in Filmlight’s Baselight, BMD DaVinci Resolve, Adobe Premiere Pro, and SGO Mistika in rapid-fire. If you are using anything else… please stop.

Baselight

Open “Shots” view(Win + H) and click the gear pull-down. Next click “Export EDL.” The exported EDL will respect any filters you may have in “Shots” view, which makes it a very powerful tool, but also something to keep an eye on.

Open “Shots” view(Win + H) and click the gear pull-down. Next click “Export EDL.” The exported EDL will respect any filters you may have in “Shots” view, which makes it a very powerful tool, but also something to keep an eye on.

Resolve

In the media manager, right-click your timeline and select “Timelines“ -&gt; “Export“ -&gt; “AAF/XML/EDL“

In the media manager, right-click your timeline and select “Timelines“ -> “Export“ -> “AAF/XML/EDL

Premiere Pro

Make sure your “Tape Name” column is populated.

Make sure your “Tape Name” column is populated.

Make sure to have your Timeline selected. Then go, “File“ -&gt; “Export“ -&gt; “EDL“

Make sure to have your Timeline selected. Then go, “File“ -> “Export“ -> “EDL

The most important setting here is “32 character names.” Sometimes this is called “File32” in other software. Checking this insures the file name in it’s entirety(as long as it’s not longer then 32 characters) will be placed into the tape id locatio…

The most important setting here is “32 character names.” Sometimes this is called “File32” in other software. Checking this insures the file name in it’s entirety(as long as it’s not longer then 32 characters) will be placed into the tape id location of the EDL

Mistika

Set your marks in the Timespace where you want the EDL to begin and end. Then select “Media“ -&gt; “Output“ -&gt; “Export EDL2” -&gt; “Export EDL.“ Once pressed you will see a preview of the EDL on the right.

Set your marks in the Timespace where you want the EDL to begin and end. Then select “Media“ -> “Output“ -> “Export EDL2” -> “Export EDL.“ Once pressed you will see a preview of the EDL on the right.

No matter what the software is, the same rules apply for exporting.

  • Clean your timeline of unused tracks and clips.

  • Ensure that your program has leader and starts at an hour or ##:59:52:00

  • Camera source on v1, Opticals on v2, Speed FX on v3, VFX on v4, Titles and Graphics on v5

Many of us are running lean right now. I hope this helps the folks out there who are working remotely without support and the colorists who don’t fancy editorial or perhaps haven’t touched those tools in a while.

Happy Grading!

JD