My blog has been moved to ariya.ofilabs.com.

Friday, February 01, 2008

to blur or not to blur

Blur is an interesting effect, mainly because it lets us enjoy the main object yet the out-of-focus parts add something to the realism. Like in the default KDE 4.0's splash screen:

For PictureFlow, I decided to add the support for optional blur effect for the reflection, as shown in the following comparison:

It is even more enjoyable when you run the demo program and see those book covers sliding, as if they are ice skating. Shader guru can quickly point out the fakeness of the blur. Rather than blurring the "floor" after the reflection is painted there, I choose to blur the reflection for each image beforehand. Fake but fast and fun enough. As for the algorithm, it is the famous blazing-fast exponential blur from Jani Huhtanen, used among others in KDE 4's Plasma.

Another improvement is that the background color can be customized, not limited to black. In fact, black is particularly suitable to do fast reflection illusion cause blending a specific color with black can be approximated by multiplying its RGB components with a decreasing factor. But since I saw that Cover Flow for iPod nano is with white background, I thought I just let you use your favorite color for PictureFlow.

In addition, I refactored the code so that it is more maintainable. For simplicity, the horribly long look-up sine/cosine table has been reduced with the help of simple interpolation. Even better, PictureFlow now supports Qt 4 (Win32, Linux, Mac, Qtopia, Windows Mobile), Qt 3 (tested on Linux only), and Qt 2 (for Qt/Embedded platform) with a single code base. Maybe even Symbian in the future :-)

7 comments:

Sami said...

A cheap way to improve the visual quality of the blur in this case might be to also blur the edges of the images, creating a transparent fuzzy border. This would get rid of the hard edges shown in the bottom image.

A nice effect would also be to increase the amount of blurring based on the vertical position in the image. This way, the far reflection of the image would appear more blurred, simulating a "frosty" surface.

Anonymous said...

wow, you used look-up-tables for sines/cosines? I don't believe that this would give you anything these days. I remember that I tried it in Marble initially and it was slower than using the actual sines and cosines even for a quite small amount of values.
In Marble I also do linear interpolation to avoid sines and cosines ...

Temet said...

I like a lot with blur.
Nice idea ;)

Marcel said...

I would love to see a plasma applet for pictureflow to play albums by clicking on their covers!

Ariya Hidayat said...

@Sami: Unfortunately, both blurring the edges and progressive blur cause too much performance penalty for 200 MHz device. This is useful only with OpenGL (ES) support.

Ariya Hidayat said...

@Anonymous: I want this to run on devices without hardware floating-point support. Hence the look-up tables.

Anonymous said...

Wow! The blur really works; I love it!