Spielerando

Shaders for Pixel Art

Shader techniques for pixel art games, for people who build with an AI. You learn what each effect is, see it in a picture you can change, and get the rule in tested code, the same rule as a shader, and the words for your AI.

  • 24 lessons
  • about 180 minutes of reading
  • Free
Start with lesson 1

How this course works

  1. A pixel is a whole number: 0 where nothing is, 1 to 25 for the palette's colours. A shader answers with a number, so it cannot invent a colour.
  2. Everything moves in whole pixels and whole ticks. No half pixel, no smoothing, no blending.
  3. Every rule is first a small function with a test. The shader comes after, and we run it in a browser and count the pixels it gets differently from the rule.
  4. Every lesson has the mistake an AI makes most often. You can switch it on in the picture and read the test that catches it.

Who it is for

People who build pixel art games by talking to an AI and want effects that look right: a hit that flashes, water that mirrors, a lantern in the dark. You do not need to read code. Your AI reads it; you learn what to ask for and how to see that it worked.

What you need

A game or a small test project in any engine that can run shaders (Godot, a web game with WebGL, and others), and an AI you build with. Nothing to install for the lessons themselves: every picture runs in this page.

Every lesson is free to read, without an account. Films for the lessons are planned. Today every lesson is words, tested code and a picture you can change.

Part 1

One rule for one pixel

What a shader is, where a pixel is, what time it is, which colours there are, and how you know a rule is right. Five short lessons that everything after them builds on.

  1. 1 · 6 min

    What a Shader Is: One Rule, Asked for Every Pixel

    A shader is one small rule that the game asks for every pixel of a picture. The first one turns a sprite into a silhouette, and shows the mistake almost everyone makes first.

  2. 2 · 7 min

    Where Am I? Stripes by Pixel Position in a Pixel Art Shader

    A shader knows its pixel's place as a column and a row in whole pixels. Stripes across a shed show why rows work where shares of the screen come out uneven.

  3. 3 · 7 min

    Time in Ticks: an Even Conveyor Belt Shader for Pixel Art

    A shader can move things by itself if it knows the time. Counted in whole ticks, a conveyor belt moves one pixel at a time in an even rhythm; counted in seconds, it jerks.

  4. 4 · 8 min

    Only the Palette: a Colour Tint Shader That Keeps Pixel Art Colours

    Tint a whole pixel art scene towards one colour and keep every pixel in the palette: mix in red, green and blue, then take the nearest colour. Why brightness alone gets hues wrong.

  5. 5 · 8 min

    Is It Right? Testing a Pixel Art Shader, Pixel for Pixel

    How to know a shader does what it should: the rule, its test on a picture you can count by hand, the shader, and a comparison pixel for pixel. Shown on a frame round the screen.

Part 2

One sprite

Effects on a single figure: the flash of a hit, new clothes from the same picture, an outline, noise you can rely on, crumbling away, and a shadow on the ground.

  1. 6 · 7 min

    Hit Flash Shader for Pixel Art: White Blinks After a Hit

    A hit flash turns a pixel art sprite white for a moment after a hit, in blinks. Count the blinks from the hit, not from the clock, or the flash comes late and no two hits look alike.

  2. 7 · 7 min

    Palette Swap Shader for Pixel Art: New Clothes, Same Sprite

    A palette swap gives one pixel art sprite other clothes through a table of colour pairs. Look each colour up once, as drawn, or a colour just swapped is swapped again.

  3. 8 · 7 min

    Outline Shader for Pixel Art: One Pixel Around the Sprite

    An outline shader draws a line one pixel wide around a pixel art sprite on the empty pixels beside her. It asks four neighbours, not eight, and needs a pixel of room.

  4. 9 · 8 min

    Shader Noise for Pixel Art: The Same Stars on Every Machine

    A scramble of whole numbers gives every pixel a number from 0 to 99, the same on every machine and at every run. It fills a pixel art sky with stars, and shows why a quick one makes stripes.

  5. 10 · 7 min

    Dissolve Shader for Pixel Art: Crumbling Without Flicker

    A figure crumbles pixel by pixel in an order a scramble decides, and each pixel glows just before it goes. Why the time must stay out of the scramble, or she flickers.

  6. 11 · 6 min

    Drop Shadow Shader for Pixel Art: Look Back, Not Forward

    A drop shadow is the figure's shape, moved a few whole pixels and filled with one dark colour behind her. The rule has to look the other way, which is where an AI slips.

