Collin Banko

Python Programmer


Sierpinski instanced spheres


The purpose of this work was to create a script written in Python that would generate points in 3D space based off the fractal algorithm for Sierpinski's Gasket and be viewable/renderable in a number of 3D rendering software packages.


Sierpinski's gasket is created by defining the vertices/points of a tetrahedron, choosing a random point within the tetrahedron, picking a vertex/point of the tetrahedron at random, finding the midpoint between that random point and random vertex and then storing that midpoint in a list. This process is done over and over again in order to create the fractal.

The code that picks a random point from a list and finds the midpoint between two points is as follows:

Renderman Output

For each software package a different method was used in order to send the information to the program. Two methods for Renderman were created. The first being a RIB-file.

The RIB-file created can be read into into Renderman, Maya or Houdini as a RIB archive. The script for such is as follows:

The second form of Renderman output is more user-friendly. The script "listens in" on the system streams of "stdin" and "stdout" for commands given to it and subsequently sends commands to Renderman that output renderable geometry. This method is more direct than importing a separate RIB-archive full of geometry.

This is the snippet of the code to be placed in the Beauty Pass RIB scene:

Maya Output

In a similar manor as described in the Renderman output above, Maya's output in sent via a written MEL file. In order to simplify the procedure of importing the file, a connection is made to Maya via a socket port.

Houdini Output

Output to Houdini is also done via a written file of commands. Unfortunately, the process is inefficient and taxing on Houdini's interface. More work can be done to optimize and check for errors in an effort to ensure flawless execution.

Final Code

The final script incorporates all three program outputs (excluding the system I/O streams method for Renderman) in a customizable package. The size of the points, the vertices of the initial tetrahedron and seed-point, the number of points, and renderer are all user-set variables.


Sierpinski's Gasket originally seemed as though it would be a daunting task. After wrapping your head around what truly was happening, programming for this fractal proved to be simple. The main difficulties lie in output to the rendering programs. Due to some limitations in Houdini's python syntax, output is limited to a few thousand points otherwise intense slowdowns or crashing can occur.

The entire project proved informational though. Much can be improved, as with many programming jobs but I take great satisfaction in knowing that I was capable of three-plus, different output methods.