Sunday, August 22, 2010

Digital Fluid (2000)

After spending time teaching my computer how to solve Rubik's cubes, I started thinking about writing something that would cater to my lifelong fascination with gooey matter and infinitely-derivable functions.  The first generation of GPUs had just come out (hardware transformation and lighting, oh my!) and it was time to put my 450$'s worth of graphics hardware to work.  Other than playing games, of course.  Ahem.

By tinkering over the course of a few nights, I wound up writing this little fluid simulation.  As it turns out, most of the computation performed wound up on the CPU, so it was taxing little more than the transfer rate of my AGP 4x bus.  However, it does shun vendor-specific extensions in favor of multipass rendering to layer the specular highlights onto the texture map.

The fluid patch is implemented using a height field; normals and other epiphenoma are derived from the vertex positions.  Texture coordinates are calculated using Snell's law, by putting the texture on a virtual plane behind the fluid patch.

The simulation itself isn't really that interesting from a mathematical standpoint - I was just experimenting, so all the code is ad hoc.  The positions are animated using different models.  For liquids, linear combinations of many simple closed-form sinusoidal decay solutions are used.  For the gooey-looking ones, a simple spring/damper model is used.

(Browsing this code ten years later, I can say that this being my second C++ program, the code stank a bit less than the cube solver. :P )

Be sure to pick HD if available over your connection... the low-resolution version looks like a tie-dye cow.



Lessons learned (or points confirmed):
  • Programmer art sometimes far outlives its intended longevity...  As of this writing, 10 years later, I still haven't replaced that Paint-produced bitmap.
  • Stuff doesn't necessarily need to be complicated to look decent.  In fact, the simpler it is, the easier it usually is to tweak the way you want it.  (Recall that this was in year 2000; register combiner cards were still quite mainstream.)

Rubik's Cube Screen Saver (2000)

Around the same time I was given my first copy of Visual Studio, I bought the OpenGL Superbible.  Feeding these two items through the transfer function of my deranged brain, I wound up brewing the following program as a first foray into both the worlds of C++ and modern API-based graphics programming (as opposed to writing to the metal).

The program solves rubik's cubes, bouncing them around the screen:





The algorithm is the same I first learned to use when solving the cube by hand - the original Singmaster method - and it's far from optimal.  I recorded sequences of moves interactively using a built-in "move editor", then wrote code that analysed the state of the cube and chose the algorithm to play back.  The debug mode output looks something like this:


