Spielerando

Lesson 21 of 24Wind, water, fire and weather7 minFree

Heat Haze Shader for Pixel Art: Shimmer Without Ragged Edges

Heat haze is the shimmer above a hot road, a desert or a furnace: whatever lies behind the hot air seems to waver. In pixel art the shader moves the rows of one band of the picture sideways by whole pixels, with a wave that climbs upward. This lesson's rule also minds the picture's left and right edge, where a moved row would otherwise pull in nothing.

A pixel art road at noon in high summer, beside a yellow stubble field with round bales of straw. The beekeeper pulls a cart with two honey jars along it. Above the road the far field, the bales, a row of small hives and the poplars on the horizon waver sideways, row by row.

The whole picture is given to the rule, and it moves only the rows of the hot air, by the wave in whole pixels. At the picture's left and right edge it takes the edge's own pixel; the road, the beekeeper and her cart, below the hot air, stay sharp.

Also in this lesson 3 things to read up on 3 questions to check yourself

The idea

Hot air near the ground bends the light that passes through it, unevenly and all the time, so a far tree or a house seems to waver. In a game it says "this place is hot" without a word: a desert level, a summer road, the air over lava or a forge, the hot zone a player should keep out of.

In the picture it is noon in high summer. The air over the dusty road shimmers, and through it the far field, the bales, the small hives and the poplars on the horizon waver. The road itself, the beekeeper and her cart lie below the band of hot air, in front of it, and stay sharp.

The shimmer comes from the course's wave, sixteen whole numbers: 0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1. Heat haze in pixel art is a matter of one or two pixels. A smooth curve would ask a row of a poplar to sit part of a pixel to the right, and a picture of pixels can only show that by blurring it, which turns the crisp trees on the horizon into smudges. With the list, every row stands exactly on a pixel at every tick, and the poplars stay crisp while they bend.

How it works

The rule first asks whether its row lies in the band of hot air: rows 46 to 87 in this picture. Rows above and below are answered as they are.

Inside the band, the step of the wave is the tick count divided by the pace, plus the row's number divided by the rows setting. So a group of rows lower down is one step further along the wave than the group above it, and each step climbs one group every few ticks: the shimmer rises the way warm air does. The wave's number at that step times the strength is how far the row moves, and the pixel shows what lies that far beside it.

Then the edge. When a row moves 2 pixels to the right, its two leftmost pixels would have to show what lies left of the picture, and there is nothing there. The rule takes the edge's own pixel instead, so for a moment the outermost pixel of that row is shown once more for every pixel the row has moved. In a shimmer nobody notices that.

The slider strength goes from 0 to 2; at 2 a row moves up to 4 pixels. Rows goes from 1, a fine shimmer where every row is one step from its neighbour, to 4, coarse blocks. Pace is the ticks one step lasts: at 3 the wave comes round in 48 ticks.

What goes wrong

The mistake reads the moved pixel wherever the wave says, also past the edge of the picture. A pixel art shader reads the picture pixel by pixel, at whole places, to keep it crisp, and such a read does not stop at the edge for you: past it there is nothing, or whatever the graphics card happens to return. Many shaders that read the picture smoothly get that stop for free from the engine, so it is easy to forget the edge.

Switch the picture to "With the mistake" and look at the far left and right of the band. A dark, ragged strip flickers in and out, up to 4 pixels wide when the haze is strong. In a real game the strip may be black, the background colour, a slice of the other side of the screen, or a neighbour from a sprite sheet, depending on the engine.

Two tests catch it: "at the left and right edge nothing empty comes in" moves a tiny field by up to 4 pixels for sixteen ticks, and "a row moved off the edge repeats the edge's own pixel" checks one row moved 2 pixels each way.

The mistake, line by line

Lines with - are the rule with the mistake, lines with + the rule as it should be.

- /* Heat haze, with the mistake: the rule reads the moved pixel wherever the wave says, also past the
-    picture's left and right edge, where there is nothing. At both edges of the hot air a ragged strip
-    of nothing flickers in and out, a few pixels wide.
+ /* Heat haze: the air above something hot shimmers, and what lies behind it wavers. The rule moves
+    each row of a band of the picture sideways by whole pixels, by a wave in ticks. Each band of rows
+    is one step further along the wave than the band above it, so the shimmer climbs like warm air.

+    At the picture's left and right edge a moved row would have to show what lies past the edge, and
+    there is nothing there. The rule takes the edge's own pixel instead.
+
     From the course "Shaders for pixel art" on spielerando.com.
     SPDX-License-Identifier: MIT */
