The GLSL Challenge

The GLSL Challenge is November's LearnByDoing challenge. It has a thread in Microsoft Teams, a chat where everyone taking part can talk about it. Open the Teams thread to ask questions, and to say when you've solved it.

The GLSL Challenge is one of the LearnByDoing challenges, where colleagues learn a new programming skill by using it. A shader is a small program that runs once for every pixel, one of the dots of colour that make up a picture, and sets that pixel's colour. Here you learn GLSL, a language for shaders, by writing shaders that decode scrambled pictures. It all runs in this browser tab.

How it works

Each scrambled picture is an Encoded Asset: a picture that has been scrambled by a list of steps, given on its page. Your shader undoes those steps, and the picture appears.

The On-ramp is five short practice exercises, called Milestones, numbered 0 to 4. Each teaches one new skill, with hints and a solution if you need it. Milestone 0 needs no experience, so start there.

The Puzzle comes last. It uses the same steps as Milestone 4, but some of the numbers in them are hidden, and you find them by trying. It has hints, but no button to show a solution.

The Techniques page, the last tab, shows each skill on an ordinary photo, with code. Read it and copy from it at any point.

How you'll know you've solved it

Nobody checks your work. You'll know when you see it: while your shader is wrong, the picture is still scrambled, and when it's right, a clear picture appears. The Puzzle's picture isn't shown anywhere beforehand.

How the editor works

Each Milestone and the Puzzle has an editor, where you type your shader, under a canvas, which shows what your shader draws. The editor runs your shader again every time you type. If there's an error, it's shown next to the line it's on.

Optional reading

The Book of Shaders is a free online book. Its first three chapters cover the ideas the early Milestones use: What is a fragment shader?, Hello world! and Uniforms. You don't need them, because each Milestone explains what it uses.

Start with Milestone 0