Lessons learned:
  • As a first contact with the world of hardware abstraction layers, in terms of API design, OpenGL and GLUT are infinitely friendlier than DirectX 5.0.
  • Do read your employment contracts closely.  I got into somewhat serious trouble for posting a copy of this on NeHe, believing the IP belonged to me since I had created it on my own time.  Not so.
  • A 2,300 line switch statement does not constitute "artificial intelligence".  (I still laugh this one today.  In my defense, it's not because I didn't know better in terms of design; it's more that I was still learning so much about the language at the moment that there were more pressing points than learning about the constructs which would have enabled me to organise my code in a cleaner fashion.)

Wednesday, July 28, 2010

Greece 2010 - July 23rd - Home, Sweet Home!

After an outstanding breakfast in the Plaka, we hopped on the subway to the airport.  A relatively short but wobbly flight to Paris later, we hurried across terminals at Charles-de-Gaulle to catch our connecting flight, arriving just as boarding began.

Our flight back across the ocean, the movies we watched were punctuated by the screams and kicks of the young'un beside me.  Though there was a relatively long line at customs in Montreal (about an hour), the guard pretty much waved us on with almost no questions, in stark contrast to the occasion of our return from the Dominican Republic.

Oh, the sweet feeling of crashing into your own bed after weeks away.

A very special, smooshy thanks to Laurence for many of the great pictures and fact-checking!  Any errors are mine, and any things that make you go "wow" can be attributed to her.


Greece 2010 - July 22nd - Back to Athens

After Mount Olympus, our trip wound down as we took a bus out from Litohoro to Katerini, and from there took a train back to Athens.

I had a stupendous shower in our Athens Backpackers suite, and apparently exhausted the country's hot water supply.  There was none left for Laurence afterwards.  :-(

We had one last supper in view of the Acropolis, on Makri street.

Greece 2010 - July 21st - What Goes Up, Must Come Down!

We had a surprisingly good night's sleep at the refuge - over ten and a half hours.

Accomodations in the refuge.

Main hall in Refuge SEO.

Can you spot the face of Zeus here?

We walked out to one of the nearby peaks, Toumba, to scope out the other side of the mountain.

Northwestern view.

View of the peaks from the Western side.

We set out clambering down shortly thereafter.  We decided to take a different path down, about 13.5km.  This took us about 4.5 hours.

Plateau of the Muses seen from the North.

The three human-made rock formations we had seen from afar the previous day.

Shepherd dogs admiring the view.

Mules!  These must have set out really early, because it's a long way down from here and it's only mid-morning.

Crooked trees!  (Actually, the trees grow straight up - the camera was tilted with the slope to take the picture.)

Back in Litohoro, all filthied up and war-torn from the two-day hike, we took baths.  And then we promptly returned to the famous Gastrodromio for more outstanding food.  Older men played a card game tournament of sorts nearby.  (Our waiter identified the game as "Kseri".)

Greece 2010 - July 20th - Climbing Mount Olympus

By this point all the easy stuff was done, and we had kept the best, but hardest, challenge for last: a hike up Mount Olympus.

Getting dropped off by our "personal" taxi driver Ioannis in Prionia, at the base of the valley, we set out to climb up to Refuge A.

Our target.  This was one of the very brief and rare moments where we could see the peak from the base or vice versa.

A short while into the hike, we were already nearing the cloud cover. 

Clouds just barely a few meters above our position.

It's going to be above 30 degrees Celcius that at the base that day, past the middle of July, and here we are trekking across snow.  And we're not even close to being half-way up yet!

Lots and lots of snow, but it's "ski de printemps".

A look back down, to the path we just recently walked.

Getting close to the clouds.

Refuge A!  Time for some veal spaghetti and, as always, Greek salad.

Mules bringing up supplies to the refuge.

Having started at about 9:30am at the bottom, we got to refuge A just past noon.  We rested, ate, and gathered information about the rest of our planned route.  We still had a bit more than half to go.

Leaving around 2pm, we kept walking through the clouds.

An ethereal setting, with the sun getting close and the clouds letting up.

We are now occasionally above the clouds, on the E4 international hiking path for the moment.

Rest.

When we are not above the clouds, we can barely see feet ahead.

Across the mountain to another stone arm flanking the valley.


You can just barely make out three human-made stone piles at the top left there, at the edge of the Plateau of the Muses.

You don't want to fall down here.

We are so high up by now that the views are similar to those from a landing plane.

Idem.


Brief rest before going on.

Barren lands from now on.

One of the peaks with the sun behind it.

This picture cannot impart the sheer steepness of the slope below.  You can see Refuge A through the clouds.

One of our first peeks at a summit refuge.  Still quite a ways to go!

The path leading across to the Plateau of the Muses, where the refuges are.

Reasonably sheer drop.

Brief moment in a dark cloud, where you pretty much can't see anything.

The valley below, with Refuge A.


Where we came from.  Clouds are fewer and further apart here.

Our first glimpse of Refuge SEO (on the left, where we slept) and smaller Refuge C, on the right.  The green area beyond is the Plateau of the Muses.

Refuge SEO about to be swallowed by a cloud.

We reached Refuge SEO around 5:30pm.  All in all it took us about 6 hours for the ~9km hike from our starting point, which we gather is about the norm.  At the Plateau des Muses, it was 12 degrees Celcius inside the refuge, before they turned on the heat, so that's quite a temperature gradient along the mountain - a difference of about 20 degrees Celcius with the base.

Setting sun.

Peak by moonlight.

Before hitting the sack, we had some goat soup with Greek salad, which was exactly what the doctor had ordered.  In the mountain, I was expecting astronaut food; the actual quality of the food in the refuges left me astounded and surprised.  It's not merely good, it's great, and it's not even more expensive than elsewhere in the country.

I was fast-tracked through about ten years of Scout training in order to use the facilities for my ablutions, however.  And you really want to make sure that you take care of business before going to bed, because the prospect of hitting up a floodlit, draughty, unheated, Turk-style can in the middle of the night because you had one too many sips of tea is enough to make you hold it in until morning.  (The reason for this state of affairs is that the washroom can be independently accessed from the outside with boots on, and as such, is not part of the enclave of warmth and slipper-bound comfort.)

Greece 2010 - July 19th - Creeping Up to Mount Olympus

The 19th was pretty uneventful - we simply travelled from Kalambaka to the town at the base of Mount Olympus, Litohoro.  We had a great, hearty meal at Gastrodromio to prepare for the next day.

In my mind, "Gastrodromio" conjures a picture of the Thunderdome from Mad Max III crossed with some kind of gigantic, disorganized kitchen.  However, the food is exquisite, and I must thus surmise that the first part of the name refers to "gastronomy."  I sure hope it's planned that way, because in Québec, a restaurant whose name begins with "gastro" probably wouldn't fare long.