…
  }

- /** The rule, wrong: it reads past the edge of the picture and brings back nothing. */
+ /** The rule: a row of the hot air shows what lies as far beside it as the wave says. */
  export function shade(x: number, y: number, tick: number, src: Frame, p: Params = DEFAULTS): number {
    // above and below the hot air the picture stays as it is
…
    const phase = Math.floor(tick / Math.max(1, p.pace)) + Math.floor(y / Math.max(1, p.rows));
    const shift = WAVE[phase & 15] * p.strength;
-   // wrong: the column is used as it comes, even where it lies past the edge
-   const column = x - shift;
+   // never read past the picture's edge, where nothing is: take the edge's own pixel
+   const column = Math.min(Math.max(x - shift, 0), src.width - 1);
    return at(src, column, y);
  }

What the test says about the mistake

✔ rows above and below the hot air stay as they are
✔ a row of the hot air moves by the wave's number times the strength
✔ a band lower down is one step further along the wave, so the shimmer climbs
✖ at the left and right edge nothing empty comes in
    row 1 at tick 0 is 0023456
✖ a row moved off the edge repeats the edge's own pixel
    got '0023456', expected '2223456'
✔ with strength 0 nothing moves
✔ after 16 steps of the wave the air looks the same again
7 tests: 5 passed, 2 failed

Tell your AI

Write a heat haze shader for my pixel art game, over [the hot thing: a road, a desert, lava], from screen row [top] down to row [bottom].

- Work on whole pixels: each row in that band moves sideways by a whole number of pixels. No blur, no blending. Read the screen pixel by pixel (nearest).
- The wave is this list of 16 whole numbers, not a sine: 0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1. A row's step is the tick count divided by [pace, for example 3], plus the row's number divided by [rows, for example 2], wrapped to 16. Its shift is the number at that step times [strength, for example 1].
- Rows above and below the band stay as they are.
- At the left and right edge of the screen, never read past the edge: take the edge's own pixel instead.

Before the shader, write the same rule as a small plain function. It takes a grid of whole numbers (0 = empty, 1 to N = my palette), a place and the tick, and returns the number for that one pixel. Test it: rows outside the band never change; a row in the band moves by the wave's number times the strength; at both edges no empty pixel comes in, even at the largest shift. Show me the test's output. Then write the shader so that it does exactly what the function does.

The code

Three times the same rule. The first is the one we test; the two shaders are that rule in a shader language, which is what your game runs.

The rule, tested: shader.ts

TypeScript, small, and it needs nothing else. Your AI can read it and write the same rule for whatever your game is built with.

/* Heat haze: the air above something hot shimmers, and what lies behind it wavers. The rule moves
   each row of a band of the picture sideways by whole pixels, by a wave in ticks. Each band of rows
   is one step further along the wave than the band above it, so the shimmer climbs like warm air.

   At the picture's left and right edge a moved row would have to show what lies past the edge, and
   there is nothing there. The rule takes the edge's own pixel instead.

   From the course "Shaders for pixel art" on spielerando.com.
   SPDX-License-Identifier: MIT */

export interface Frame {
  width: number;
  height: number;
  index: Uint8Array;
}

export const DEFAULTS = {
  /** The top row of the hot air, counted from the top of the picture. */
  top: 46,
  /** The first row below the hot air. From here down the picture stays as it is. */
  bottom: 88,
  /** How far a row moves: the wave's number times this, in whole pixels. 0 or more. */
  strength: 1,
  /** How many rows share one step of the wave: 1 is a fine shimmer, more is coarser. */
  rows: 2,
  /** Ticks for one step of the wave. Its 16 steps take 16 times this. */
  pace: 3,
};
export type Params = typeof DEFAULTS;

/** A wave in whole pixels, 16 steps long. */
const WAVE = [0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1];

/** The number at a place of the picture; outside the picture nothing is. */
export function at(src: Frame, x: number, y: number): number {
  if (x < 0 || y < 0 || x >= src.width || y >= src.height) return 0;
  return src.index[y * src.width + x];
}

