Experiment : Real-Time Pixel Processing : Water Filter (2001)
I've always been fascinated by real-time pixel filters. Pitty enough Director doesn't permit you to have direct access to the
pixels in the video memory. This means Director is not fast enough to do real-time pixel filters but still we can try.
For this water ripple filter you need to move every pixel in the image. For every pixel you need to calculate how much it
has to move (pixel offset). That are a lot of calculations! So we can speed things up by creating a so-called lookup table. This
lookup table holds the pixel offset for each pixel in the image. The advantage of this is that you only need to calculate the
pixel offsets once in advance. To create nice waves you can use the sinus fuction to calculate the pixel offsets.
When you've created all the lookup tables you need to make an animation you can start drawing pixels. You'll need two images. The original image to copy from
and a result image to copy to. The idea is that you 'pull' pixels from the original image to the result image. For example when you want to draw the pixel on point(10,20). Then you first lookup the pixel offset of this pixel in the lookup table.
Let's say that the offset of this pixel is point(2,3). Then you need to copy pixel on point(10+2,20+3) of the original image to
point(10,20) of the result image. You have to draw every single this way.
And as finishing touch you can make this effect even more fancy by adding a little shade. You can do this by looking at the
offset of a pixel. You make the pixel darker depending on the lengt of the offset. calculate and draw every pixel in the image this way you have created a blur filter.