Biochemical Visualization Using Blender

Here at the Scientific Visualization Unit of the National Research Council in Pisa, Italy, we have been using Blender since 2008 for doing some very interesting bio-molecular visualization at the sub-cellular level.  I myself joined the team just over 3 months ago, and am eager to share some of our work with the Blender community now that the Italian soccer team can stop embarrassing themselves in South Africa.

We use Blender to visualize protein motions and interactions, as well as making short animations that show the inside of a cell in a way that had never been seen with the unaided eye.  Because one key focus of the project is scientific accuracy, a lot of time is spent to ensure that the visualization is not only nice-looking, but also scientifically accurate. The process involves using numerous third-party programs to convert the input data (atomic coordinates of a protein) into something Blender can read. We use Python extensively to help facilitate data conversion between different formats.  The result is this video:

To really appreciate the video, it helps to understand the science going on behind it.  If you are a bit lost, have a look at the explanatory note associated with the video.  The video is made and rendered with Blender in 1080p HD, we also toyed with stereoscopic rendering with some very good result.  You can download the HD stereo version from the SciVis site.

Currently, we are working to build an interactive protein viewer inside Blender.  Using Blender 2.5 as the platform, we built an interface that will allow biologist to load a text description of any protein (a PDB file), and Blender will display the imported file in an intuitive interactive viewer. (As shown below)

Why Blender? Blender is especially suitable for this task for several reasons. Its python support allows us to accomplish a lot of custom features in relatively very little coding.  Having a game engine and a physics engine built-in means we can use do realtime visualization all from one software package.  Its open source nature allows us to easily modify (at least have access to) the source code if needed.

Above is our BioBlender interface for Blender 2.5.  The protein on the right is MLCK backbone, a 1845 residue long protein.

There is still a lot of work to be done.  Blender is currently having a hard time handling large proteins that contains thousands of amino acid groups, the interface turns sluggish with as the number of object increases.   Surprisingly, the game engine performance is very fast, it manages to maintain 20fps on a laptop even with a fancy ambient occlusion shader.

Sintel Movie coloring test

Blender Institute just released a bunch of test renderings from their upcoming movie Sintel, and I couldn’t help it but try my hands on giving those wonderful images some aggressive color-grading.  I’ve included the before, after and a short justification for my choice of grading.  Criticisms welcome!

The Sintel team simply isn’t doing a good enough job, they are doing a GREAT job, and I am sure color grading is a planned part of their pipeline.  I just got carried away a bit playing with these images :D

Even though snow should be white, it doesn’t hurt to give it some tone to communicate the extreme coldness.  Blue works well in this case.

Wow, the team is doing a great job with facial animation.  This looks like a very somber scene, so it calls for some gloomy color.  I also added a dark gradient from the top, anime style.  Split toning is used to maintain the skintone while pushing the background to a cool blue.  This is the classic ‘orange-teal’ Hollywood color palette that everyone’s using.  Some love this, some hates this.

I am speculating here, but I think we want to create a contrast between the safety of the warm tent and the harsh cold outside.  So things close to the fire is made warmer, things further away is pushed to a chilling blue.  The histogram is also very left-biased (dark), so I brightened up the image a bit.

Here, our main character isn’t emphasized enough in this (what I assume would be) high motion scene due to the similarity in color. I added a warming filter to highlight Sintel to convey the classic warm-vs-cold, good-vs-evil, light-vs-dark concept.

Just added some warmth to make the image look a bit more organic and less CG.

Everything is done in Lightroom, which is an awesome postprocessing package for photos, but the same effect can be easily achieved in Blender’s composite engine.  But seriously, Sintel is going to be amazing.

Blender Scripting, a rant and a review.

I have been writing a lot of Python codes lately, and have since grown increasingly fond of the language over its minimalist approach to programming.  For the newcomers here: Python is what Blender uses for its scripting interface, with Python linked to the Blender API, one can access and modify almost anything programmatically.  This scripting interface significantly extends what is possible with Blender.  Although to call Python a scripting language is perhaps a disservice to this supremely capable and elegant language.  Python’s simplicity means it can be used as a scripting language, but it also has the power to do so much more.

Around the Blender community, I have seen some people approach Python with certain skepticism.  (“It’s programming, it must be hard!”)  But Python is intuitive.  Writing Python code is the closest one can get to writing in an natural language.  Compare with other languages, there is no semicolons, no excessive symbols and punctuations, no long compilation process before one can test the code.  To make a program in Python is a think-type-run process.

Blender 2.49 Scripting

Perhaps due to my recently found enthusiasm, I was given a chance to take a sneak peak at Michel Anders’ upcoming book Blender 2.49 scripting.  Flipping through this ~300 page book, I realized this is exactly what I would have asked for as a beginner wanting to learn how to script in Blender.  This wonderfully comprehensive book covers everything from editing object to working with material to PyDrivers, Constraints, IPOs and shapekeys.  The only notable omission seems to be the game engine component.

Sure you can look at the Blender API documentation for help, but ingredient lists does not make a cookbook.  As there still isn’t a centralized repository for Blender scripts in the Blender community,Michel managed to bridge a rather large knowledge gap with this book that is filled with useful snippet of code.

Python is not as fast as C, or as ubiquitous as Javascript.  But one can accomplish a task in Python at a fraction of the code and mental power it takes in other languages.  Which makes it an ideal language to learn as a beginner.

Blender 2.49 Scripting is available from Packt Publishing.  I eagerly awaits a second edition of the book, no doubt slewed for Blender 2.5 and Python 3?

I am folding proteins in Italy

A friend and fellow blenderhead was the first to drop the news, then my photos on Flickr confirmed it,   and now, you get to hear the news from me: For the next few month, I’ll be working at the Scientific Visualization Unit at IFC –  Consiglio Nazionale delle Ricerche Pisa, on a research project to develop new ways to visualize proteins molecules using Blender.

The project team is a well balanced mixture of scientists and artists, so you know you can expect something incredible from us :D.  The short movie they made had already been submitted to Siggraph 2010.