/** The rule: a row of the hot air shows what lies as far beside it as the wave says. */
export function shade(x: number, y: number, tick: number, src: Frame, p: Params = DEFAULTS): number {
  // above and below the hot air the picture stays as it is
  if (y < p.top || y >= p.bottom) return at(src, x, y);
  // a band lower down is one step further along the wave, so each step climbs one band at a time
  const phase = Math.floor(tick / Math.max(1, p.pace)) + Math.floor(y / Math.max(1, p.rows));
  const shift = WAVE[phase & 15] * p.strength;
  // never read past the picture's edge, where nothing is: take the edge's own pixel
  const column = Math.min(Math.max(x - shift, 0), src.width - 1);
  return at(src, column, y);
}

The same rule as a shader: GLSL

For WebGL 2 and OpenGL ES 3.0. Only the part marked as the rule belongs to this lesson; the rest is the same in every lesson.

#version 300 es
// A shader the pixel art way: a pixel is a whole number, 0 where nothing is, 1 to 25 for the
// palette's colours. The rule is shade(): it is asked for every pixel and answers with a number.
// Everything outside the marked part is the same for every rule. Put your own palette in PALETTE.
precision highp float;
precision highp int;

uniform sampler2D SRC;   // the picture, sampled without smoothing (nearest)
uniform sampler2D OTHER; // a second picture, where the rule uses one
uniform int TICK;        // the time in ticks, 60 a second, counted by the game

const vec3 PALETTE[26] = vec3[26](
  vec3(0.0),
  vec3(31.0, 33.0, 66.0) / 255.0, // 1: k
  vec3(75.0, 78.0, 112.0) / 255.0, // 2: n
  vec3(120.0, 123.0, 152.0) / 255.0, // 3: m
  vec3(198.0, 199.0, 227.0) / 255.0, // 4: e
  vec3(255.0, 255.0, 255.0) / 255.0, // 5: w
  vec3(246.0, 241.0, 233.0) / 255.0, // 6: c
  vec3(214.0, 205.0, 189.0) / 255.0, // 7: d
  vec3(242.0, 193.0, 78.0) / 255.0, // 8: y
  vec3(224.0, 138.0, 46.0) / 255.0, // 9: o
  vec3(194.0, 65.0, 45.0) / 255.0, // 10: r
  vec3(244.0, 163.0, 160.0) / 255.0, // 11: p
  vec3(47.0, 98.0, 240.0) / 255.0, // 12: b
  vec3(35.0, 83.0, 214.0) / 255.0, // 13: u
  vec3(157.0, 184.0, 255.0) / 255.0, // 14: s
  vec3(234.0, 240.0, 255.0) / 255.0, // 15: a
  vec3(207.0, 224.0, 255.0) / 255.0, // 16: i
  vec3(15.0, 138.0, 76.0) / 255.0, // 17: g
  vec3(124.0, 207.0, 154.0) / 255.0, // 18: l
  vec3(226.0, 244.0, 234.0) / 255.0, // 19: f
  vec3(138.0, 90.0, 60.0) / 255.0, // 20: t
  vec3(92.0, 59.0, 40.0) / 255.0, // 21: h
  vec3(109.0, 76.0, 230.0) / 255.0, // 22: v
  vec3(201.0, 187.0, 255.0) / 255.0, // 23: q
  vec3(18.0, 20.0, 43.0) / 255.0, // 24: x
  vec3(39.0, 43.0, 82.0) / 255.0 // 25: z
);

// Which colour of the palette is this? 0 where nothing is drawn.
int number(vec4 c) {
  if (c.a < 0.5) return 0;
  int best = 1;
  float least = 9.0;
  for (int i = 1; i <= 25; i++) {
    vec3 d = c.rgb - PALETTE[i];
    float away = dot(d, d);
    if (away < least) {
      least = away;
      best = i;
    }
  }
  return best;
}

// The number at a place of the picture; outside the picture nothing is.
int at(ivec2 p) {
  ivec2 size = textureSize(SRC, 0);
  if (p.x < 0 || p.y < 0 || p.x >= size.x || p.y >= size.y) return 0;
  return number(texelFetch(SRC, p, 0));
}

// The same for the second picture.
int otherAt(ivec2 p) {
  ivec2 size = textureSize(OTHER, 0);
  if (p.x < 0 || p.y < 0 || p.x >= size.x || p.y >= size.y) return 0;
  return number(texelFetch(OTHER, p, 0));
}

