Each of the gray bars in this applet is a flat, uniform gray, but we tend to perceive the grey gradually getting lighter towards the right edge of the bar (near the neighbouring darker bar) and darker towards the left edge (near the lighter neighbour). This phenomenon is called Mach Bands and can be explained by how the sensory neurons that send visual information from the eye to the brain (aka Ganglion cells) process the input from the photoreceptors.
Ganglion cells receive signals from a group of receptors in the retina, forming what is called the cell's receptive field. In some Ganglion cells, the input from the receptors in the centre of the receptive field adds to the cell's output, while the input from the receptors surrounding the centre subtract from the cell's output. (This is called an on-centre centre-surround receptive field.) If such a cell is looking at a uniform gray, the inputs from the centre and surround are balanced such that the cell's output corresponds to that gray. But when the cell's receptive field sweeps across an edge, interesting things start to happen...
When you first click in the applet, a black mask lets you verify that the gray bars are indeed uniform. Type 'm' to switch mode, and see how the input from the receptors (small circles) in the receptive field affect the output of the Ganglion cell (large circle).