Compiling Blender to Increase Vertex Colour Layers

Blender usually comes with a limit of 8 vertex colour layers that can be applied to an object. As the VI-Suite uses vertex colour layers to visualise results this means that, in effect, only 8 steps of an animation can be visualised. To increase the permitted number vertex colour layers some changes are required to the Blender source code, and then Blender must be compiled. The Blender source code can be downloaded from http://www.blender.org/download/. In side the source archive file is a directory called source. Relative to this source directory the source code changes required to the 2.69 version are as follows:

  • Line 182 in the file source/blender/makesdna/DNA_customdata_types.h should be changed from ‘#define MAX_MCOL    8’ to  ‘#define MAX_MCOL   256’ or however many vertex colour layers you want. I have tested up to 256.
  • Line 143 in source/blender/render/extern/include/RE_shader_ext.h should be changed from ‘ShadeInputCol col[8];’ to ‘ShadeInputCol col[256];’

Instructions for compiling Blender for different platforms can be found here http://wiki.blender.org/index.php/Dev:Doc/Building_Blender

Shadow Study node

The Vi-Suite Shadow Study node uses an in-built function of Blender to check whether faces of the Blender geometry can see the sun at each time step of the simulation period. The Shadow Study node then composites these results to determine what proportion of time a face is in shade. A typical node set-up is shown in figure below.

ssnode1

And the video below shows the Shadow Study node in operation.

VI-Suite Shadow Study Node from Ryan Southall on Vimeo.

Wind Rose Node

The VI-Suite Wind Rose node creates a wind rose plane and a wind rose image based on the location data within the location node. The location node must be drawing its information from an EPW file to provide wind speed data. EPW files must be placed within the VI-Suite script directory in the directory EPFiles/Weather to be seen by the node. A typical node arrangement is shown below.

wrnode1

The wind rose node requires some dependencies to be installed which I dealt with in a previous blog post for OS X. Please note that as of Blender version 2.70 Numpy is installed with the OS X version of Blender and the installation of Numpy described in my previous blog post will not be required.
Installing these dependencies for Windows is more complicated and I have not figured out an easy way to achieve this yet.
On Linux, Numpy and matplotlib should be installed via your system’s package manager system and the /usr/share/blender/’blender_version‘/python directory deleted to force Blender to see the system Python installation.
The operation of the Wind Rose node is shown in the short video below.

VI-Suite Wind Rose Node from Ryan Southall on Vimeo.

Matplot dependency on OS X

The VI-Suite now requires matplotlib to be installed to provide result graphing capabilities. The easiest way to do this is to install Python 3.3 by downloading and running the ‘Python 3.3.3 Mac OS X 64-bit/32-bit x86-64/i386 Installer’ package available from here http://www.python.org/getit/.
Then download and install the numpy package ‘numpy-1.8.0-py3.3-python.org-macosx10.6.dmg’ from from http://sourceforge.net/projects/numpy/files/NumPy/1.8.0/.
Then download and install the matplotlib package ‘matplotlib-1.3.1-py3.3-python.org-macosx10.6.dmg’ from http://matplotlib.org/downloads.html.

The matplotlib and numpy packages now have to be copied to Blender’s python installation. From the /Library/Frameworks/Python.framework/Versions/3.3/lib folder copy the distutils and unittest folders to Downloaded Blender Folder/blenderplayer.app/Contents/MacOS/2.69/python/lib folder. The blender.app folder is exposed by right clicking on the Blender package file and selecting ‘Show Package Contents’.
Finally copy the numpy and matplotlib folders from /Library/Frameworks/Python.framework/Versions/3.3/lib/site-packages folder to Downloaded Blender Folder/blenderplayer.app/Contents/MacOS/2.69/python/lib/site-packages folder.
VI-Suite should now be selectable from Blender’s add-on menu.

Sunpath Node

The VI-Suite Sunpath node creates a 3D sun path diagram, sun lamp and sun mesh within Blender. The node also enables real-time control of sun position and colour based on day-of-year and hour-of-day settings. These controls also modify the Hosek/Wilkie sky orientation for realistic sky control within Blender’s Cycles rendering engine. The short video below details the operation of the node.

VI-Suite Sunpath Node from Ryan Southall on Vimeo.

Anatomy of a node

One of the simplest nodes in the VI-Suite is the location node. The location node defines the location of the building to be analysed in terms of latitude and longitude, and is a required node for Sun Path, Shadow Study, Wind Rose, LiVi and EnVi analyses.

The image below shows the Python code listing for the location node.

Basic node Python code

A node in Blender is an instance of a Python class and so the code begins with a class definition that locates the node within the ‘VINodes’ node tree.   Lines 2 to 5 identifies the name, label and icon of the node.

