Friday, April 28, 2006

Shhhh..... It's a Secret!


Here is a rendering of a project that I am working on. I am not ready to be talking about it yet, as it might end up being important and highly valuable. You can draw your own conclusions about what you see here.

All I am going to say is what is already available to observant web-browsers. This shot is titled floorplan_fractal1...

Monday, April 17, 2006

Brownian Rain

WOOOOOOOOOOOOHOOOOO!

this is good stuff...
I call it "Brownian Rain," and its going to get better soon. More on this to come as I noodle with it, but so far so good. This is 100 little brownian particles going nuts from random spots around the origin. I want it to spawn around the camera so you are engulfed in them like rain...


Here is a newer variation. The particles spawn all around the camera and have random lifespans. The darker lines are the paths of near-dead particles.

Wow so I just took this idea and ran with it. Here is some more stuff based on the same concept.

These ones are made by introducing a small bias into the randomness so that a particular direction is favored. You can easily see the progression of movement from the particle well (the pointy end) along the bias vector.

I think this is the high point of the website so far. I am quite pleased with these renderings. Keep in mind that all of these renderings were produced with the same algorithm across different instances and with some variable tweaking. This is definitely some of my best work.

Sorry, I am getting a bit excited. There are lots of applications for something like this, though, and it is really fast to compute cause there is basically no computation. The original ball is still the king though.
Ok, then i was thinking, why not add gravitation to the system? I did and this is what it looks like. The particles all start far away from eachother and gradually are sucked together.

So next I had to try something even weirder. I started the particles close together, added in the bias, and adjusted gravitation to the point where the particles gradually start to reach escape velocity. The resulting rendering is a 3D image of what a timeline of the big bang might have looked like. At first its a singularity, but it cannot sustain that level of energy and particles start to seep off its event horizon... ...Then again, it also looks like a piece of celery.

Thoughts on the Future of Gaming


the majority of this post was originally a comment that I left on my friend Namaste's blog. To see the whole conversation, go to http://namaste.soylentsoft.net/2006/04/01/future-game-design-methods/

So the topic is the direction of game design and emergent systems. Namaste's proposition is that increases in computer speed are allowing for more and more emergence in contemporary games, but also that a game designer can embrace emergence in his/her outlook from the beginning. Namaste uses the example of Will Wright's philosophy towards the upcoming game Spore and how he used a rapid prototyping model instead of the more traditional "2 years of whiteboarding" approach.

The idea is that you can get emergence from the rules of the system, but you can also get emergence through a more elastic, dynamic creation of the system in the first place. If you approach the problem with an open mind and some imagination, a designer can actually encourage emergence.

Scott Cronce told me that EA can afford to produce two “risk games” each year. These “risk games” are defined as games that do not closely follow the archetype established by a previously successful archetypal game. Spore is one of those games.

What is really interesting is this: the only reason that EA can afford to gamble on 2 high risk ventures per year is that they produce so many bland, lifeless rehashes. Not that these games are bad, in fact I believe that the vast majority of EA games are in the “good” category, they are just unimaginitive. For those of us that highly value imaginitive games (which Luke, Namaste, and myself certainly consider ourselves to be), this means that we can get what we want (spore) but only as long as the people who dont value imaginitive games (see anyone who obsessively plays counterstrike) also get what they want.

It is only because there are millions and millions of people paying 50 dollars for a coat of new paint on Madden each year that Spore exists in the first place.

