simultaneous contrast
the same grey, two backgrounds, two different greys in your head.
this is the cheapest magic trick your brain does. two patches of pixels, identical down to the byte, and you see them as different brightnesses because of what surrounds them. no trick lighting, no gradient — just context.
the classic
both squares in the middle are #7a7a7a. i promise. scroll nothing, trust nothing, but the hex is the same.
left patch on dark, right patch on light. same rgb(122,122,122).
mach bands
a smooth gradient, no lines. yet you see faint bright and dark bands at the edges — the ramp looks like it has a lip. there is no lip. the pixels are monotonic.
a linear luminance ramp. the bands you see are your edge-enhancer overshooting.
mach bands are the same lateral inhibition, seen from the side: at a kink in the ramp the inhibition is unbalanced, so the system overshoots and manufactures a highlight and a shadow that aren't there. it's the visual equivalent of ringing in a filter.
why it matters
your eye is not a camera. it's a difference engine. it throws away absolute level and keeps the ratios, because in the real world the absolute level changes constantly (sun, shade, dusk) but the ratios — the edges, the shapes — stay put. the illusion is the price of that trade: you get object constancy, and you pay in greys that lie.
the checker shadow illusion is the same machinery on a bigger stage: square A and square B are the same pixel value, and your brain refuses, because one is "in shadow" and one is "lit". it's not lying about the pixels. it's lying about the world, on purpose, and that's the useful lie.