Lines 7 to 13 define some parameters associated with the node. Parameters are important as they not only hold values, but also create user interface elements to allow the user to alter their values. Parameters for the location node include the latitude and longitude values.

A Blender node has a number of built-in functions, but as a node is an instance of a class we call these built-in functions methods, that are called during the ‘life’ of the node. When a node is created by the user the ‘init’ method is executed and lines 15 to 21 defines what happens when this occurs. In this method a property is associated with the node called ‘nodeid’ which contains the name of the node and the name of nodetree that the node sits in. An external function is run called ‘nodeinit’ which creates some platform specific parameters the VI-Suite uses, and finally an output socket is created.

Whenever the user changes the socket connections of this node the method ‘update’ is executed, which is defined on lines 23 & 24. When the update method is executed it in turn executes an external function called socklink that checks if the socket on the other node we are connecting the output socket of this node to is the same colour. If so the connection is made, if not the connection is not made. This helps make sure the user does not construct node connections that would result in an error.

The final method we use here is the draw_buttons method where we can define the user-interface presented by the node. In this function some of the parameters of the node defined earlier are presented. For example the ‘loc’ parameter is defined as a Blender EnumProperty. An EnumProperty in Blender basically represents a list, and the loc parameter has two entries in its list: A ‘Manual’ entry and an ‘EPW’ entry. When we include the ‘loc’ parameter in the draw_buttons method Blender automatically creates a drop-down menu interface for this parameter. Similarly, the latitude and longitude parameters are defined as FloatProperties, which represent regular numbers. When these are included in the draw_buttons function, Blender creates boxes that allow the user to manipulate these numbers.

If ‘EPW’ is selected in the ‘loc’ menu then an EnumProperty drop-down menu is displayed to select the desired EnergyPlus weather file. Weather files with an .epw or .EPW extension should be placed within the vi-suite/EPFiles/Weather directory. After adding a weather file Blender needs to be restarted to see the new file.

The short video shows how the location node functions.

VI-Suite location node from Ryan Southall on Vimeo.

Installing the VI-Suite

First get hold of a copy of the most recent version of Blender (2.69 at the time of writing) from http://www.blender.org and install it. If this is the first time you have used Blender open it and select the ‘File – User Preferences’ menu item. The settings window will appear and for now simply click the ‘Save User Settings’ button in the bottom left corner. This makes sure that the Blender configuration directory is created on your system.

On a Windows 7 PC this directory can be found at  C:\Users\your_username\AppData\Roaming\Blender Foundation\Blender\blender_version

On a Mac it can be found at /Users/your_username/Library/Application Support/Blender/blender_version

And on an Arch Linux machine can be found at /home/your_username/.config/blender/blender_version

Other operating systems may vary but this directory should be created somewhere similar.

Within this folder create a directory called ‘scripts’ and within this a directory called ‘addons’.

For those comfortable with the command-line navigate to the ‘addons’ directory above and checkout, with Mercurial, the VI-Suite code from the Google Code repository with the command:

hg clone https://code.google.com/p/vi-suite/

This should place a ‘vi-suite’ directory within the addons directory.

Alternatively, a zip file containing the VI-Suite code can be downloaded from https://code.google.com/p/vi-suite/source/list by clicking the download zip button just above the list of code changes. The directory within the zip file should be renamed to ‘vi-suite’ and moved to the ‘addons’ directory.

Upon starting Blender the VI-Suite should be registered as an available add-on. The video below shows how to activate this add-on within Blender.

Activating the VI-Suite from Ryan Southall on Vimeo.

Introducing the VI-Suite

The VI-Suite is a set of environmental analysis tools presented to the user as a set of connectible ‘nodes’ within the 3D content creation suite Blender. Blender nodes have traditionally been used for the application of a sequence of post-production tasks on rendered images. More recently they have been used to define materials for Blender’s new physically based rendering system, and very recently nodes, and the nodetrees that they sit in, have become user programmable with Blender’s scripting language Python. It is this latter development that is leveraged here.

I have previously written two Blender based interfaces for environmental analysis: LiVi, for lighting simulation with Radiance, and EnVi for energy simulation with EnergyPlus. As these interfaces became more advanced it became increasingly difficult to see how I could easily manage communication between these types of analyses e.g. using accurate solar radiation data from LiVi in the temperature calculations of EnVi. It also became difficult to envisage how the data generated by these analyses could be used to flexibly manipulate geometric form for environmental parametric and generative design studies. This is where a node based system comes in very handy. By having analyses broken down in to a set of modular nodes, the user can connect these nodes as they wish, for example modifying window size according to solar radiation or light levels and density of parametrically generated shading forms.

When combined with ancillary nodes like sun path and wind rose generators, shadow study node and glare analysis nodes the VI-Suite becomes a powerful holistic tool to explore interconnections between building form and performance.