Part 3

Light with few colours

Darker and lighter without leaving the palette, steps instead of smooth fades, a lantern in the dark, a day that turns to night, and fog.

  1. 12 · 8 min

    Darker and Lighter in Pixel Art: Colour Ramps in a Shader

    Pixel art shades by stepping to a neighbour colour of the palette, not by dimming. Two small tables make a shader do it, and counting the palette's numbers down gets it wrong.

  2. 13 · 8 min

    Dithering in a Pixel Art Shader: Two Colours in 16 Steps

    Dithering mixes a colour with its darker neighbour in 16 steps by a fixed 4 by 4 pattern: a soft shade edge in a shader, and why a pattern that changes every frame boils.

  3. 14 · 8 min

    Lantern Light in Pixel Art: a Shader with Round, Dithered Rings

    A shader that darkens a pixel art scene and lights it in round rings around a lantern, with dithered edges, and why an AI's first light often comes out as a diamond.

  4. 15 · 8 min

    Day and Night Shader for Pixel Art: Darker by the Hour

    A shader that takes a pixel art scene from noon to night and back through the palette's darker colours, in dithered steps, while lit windows and lamps keep glowing.

  5. 16 · 8 min

    Fog in a Pixel Art Shader That Leaves the Figure Clear

    Pixel art fog: mist dithered in, thicker with distance, drifting in banks, and kept off the figure in front by a second picture. With the mistake that fogs her as she climbs.

Part 4

Wind, water, fire and weather

Things that move by a rule instead of drawn frames: grass in the wind, a lake that mirrors, a fire, rain, and air that shimmers with heat.

  1. 17 · 7 min

    Wind Sway Shader for Pixel Art: Grass and Trees That Bend

    A pixel art wind shader moves each row of grass or a tree sideways by whole pixels, more the higher it stands, while the root stays in the ground. With the mistake that uproots it.

  2. 18 · 8 min

    Water Reflection Shader in Pixel Art: Mirror, Darken, Ripple

    A pixel art water reflection: below the waterline the shader turns the scene upside down, a step darker by a palette table, with ripples in whole pixels. And the upright copy.

  3. 19 · 9 min

    A Pixel Art Fire Shader: Flames That Rise and Thin Out

    A fire shader in whole pixels: scrambled numbers that climb, fade with height and pick their colour from a short ramp. And why the flames an AI writes often run down instead.

  4. 20 · 7 min

    Pixel Art Rain Shader: Streaks That Never Fall in Step

    A rain shader in whole pixels: a scramble of each column decides whether it rains there and when its streaks come. And why the rain an AI writes often falls in rows, like a curtain.

  5. 21 · 7 min

    Heat Haze Shader for Pixel Art: Shimmer Without Ragged Edges

    A pixel art heat haze shader moves the rows of hot air sideways by whole pixels, in a wave that climbs like warm air, and keeps nothing from creeping in at the screen's edges.

Part 5

The whole screen

Rules for the finished picture: getting from one scene to the next, the look of an old screen, and the order in which effects have to run.

  1. 22 · 7 min

    Pixel Art Screen Transition Shader: A Dithered Wipe

    A screen transition in whole pixels: an edge sweeps from one scene to the next, softened by the 4 by 4 dither pattern. And why at 100 a strip of the old scene often stays behind.

  2. 23 · 7 min

    Scanlines Shader for Pixel Art, and When to Leave It Off

    A shader that darkens every second row of the screen for the look of an old television, without sinking dark colours into black, and the pictures it makes worse.

  3. 24 · 10 min

    The Order of Shader Effects in a Pixel Art Game

    Night, a lantern and a reflection in water in one pixel art shader, as three steps in the right order, and the order of all effects in a game, from single sprites to the screen.