Dune (Sand Worm)

GLSL Shadertoy Shader

There’s a new Dune movie coming out soon, so I thought I’d make a ‘Dune’ shader (based on the 1984 version).

Nothing too complex in this scene. It’s the first time I’ve used polar coordinates in an SDF (for the teeth and mouth segments), but the landscape is just a simple FBM noise. Ripples are added outside of the SDF to keep the frame rate higher.

The GLSL shader source can be found here, and a 360° VR view here.

Silence of the Lambs

GLSL Shadertoy Shader

For this shader I wanted to write something that used textured stone walls, as I hadn’t really tried writing that effect before. The cell scene Silence of the Lambs movie seemed to lend itself as inspiration, as it would also allow me to add some cool reflections from the cell glass.

The stone pattern was made using a voronoi pattern with a couple of layers of noise on the material to add roughness. All the walls are completely flat, but when applying the material I tweak the normal vector to add dynamic highlights and shadows as the camera moves.

I’m quite pleased with the outcome, although it would have been good to add some pencil-drawn artwork onto the cell walls. Technically doable, but the scene was making my GPU groan, and I like to keep the frame rate reasonable for the majority of people.

The GLSL shader source can be found here, and a 360° VR view here.

The Fly

GLSL Shadertoy Shader

The challenge for this shader was to a) pay tribute to an awesome movie, and b) to add some animated content. I actually got quite attached to the little Fly – It was fun working out how to make a dot move like a fly, and go through the ‘transporting’ process with a bit of character.

The textures are based on FBM noise – In the case of the wood, once axis is squashed much more than the other. Even the plain walls have some subtle noise added to them, making them look a but more realistic than they would if perfectly flat.

I cheated with the vertical drain pipe – It is actually infinitely long to keep the code simple. It definitely looked strange when the scene was viewed in VR, so I had to add some distance fog when looking up.

The GLSL shader source can be found here, and a 360° VR view here.

Ready Player One

GLSL Shadertoy Shader

After watching Ready Player One way too many times (Then reading the book. Then reading the second book.), I figured I just had to write a shader. Starting of with some reasonably straight-forward modelling of the Iron Giant (using axis symmetry to get lots of objects ‘for free’), I then added the landscape, the ‘force field’, and then the towers.

This is the first shader I have made compatible with VR, and it works really well. It was amazing to see how well the infinite landscape and stars in the sky added to the realism, and the camera angles really make the Iron Giant ‘giant’. I spent ages just looking around the ‘world’ thinking ‘I made this!’.

The GLSL shader source can be found here, and a 360° VR view here.

GLSL Shader Shrinker

I have written many GLSL shaders over the last few years, most of which can be found on the Shadertoy website, and over time I’ve built up some code which I use as a ‘starting point’ for ray-marched scenes.

An example of one of my ray-marched scenes.

After writing a shader I then review the code to delete any unused functions, simplify calculations, and optimize performance, and generally get things into a state where I don’t mind people taking a look.

It occurred to me that much of this process can be automated, so I wrote a Windows tool which does just that:

GLSL Shader Shrinker

The C# source (and prebuilt Windows installer) can be found on GitHub at this location:


See here for a full list of features.

Arduino Code – Performance

I’m currently making a self balancing robot, powered by an Arduino Nano, and decided to use NEMA 17 stepper motors to power it.

The DRV8825 motor drivers are great, but cannot be driven using a PWM signal. Consequently the Arduino code must send a ‘step’ signal to the correct pin many times per second – Easily in the thousands if you require a decent amount of speed, especially if you’re micro-stepping.

Performance is critical…

Continue reading “Arduino Code – Performance”