Make whatever you will of this situation, but I see it as a good stepping-stone towards the time when virtually all gamers have seen the light and when game companies can make only great, original, high-quality games (and I believe that this is EA's long term philosophy also). If game companies can get enough creative games out the door, I believe that a paradigm shift will take place. Eventually, after playing many games like Oblivion, the public will refuse to pay so much for the next version of Madden. It certainly doesnt cost as much to produce Madden ‘06 as it does to produce Oblivion, yet they cost the same.

Only truly ignorant gamers (read 99% of the gaming population of Earth) will continue to pay more for less. Eventually, even a process as slow as natural selection will run its course.

Projection: Either we have a speciation of gamers into Homo-sapiens and Neo-sapiens, or we convince all those who play mediocre games every day to get a clue. I think the movie industry is going through the same growing pains right now. We are smarter, though, cause it took them nearly a century to figure it out


Imagine that you came up with this great experimental game idea that would most definitely produce emergent behavior. You work on one version with 10 million dollars and you produce an amazing skeleton of goodness. You ship it out there or zap it to the nets, and people eat it up. It's good stuff and everyone is in to it.

Now go back in time and imagine if you started the same project with 200 million dollars. You could develop the same code and then, at the very least, buy a boatload of supercomputers and a small building to put them in. You set up your system on the computers and let it run for half a year, THEN you release it. With the extra manpower that you could afford on the side, you could probably complete the whole process in the same amount of time.

The amount of content that would be produced with the second model would be exponentially larger than the original. People would have a ridiculously huge would to explore right from the getgo. When you come into the world, it is fully formed for the most part. You can create your works and then you die, but you dont start out in a void, or a nearly blank canvas. Now, I agree that there could be an amazing design that did start with a blank canvas on purpose, and it could still be a mode in the second version, but you would also have the other crazy computer-rendered world there for those who wanted to explore it.

I think the projects that you are working on will eventually lead there, as I hope mine will, but what we hope for is a SYNTHESIS of the two. The games industry is massive, and it can easily support a full cornucopia of ridiculous games in only a few years. If we can get the major studios and the major funding sources towards the good stuff, then we win. Gamers everywhere win, and the payoff will be big-time.

I hope your goal is to create the stuff at the beginning, but work towards something larger, something bigger than what exists elsewhere. To do something like that you need people. Our civilization is what makes us strong, and if you get a bunch of brilliant artists together the result is magic.

Wednesday, April 12, 2006

Brownian Motion: the Drunken Amnesiac Particle

UPDATE: Luke Palmer helped me fix the problem, and now the distribution looks uniform!
The above rendering is with the new code, which replaced the old code below.

We learned about Brownian motion in fractal class today, so I programmed up a little guy to run around drunkenly, and I taught him to drop breadcrumbs so that I could see where he went. The result is quite beautiful, even though the fundamental basis of the rendering is totally "random," meaning the directions of the steps are taken from a random seed.

*UPDATE*: I was falling asleep last night, when the thought struck me that I should show the path of the particle as opposed to a cloud of points. It seems so *$%#&ing obvious to me now that I can't imagine how I didnt think of it this way to begin with. After I implemented the path trace (see above rendering), I thought back to my CAGD class (Computer-Aided Geometric Design) and remembered b-splines. The idea of a b-spline is to extend a Bezier curve into a long "frankenstein" curve that is a concatenation (and combination) of any number of Bezier curves into one composite curve, which is defined by the control points and a sequence of knots which define the time spent in each portion of the curve (which basically means "how fast the particle is moving through the various sections of the curve"). This technique is used extensively in computer animation, for example Pixar films. The animators use a b-spline to trace the path of an object through the virtual world, like a ufo flying through space, and the knot sequence determines the acceleration and speed of the ship through the various turns, twists, and straights.

If I have some time, and if I can get my head around it, I will try to turn the path of the particle into a sequence of control points for a b-spline. The knot sequence wouldnt be too important for this application, but to ensure that the curve is as smooth as possible, they should be uniformely spaced through the middle, one per control point, and a multiplicity of two or three on the endpoints. The end result of this method would be a nice, pretty, smooth curve that represented the particle's path as opposed to the sharp, geometric, computerized form that it has currently.

Also, I think that it would be a closer approximation of actual brownian motion, because I would be treating my collection of points as a sample instead of a population. The b-spline would approximate what the particles actual path might have been, since in reality the particle's path would be continuous (at least) through its second derivative (not sure about this... any math people want to comment or correct me or give a specific explanation?). If I used the b-spline technique, it would be C2 and G2 continuous, which mean, *basically* (look them up for more detailed info), that the curve is continuous on its first and second derivatives through all junctions.

*END UPDATE*

************2ND UPDATE*****************

Brownian Motion in full continuous glory! I used the path samples as control points and formed a uniform cubic b-spline! Now the particle appears to actually fly through the air in a somewhat realistic way. The laws of physics are no longer put on hold!

Here is the equation that I used for you b-spline junkies:

vec result= (1.0f/6.0f) * (pow((1-t), 3) * p[3] + (3 * pow(t, 3) - 6 * pow(t, 2) + 4) * p[2] + (-3 * pow(t, 3) + 3 * pow(t, 2) + 3 * t+1) * p[1] + pow(t, 3) * p[0]);

Where p[0], p[1], p[2], p[3] are current and previous 3 points. p[0] is the current point, p[1] is i-1, and so forth, and t is a parameter that ranges across [0, 1] by increments. In these renderings, I used an increment of 0.05 to get 20 piecewise chunks for each curve segment. As t goes from 0->1, the curve from p[1] to p[0] is traced using the information of the previous points to maintain continuity.

This is a very basic b-spline equation but it does the trick. If you want to see a more palatable (but less functional) representation of this equation, go to wikipedia and search for "cubic b-splines" or just "b-splines."

Here are some renderings: DONT CLICK ON THEM FOR A CLOSER LOOK! because of the smoothness of the curve, there are some major aliasing problems resulting from blogger's compression. The best way to view these renderings is the way they look here on the page.

note: although it appears that there are some cusps, keep in mind that these are fully 3d particle path traces, and if viewed from a different angle, the cusps are all revealed to be tight loops.

***********end 2ND UPDATE********************




The code I am posting should be completely executable (if you set up an opengl window), and providing you write a function called randrange(float min, float max), which returns a random floating point number between the two boundaries.

Note: I still cant post code properly for some reason, even when i use the tags that they say should work online. I have changed the line that keeps getting chopped out with psuedocode. This is the best solution i could come up with. sorry.

[code]
class brown
{
public:
vec position;//mean

float range; //"variance"

int stepcount;

bool live;

vec varray[2000000];
int varray_cursor;

brown()
{
position=vec();//(0,0,0)
range=100;
stepcount=0;
live=true;

varray_cursor=0;

srand(time(NULL));
}


float randrange(float min, float max)
{
return float(rand()) / RAND_MAX * (max - min) + min;
}


step()
{
vec direction;

direction.x=randrange(-1, 1);
direction.y=randrange(-1, 1);
direction.z=randrange(-1, 1);

direction=(~direction)/10.0f;

int count=1;
//pseudocode
for(int i=0; i less than range; i++)
//end pseudocode
{
if(((int)randrange(0, 1000))%2==0)
count++;
}

direction*=count;

position+=direction;


varray[varray_cursor].x=position.x;
varray[varray_cursor].y=position.y;
varray[varray_cursor].z=position.z;
varray[varray_cursor+1].x=position.x;
varray[varray_cursor+1].y=position.y;
varray[varray_cursor+1].z=position.z+2.0f;
varray_cursor+=2;
}

tick()
{
if(live)
step();
if(stepcount>=1000000)
live=false;

draw();
}


void draw()
{
glColor3f(1, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_FLOAT, sizeof(vec), &varray[0].x);
glDrawArrays(GL_LINES, 0, varray_cursor*2);
}

};

[/code]


By changing the variable "prob", the "width" of the drunken particle's path is increased or decreased, which accounts for the difference between the crack above and the nebulous cloud below. The closer prob is to -1, the thicker the cloud. The closer prob is to 1, the narrower the cloud. (note: the code no longer works this way. Luke pointed out that there is an inherent bias towards the negative in computer representations of numbers, so the code has been changed to a x%2=0 binary selection where x is a random number. The steps can be as long as 100, but it is insanely unlikely. This represents a somewhat reasonable probability structure, but not a bell curve. This is more like a gravity well than a bell curve.)



Clearly something is broken here. I would expect the particle to wander more aimlessly than it does. It seems as if either x, y, or z is biased towards a single direction. It is not completely locked in that direction, as can be seen if you watch the particle in motion (which will go in seemingly random directions on a local scale), but there is a definite large scale trend as if the particle is actually trying to get somewhere, despite constantly forgetting where it is and where it came from.

(This is no longer broken, as can be seen at the top of the post. It looked interesting when it was broken anyway, though, so it stays up).

Monday, April 10, 2006

The Vision Beyond the Darkness

What do you see when you fall backwards out of the back of your head?

John enters a world where no one seems to recognize him.

A dark haze seems to block his view. Bright flashes break through the darkness, but only to blind him. Debris blows everywhere, getting in his eyes, and he searches desperately for his handkerchief. Old friends fly by, waving as they pass.

Then, the darkness.

A great deep void presses in around him as he struggles to maintain his identity.
Friends become shades and phantoms, grasping at the edges of his soul, pulling loose threads until the fabric starts to fray.

Shaking violently to keep the specters from tearing him apart, he runs in random directions as fast as he can. The shadows cling to his legs and arms like smoke, and wisps of dust trail away from his extremities through the dead vacuum of the place.

Eventually he spies a shining thread off in the distance. He runs faster.

When he reaches it, he is amazed to find that it really was just a thread, and that it had seemed no larger from hundreds of meters in the distance than it did now. It was finer than a hair, and it glowed so brightly that John had to take his eyes from it after a couple of seconds. Keeping it in his peripheral vision, he reached his finger slowly towards the glowing strand.

He touched it ever so gently.

It pulled in response to his touch. "Come with me, follow me, come here, I need you," it seemed to say. It called to him, begged him, and he finally relented. He grabbed it quickly and firmly, and he pulled.

As the thread came loose from whatever had been holding it there in space, it began to form a small tear. As John pulled more and more of it out, it started weaving itself into the frayed patches of his body where the shadow had threatened to devour him. It made him whole.

And yet, as soon as he was done, he was gone.