Saturday 23 April 2011

Simplex Noise

Apparently, Ken Perlin fixed a bunch of things that were a bit off about Perlin noise in 2001, while also reducing how expensive the function is to compute. The result is named simplex noise.

Here is a neat paper on the subject.

Here is a guy using it in Java, to do procedural content for a simple game. Lots of other cool little projects on this site too, especially web synths.

Tuesday 12 April 2011

Final - Luke changes his mind

So I was looking at my terrain/island generator, thinking about what Elle and Richard said about it being a bit too literal and a bit too "floaty islands in Avatar", and reached a point where I didn't think I could take it further. It is too rigid, although I am fond of it and will use the concepts I learned for other applications.

Further back in my blog history, before I handed in project 1, I was exploring another sort of random walk with strings of polygons in 3D space. I revisited this and managed to find some remarkably organic motion when animating a single polygon string, smoothly changing the angles between each polygon. After a chat with Elle, she suggested I see where I can take this before hand in and if I can improve its aesthetics.

This still fits into my core idea of using random walks to build complexity, ultimately ending up with something we read as organic rather than inorganic and computerised. The islands code generated forms that read like organic terrain, but they had no element of motion. The polygon stream code is a little less organic in form, in some cases, but it's motion is variable and unpredictable in a very eye catching and natural way.

The alpha is tuned to highlight the interactions between polygons, rather than the polygons themselves, in order to further remove the resulting image from its beginnings.

To talk directly about the brief, the randomness in this project is in the net construction. It chooses a side of the polygon, and an angle to fold by, then attaches another polygon to that side with that angle of rotation, and repeats. When these fold angles are incremented over time in the animation, the motion that emerges is a function of the initially random selected angles and directions.

The control I exhibit is in the number of sides of each polygon, the range of angles available to select, the colour ranges, speed of motion, in other words general aesthetic direction. I have constrained the resulting strings (and actually placed 4 of them in the scene) in every other way to achieve interesting motion, and to show as much as possible to the viewer of what is unfolding. Crucially, the motion is smooth because the folding angles are not chosen randomly at each step, they are instead chosen randomly once and then a random seed is used to recreate them identically (but incremented slightly, to animate) each frame. Were the motion not smooth, the organic properties of the whole piece would be destroyed, so controlling this aspect of randomness was incredibly important to my project.




Monday 4 April 2011

Islands

I am really interested in generative landscapes (and creatures, but creatures are much harder) so I have been messing about with using a controlled random walk to build me islands. I plan to compose these nicely as a scene for Project 2, plus some other factor that is more surprising and unexpected (yet to be decided).

It makes maps! The circle is to test the radius which I think I am restraining it too. It is fairly elastic though, so this isn't really a big help.

Letting it off the leash. Also with a small step size. Looks smokey!

Shows the distribution well. Random walk has an advantage over random points, for landmasses, because everything is by default connected. Using some alpha to show how often it retraces it's steps shows up well how much foot traffic ends up in the centre.

3D! Heightmaps! I had to store all the visited points in a dictionary to do it, so I could index them by their location, and then store the 'frequency of visits' next to each point so I could measure how 'dark' each square is. The random walk might be 5000 steps, but the dictionary only has a few hundred entries, since it goes over old terrain often. I can use this 'darkness' information to determine the height of each location.


Colours! Mapping the frequency to saturation is nice too.


Adding in some directional lighting and letting the walk breathe a bit, I get some nice harbour cities.


Changing a few things and scaling up, we get some very nice landscape happening. Perhaps a few too many holes to be realistic, but still interesting.


Hue! This is about the point where I add all kinds of fun mouse and keyboard controls! There are tons in this one, perhaps I should post the code just so people can play with it.



Reducing the size of the elements (without reducing the space between them) creates some nice effects. 




Exercises in Random Shaping

The exercises I have been playing with are mostly to do with random walk, and filtering the randomness or controlling the density.


This program picks one of 8 possible directions to walk in, each frame, but the distribution is made 'more gaussian' (not sure of terminology) so that the density is clustered around one particular direction. This averages out the path to be in one direction overall, even though it makes many deviations.

This is another random walk, moving in one of 4 directions and then drawing a square. The walk is influenced though, so I think this defines it as a filtered randomness. A central point is defined, and the distance to that point is checked at each step. Through mathematical wizardry, I convert this information into an influence value, so the decision it makes to walk in one direction or another is slightly influenced by its proximity to this point. This effectively reins it in, and can create pretty cool landscapes (more on this later, it is the basis for my Project 2).


This one uses the technique of averaging the neighbouring points in a point array to draw successively less distorted circles. I managed to find out how to control how much it averages the points when passing through the filter (rather than just making the current point equal to the average of it's neighbours).

This is just visualising density, in the y axis. This uses the method of summing random numbers. I hooked up some controls so its possible to play around with which axes are being density controlled, how aggressively gaussian the distribution is, and how big the particles are.