Archive for December, 2009

A Single Step

Wednesday, December 30th, 2009

As I mentioned in the previous post, I have a hard time getting started. Much like I have a hard time committing to doing laundry. Or cooking dinner. I think about all the steps needed to successfully wash clothes or cook a 3-course meal and I get all flustered and the lazy gene kicks in. But if I stop thinking about all the necessary steps and just focus on the next logical step, the chore seems to finish itself.

I suffer in the same way with coding. I’ll think, “I really want to make a robust environment complete with weather systems and night-day cycles and wind and trees and grass and clouds and bugs and birds and valleys and…” and before I even have a chance to get started, I overwhelm myself with all that needs to be done.

(note: Any code you see will likely be pseudocode based on bits from Cinder, Processing, OpenGL, GLSL, and whatever else might strike my fancy. These posts aren’t meant to be source-code repositories. I want to talk more about my process and not my actual code. There are much smarter people out there that can explain how to code. I’d rather talk about why I code).

Vec3f point = Vec3f( 0.0f, 0.0f, 0.0f );

What could be simpler than a single point? It is a location in space. A single x, y, and z position. It helps to ground me in the void. It is something to look at. By creating a point, I am giving myself an anchor. It becomes the focus of my attention. Something infinitely small in a space that is infinitely large.

There is definitely something compelling about the single point in a void. It is a perfect representation of duality. The void represents the infinite, an expanse which has no end. The point represents the finite, a location which has no dimension. What better place to start?

I have been referring to the void as black and the point as white. I do this because of the obvious correlation to outer space. We know the universe to be mostly empty space which to our eyes comes across as black. It is generally devoid of any light. In programming, we show this by setting the red, green, and blue components to zero. I think of a point as being like a star in space. To our eyes, it is a pinpoint of white which is represented with red, green and blue values of one.

Next up: Giving this point some personality.

In the beginning…

Tuesday, December 29th, 2009

Void

This is how all my projects begin.

There is no red, green or blue. A complete absence of content or meaning. Anything can exist there. Any form. All possible worlds. But for now, it is the computational equivalent of nothingness.

Darkness within darkness. The gate to all mystery.

When I decided to attend art school, I was going to major in painting. I had a decent technique. I knew what paints to buy. I knew which brushes would last the longest. I would buy a large canvas, prep it with gesso, and then just sit and stare. Making that first mark was hard for me. I envied those that were able to just dive right in, seeming to know exactly where they wanted to end up. I was not like them. I wanted to plan it all out in my head before starting. As a result, I wasn’t a very good painter.

It is like the eternal void: filled with infinite possibilities.

My hesitance stems from not knowing what I want to create. When I start a new project, I occasionally have an idea in mind but far more often I simply want to create something new. I want to start down a path. I do not know where I want to go but I know that I want to go somewhere.

A good traveler has no fixed plans
and is not intent upon arriving.
A good artist lets his intuition
lead him wherever it wants.

All I need to do is place brush to canvas. The simple act of starting is enough. I need not know where I want to go. By simply going, regardless of which direction I choose, I will be well on my way. Even if I do not yet know where that destination lies.

A journey of a thousand li begins with a single step.

Next up: Taking that first step.

The quotes in this post are from the Tao Te Ching, as interpreted by either Stephen Mitchell or Jane English and Gia-fu Feng.

You have been warned

Monday, December 28th, 2009

I have been maintaining this blog since July 2005. Sometimes I post frequently, as often as once per day. Usually the frequency is closer to once per month. However, in that month there are usually several posts that were partially written and abandoned because I felt I wasn’t offering anything new. At some point I inevitably start to think, “Everyone knows this stuff so why bother writing it out.” It’s like I’m writing to tell you all that bacon tastes really good. Everyone knows that bacon tastes really good so what is the use in telling you.

Many of you have a stronger grasp on coding because you studied it in school or have just been doing it a lot longer than I. Many of you have a weaker grasp on coding because you are coming at it from a different discipline and just haven’t been doing it for very long. Some of you are only interested in source code. Some of you are only interested in viewing the outcome. Some want to know my inspirations. Some want to know about the tech. Some of you want music videos and send me links to your myspace page. To appeal equally to all of you is an impossible task.

I have decided that I will start publishing more of the abandoned posts. Hopefully, you will learn a bit more about why I do what I do, instead of just reading about what I have done. What’s the harm, right? It’s not like you can leave me mean comments. I turned those off long ago.


Cymatic Ferrofluid

Wednesday, December 9th, 2009


Picture by munkt0n

This black oil is the reason I code. Not literally but it has had a profound impact on what I find myself coding. In 2002, I bought a small amount of ferrofluid off the internet. It was around the time when I started to learn Processing. I began asking for advice on the Processing forum on how to translate the formulas for magnetism into code. I received a great deal of help and after a couple days, I had a working 2D prototype. I have been using some version of this prototype ever since. You can see the prototype here but it was written for a pre-beta Processing so the code is pretty old. If you are looking for source code, I recommend Shiffman’s tutorial on forces.

The reason the black oil appealed to me was that it allows you to visualize the invisible field surrounding magnets. Its like a three dimensional execution of the iron filings test but much more mesmerizing. I instantly wanted to know more about them. Why do they behave the way they do? Why are they spaced out just so? What insane amount of math is going on behind the scenes?

I recently came across a similar looking phenomenon when looking for late night distraction on YouTube. Cymatics is described by wikipedia as being “the study of visible sound and vibration”. Below is an image of how vibrations from audio can create non-newtonian structures in a cornstarch and water solution.

If I wanted to create a similar looking structure, I would fill a space with magnetic particles (which would all push away from each other) and corral them with a central gravitational force (which would pull them all towards the center). It would look like this:

It is not a bad solution, but it doesn’t really have any personality. It just looks like the result of a circle-packing exercise. Not only that, it isn’t descriptive of the process I am trying to model. With the ferrofluid, there was no central gravitational force tying everything together.

Recently, I revisited the magnetism code. Somewhere in a flurry of ‘what if‘ guesses, I tied the mass/charge ratio to the particle’s distance from the origin. It ended up working surprisingly well.

As a particle moves towards the center, it would gain mass. If it moves towards the edge of the threshold, it loses mass. I added a hint of Perlin noise to break up the circular boundary. It is mesmerizing to watch the particles fall into place. Something about it feels right.

The next step was to disguise these particles. I added them to the multitouch project I have been working on (which I will talk about in my next post). In addition to the goo being distorted by touch, it can now be distorted by the magnetic particles. Every particle tells the mesh at the corresponding location to distort itself by an amount equal to the mass of the particle. Additionally, each particle creates large but shallow surface ripples. Again, the larger the mass, the larger the ripple. This creates a lens distortion which keeps the mesh surface dynamic.

This project also uses webcam input as a simple environmental reflection. I realized I could get a simplified subtle global illumination effect by having the webcam pull in color and brightness directly from the output, creating a highly decaying feedback loop. In short, I draped a piece of white paper over the laptop webcam so that the camera only saw light coming off the monitor.

Here are a couple short renders. They reflect realtime performance. I hope to have videos with audio soon.

Cymatic Fluid from flight404 on Vimeo.

Cymatic ferrofluid, lighting test from flight404 on Vimeo.

Cymatic ferrofluid from flight404 on Vimeo.

Next up, I will talk about the process I used for creating the goo itself. Perhaps eventually, I will be able to code my own cornstarch monsters. Stranger things have happened.