← all demos · chapter 04

Parallax — depth from three multiplications

Far things move slower than near things. That's the whole law: layer.x = camera.x × factor, one factor per layer. Press Run, then move your pointer across the canvas — you are the camera.

Move your pointer left and right. The three factors (0.2 / 0.5 / 0.9) are the entire depth illusion.

Try tweaking: set all three factors to 0.5 — depth vanishes instantly (the best proof of why it worked) · swap the factors (far 0.9, near 0.2) for an unsettling "wrong world" · add a fourth layer.

In Godot: Parallax2D nodes with scroll_scale = these exact factors — download parallax.gd from the Godot project. In Unity: the three multiplications go in LateUpdate(), one per layer transform. In Unreal (2D): same arithmetic driven by the camera position. Chapter 04.