Friday, December 10, 2010

Web 2.0 shader

The idea
Seeing all those fashionable buttons and icons on every web page, smart phone etc. I though it was about time to create a shader that can just do this for us: Generate shiny icons. So here is the result:

This is probably one of the most pointless shaders that I have made so far ;) Nevertheless it was great fun to work on. If you have read my previous blog entries you will see that this shader reuses the ideas presented in these blog entries. It is a mixture between rendering a square and circles.

Features:
The shader outputs the color map of the icon, a bump map and a black/white mask for the icon.
A large number of input parameters give you control over the shader: Roundness of the icon, position, size, highlight intensity and highlight color, bump map intensity, just to mention a few. Just play around with it and see for yourself.



The MetaSL code
If you can call yourself a mental mill owner, I recommend to step with the visual debugger though the source code and see what it happening in each step. I tried to make the code as clear as possible and it is full of comments. Nevertheless sometimes looking at the debugger and 'seeing' is far much easier than reading comments and source code.

Here are some variations of the shader. I plugged the bump map into an Illumination_phong node to obtain some crisp highlights that I added on top.

You can download the shader along with the test-icon and a mental mill project from the mental images forum:
Web 2.0 Shader Source
Feel free to modify the shader for your own needs and let me know your feedback or any questions.

Further improvements
As almost everything in life, this shader can be improved by adding a few more features to it. I will leave it as it is right now. Experienced users might want to implement the ideas mentioned below:

  • Make a softer transition for the bump map. The edges are quite hard which leads to aliasing artifacts. It would be better to ramp the normal gently.  
  • The highlight overlay could be tweaked to look nicer. Right now a simple blend between the icon color and the highlight color is performed. Trying some other blend modes might yield a more realistic looking reflection overlay.

2 comments:

  1. Nice work Ruediger. I'm digging it :)

    ReplyDelete
  2. Thanks!
    I hope I have time for an update. In the meanwhile I added the soft transition in the bump map as I hated the hard edged in the bump map. Also I intend to add a local soft highlight.

    ReplyDelete