// a wrapped into 0 .. n-1, also for a below zero (the % sign is not safe there)
int wrap(int a, int n) {
  return a - n * int(floor(float(a) / float(n)));
}

// ---- the rule ----
uniform int top;      // the top row of the hot air, counted from the top of the picture
uniform int bottom;   // the first row below the hot air. From here down the picture stays as it is.
uniform int strength; // how far a row moves: the wave's number times this, in whole pixels. 0 or more.
uniform int rows;     // how many rows share one step of the wave: 1 is a fine shimmer, more is coarser
uniform int pace;     // ticks for one step of the wave. Its 16 steps take 16 times this.

// a wave in whole pixels, 16 steps long
const int WAVE[16] = int[16](0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1);

// a row of the hot air shows what lies as far beside it as the wave says
int shade(ivec2 p) {
  // above and below the hot air the picture stays as it is
  if (p.y < top || p.y >= bottom) return at(p);
  // a band lower down is one step further along the wave, so each step climbs one band at a time
  int phase = TICK / max(1, pace) + p.y / max(1, rows);
  int shift = WAVE[phase & 15] * strength;
  // never read past the picture's edge, where nothing is: take the edge's own pixel
  int column = min(max(p.x - shift, 0), textureSize(SRC, 0).x - 1);
  return at(ivec2(column, p.y));
}
// ---- end of the rule ----

out vec4 FRAGMENT;

void main() {
  // the pixel's place, counted from the top left as in the picture
  ivec2 p = ivec2(int(gl_FragCoord.x), textureSize(SRC, 0).y - 1 - int(gl_FragCoord.y));
  int n = shade(p);
  FRAGMENT = n == 0 ? vec4(0.0) : vec4(PALETTE[n], 1.0);
}

The same rule for Godot 4

The checked shader with Godot's names around it. We have not run this one: Godot is not part of our checks yet, so let your AI compare its picture with the one on this page.

shader_type canvas_item;
// A shader the pixel art way: a pixel is a whole number, 0 where nothing is, 1 to 25 for the
// palette's colours. The rule is shade(): it is asked for every pixel and answers with a number.
// Everything outside the marked part is the same for every rule. Put your own palette in PALETTE.
//
// Put this on a ColorRect that covers the screen, above everything it should change.
// The rule counts pixels as this shader sees them. Let the game draw at the size of its art and
// enlarge the finished picture (the project's stretch mode "viewport"), or it counts window pixels.
uniform sampler2D SRC : hint_screen_texture, filter_nearest; // what is on the screen behind it
uniform sampler2D OTHER : filter_nearest; // a second picture, where the rule uses one
// The time in ticks, 60 a second. The game counts it itself: add 1 in the _physics_process of a
// node that pauses with the game, and set it there, so a paused game pauses its shaders:
//   tick += 1
//   material.set_shader_parameter("TICK", tick)
uniform int TICK;

const vec3 PALETTE[26] = vec3[26](
  vec3(0.0),
  vec3(31.0, 33.0, 66.0) / 255.0, // 1: k
  vec3(75.0, 78.0, 112.0) / 255.0, // 2: n
  vec3(120.0, 123.0, 152.0) / 255.0, // 3: m
  vec3(198.0, 199.0, 227.0) / 255.0, // 4: e
  vec3(255.0, 255.0, 255.0) / 255.0, // 5: w
  vec3(246.0, 241.0, 233.0) / 255.0, // 6: c
  vec3(214.0, 205.0, 189.0) / 255.0, // 7: d
  vec3(242.0, 193.0, 78.0) / 255.0, // 8: y
  vec3(224.0, 138.0, 46.0) / 255.0, // 9: o
  vec3(194.0, 65.0, 45.0) / 255.0, // 10: r
  vec3(244.0, 163.0, 160.0) / 255.0, // 11: p
  vec3(47.0, 98.0, 240.0) / 255.0, // 12: b
  vec3(35.0, 83.0, 214.0) / 255.0, // 13: u
  vec3(157.0, 184.0, 255.0) / 255.0, // 14: s
  vec3(234.0, 240.0, 255.0) / 255.0, // 15: a
  vec3(207.0, 224.0, 255.0) / 255.0, // 16: i
  vec3(15.0, 138.0, 76.0) / 255.0, // 17: g
  vec3(124.0, 207.0, 154.0) / 255.0, // 18: l
  vec3(226.0, 244.0, 234.0) / 255.0, // 19: f
  vec3(138.0, 90.0, 60.0) / 255.0, // 20: t
  vec3(92.0, 59.0, 40.0) / 255.0, // 21: h
  vec3(109.0, 76.0, 230.0) / 255.0, // 22: v
  vec3(201.0, 187.0, 255.0) / 255.0, // 23: q
  vec3(18.0, 20.0, 43.0) / 255.0, // 24: x
  vec3(39.0, 43.0, 82.0) / 255.0 // 25: z
);

