Color Flipping


by Alain Brobecker (aka baah/Arm's Tech)

Introduction:
The Atari ST was normally able to display 16 colours simultaneously and each one could take its red, green & blue (RGB) values out of 8 possibilities. So we had to choose 16 colours out of 83=512 possible tints (for the STe it was 163=4096 tints).

For example this square has colour R=6, G=3, B=5: 635
The refresh rate of the Atari ST was 50Hz (60Hz in the USA), meaning the image was drawn entirely 50 times per second (Hz=s-1) which is very fast, at least too fast for the eye to notice subtle changes. So one guy (who? i saw this trick from GoldFinger first) had the idea to use this refresh speed to fool us.

Basic idea:
To explain i'll tell the story of a pixel (let's call him Fred) and what happens to him during the 50 refreshes occuring in a second. During the first refresh, Fred is very angry, so he is full red with RGB=700. During the second refresh, Fred has quieted and now is RGB=766. But the third refresh he is angry anew RGB=700, then he quiets once again... etc...

700 -> 766 -> 700 -> 766 ...
So half the time Fred is very angry, and half the time he is quiet (but he seems to be a full time raving lunatic ;). In the average we would say that Fred is tempered with RGB=733...
700 + 766 = 733
Hey! The miracle is here! Since Fred is changing very quickly between 700 and 766, your eyes percieve the average value, which is 733 (please note we do the average value on each RGB compound, not (700+733)/2 though it gives the same result in this case).

Thus we can have more than 512 tints on a mere Atari ST. For example if you set a pixel to 666 during odd refreshes and to 777 during even ones, your eye will see a "virtual" tint inbetween those ones. Thus we can now choose between 153=3375 tints on a ST and 313=29791 on a STe.

But this method has a major disadvantage, which is the flickering. Suppose you altenatively give values 666 and 777 to the whole screen. In theory your eye shall perceive the middle value, isn't it? True, but your brain will also perceive a major headache, due to the luminosity difference... The overall luminosity during first refresh is 6+6+6=18 while it is 7+7+7=21 during the next refresh, and having this difference on a big surface is too much to fool your eye... Use at your own risk.

Enhancements:
First of all, the smaller the luminosity difference, the better for your eyes. I mean you shall prefer switching between 431 & 432 (difference=1) than switching between 000 & 777 (diff=21), or even between 333 & 444 (diff=3).

The other problem concerns large surface, where the luminosity will vary a lot and cause the flicker. To avoid it, we use a method called "ordered dithering"... Our goal is to obtain the tint between 6 and 7 (6.5 on each compound that is). For this we make groups of 4 pixels, and use the following patterns on the whole surface:

pattern for odd pictures: 67
76
& pattern for even pictures: 76
67
With this patterns, we already have a value near 6.5 (if pixels are small enough your eyes also takes the average) which is very good, but moreover we have an overall luminosity on the 4-pixels of 6+7+6+7=26, during odd AND even frames. Thus the luminosity problem is avoided a bit, and so is the flickering.

The End:
Ok, it's now finished for this small explanation. There exist more tricks dealing with spatial and temporal averaging, but i'm too tired just now. Now time to look at some of the marvels artiSTs created, for example GoldFinger and Lancelot have made pictures using such tricks, which explains why you have two images.