// Which colour of the palette is this? 0 where nothing is drawn.
int number(vec4 c) {
  if (c.a < 0.5) return 0;
  int best = 1;
  float least = 9.0;
  for (int i = 1; i <= 25; i++) {
    vec3 d = c.rgb - PALETTE[i];
    float away = dot(d, d);
    if (away < least) {
      least = away;
      best = i;
    }
  }
  return best;
}

// The number at a place of the picture; outside the picture nothing is.
int at(ivec2 p) {
  ivec2 size = textureSize(SRC, 0);
  if (p.x < 0 || p.y < 0 || p.x >= size.x || p.y >= size.y) return 0;
  return number(texelFetch(SRC, p, 0));
}

// The same for the second picture.
int otherAt(ivec2 p) {
  ivec2 size = textureSize(OTHER, 0);
  if (p.x < 0 || p.y < 0 || p.x >= size.x || p.y >= size.y) return 0;
  return number(texelFetch(OTHER, p, 0));
}

// a wrapped into 0 .. n-1, also for a below zero (the % sign is not safe there)
int wrap(int a, int n) {
  return a - n * int(floor(float(a) / float(n)));
}

// ---- the rule ----
uniform int top;      // the top row of the hot air, counted from the top of the picture
uniform int bottom;   // the first row below the hot air. From here down the picture stays as it is.
uniform int strength; // how far a row moves: the wave's number times this, in whole pixels. 0 or more.
uniform int rows;     // how many rows share one step of the wave: 1 is a fine shimmer, more is coarser
uniform int pace;     // ticks for one step of the wave. Its 16 steps take 16 times this.

// a wave in whole pixels, 16 steps long
const int WAVE[16] = int[16](0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1);

// a row of the hot air shows what lies as far beside it as the wave says
int shade(ivec2 p) {
  // above and below the hot air the picture stays as it is
  if (p.y < top || p.y >= bottom) return at(p);
  // a band lower down is one step further along the wave, so each step climbs one band at a time
  int phase = TICK / max(1, pace) + p.y / max(1, rows);
  int shift = WAVE[phase & 15] * strength;
  // never read past the picture's edge, where nothing is: take the edge's own pixel
  int column = min(max(p.x - shift, 0), textureSize(SRC, 0).x - 1);
  return at(ivec2(column, p.y));
}
// ---- end of the rule ----

void fragment() {
  ivec2 p = ivec2(SCREEN_UV * vec2(textureSize(SRC, 0)));
  int n = shade(p);
  COLOR = n == 0 ? vec4(0.0) : vec4(PALETTE[n], 1.0);
}
The test: shader.test.ts
import assert from "node:assert/strict";
import { test } from "node:test";
import { DEFAULTS, type Frame, shade } from "./shader.ts";

/** A tiny picture from rows of digits: 0 is nothing, 1 to 9 are colours. */
function picture(rows: string[]): Frame {
  return { width: rows[0].length, height: rows.length, index: Uint8Array.from(rows.join(""), Number) };
}

/** Sky in row 0, a field seen through the hot air in rows 1 to 4, the hot road in row 5. */
const FIELD = picture([
  "1111111",
  "2345678",
  "2345678",
  "2345678",
  "2345678",
  "9999999",
]);

/** A post in the middle column: shows how far each row has moved. */
const POST = picture([
  "11111111111",
  "11111511111",
  "11111511111",
  "11111511111",
  "11111511111",
  "99999999999",
]);

/** The hot air is rows 1 to 4; one row a step, one tick a step. */
const HOT = { ...DEFAULTS, top: 1, bottom: 5, strength: 1, rows: 1, pace: 1 };
const WAVE = [0, 1, 1, 2, 2, 2, 1, 1, 0, -1, -1, -2, -2, -2, -1, -1];

function row(src: Frame, y: number, tick: number, params = HOT): number[] {
  const out: number[] = [];
  for (let x = 0; x < src.width; x++) out.push(shade(x, y, tick, src, params));
  return out;
}

/** How far a row of the post has moved: where the post is now, minus the middle. */
const moved = (y: number, tick: number, params = HOT) => row(POST, y, tick, params).indexOf(5) - 5;

test("rows above and below the hot air stay as they are", () => {
  for (let tick = 0; tick < 16; tick++) {
    assert.deepEqual(row(FIELD, 0, tick, { ...HOT, strength: 2 }), [1, 1, 1, 1, 1, 1, 1]);
    assert.deepEqual(row(FIELD, 5, tick, { ...HOT, strength: 2 }), [9, 9, 9, 9, 9, 9, 9]);
  }
});

test("a row of the hot air moves by the wave's number times the strength", () => {
  for (let tick = 0; tick < 16; tick++) {
    for (let y = 1; y < 5; y++) {
      assert.equal(moved(y, tick), WAVE[(tick + y) & 15], `row ${y} at tick ${tick}`);
      assert.equal(moved(y, tick, { ...HOT, strength: 2 }), WAVE[(tick + y) & 15] * 2, `row ${y} at tick ${tick}`);
    }
  }
});

test("a band lower down is one step further along the wave, so the shimmer climbs", () => {
  for (let tick = 0; tick < 16; tick++) {
    for (let y = 1; y < 4; y++) assert.equal(moved(y + 1, tick), moved(y, tick + 1), `rows ${y} and ${y + 1} at tick ${tick}`);
  }
  // with two rows to a step, rows 2 and 3 are one band and move together
  for (let tick = 0; tick < 16; tick++) assert.equal(moved(2, tick, { ...HOT, rows: 2 }), moved(3, tick, { ...HOT, rows: 2 }));
});

test("at the left and right edge nothing empty comes in", () => {
  for (let tick = 0; tick < 16; tick++) {
    for (let y = 1; y < 5; y++) {
      const pixels = row(FIELD, y, tick, { ...HOT, strength: 2 }).join("");
      assert.ok(!pixels.includes("0"), `row ${y} at tick ${tick} is ${pixels}`);
    }
  }
});

test("a row moved off the edge repeats the edge's own pixel", () => {
  // at tick 2 row 1 is at step 3 of the wave: 2 pixels to the right. At tick 10 it is at step 11: 2 to the left.
  assert.equal(row(FIELD, 1, 2).join(""), "2223456");
  assert.equal(row(FIELD, 1, 10).join(""), "4567888");
});

test("with strength 0 nothing moves", () => {
  for (let tick = 0; tick < 16; tick++) for (let y = 0; y < 6; y++) assert.deepEqual(row(FIELD, y, tick, { ...HOT, strength: 0 }), [...FIELD.index.slice(y * 7, y * 7 + 7)]);
});

test("after 16 steps of the wave the air looks the same again", () => {
  const slow = { ...HOT, strength: 2, pace: 3 };
  for (let tick = 0; tick < 48; tick++) for (let y = 1; y < 5; y++) assert.deepEqual(row(FIELD, y, tick + 48, slow), row(FIELD, y, tick, slow), `row ${y} at tick ${tick}`);
});
What we checked
  • 7 tests pass on the rule.
  • With the mistake put in, 2 of them fail: "at the left and right edge nothing empty comes in", "a row moved off the edge repeats the edge's own pixel".
  • The mistake shows in the picture above: switch to "With the mistake".
  • The shader ran in a browser (Chrome/158.0.8127.37) on 14 pictures and gave the rule's picture in 453,600 of 453,600 pixels.

Run by pnpm courses:check on 2026-11-27 with Node v24.15.0.

Try it

Read up

Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.

Check yourself: three questions

Each answer is checked and explained at once. The questions are part of the quiz, so they count for your Game Coder IQ like any other.

Question 1 of 3Easy

The road is what is hot, yet in the picture the road and the cart stay sharp while the poplars on the horizon waver. Why is that right?

All questions of this course · The quiz and the Game Coder IQ

Next lesson Pixel Art Screen Transition Shader: A Dithered Wipe

Give the whole lesson to your AI

The button copies what to tell it together with the tested rule, its test and both shaders, so your AI has everything to build this in your game and to show you that it works.

How useful was this page?

Nobody has rated this page yet.

One click, no account. It tells us which pages to make better next.

Last updated: 2026-11-27