EPICS

Engineering Practices Introductory Course Sequence. Every student from the Colorado School of Mines has taken the two-course series, and talks about it with a slight distaste in his mouth. For some students it’s a much-needed first pass at writing reports, dressing up, speaking in front of others. (This is something I’ve actually come to appreciate about the system – its emphasis on presenting to peers.)

I remember when I took it, we were supposed to design a small device within certain (relatively arbitrary) constraints to collect a soil sample. The premise was unrelatable – that we might one day be responsible for a subsystem deployed to collect a soil sample on a distant planet, without thought about its return.

It’s become rather popular lately in certain communities to program and attach digital cameras to weather balloons and take pictures from as high up as 30km (about 20 miles) or so. The results speak for themselves:

What I found regrettable about my EPICS experience was that it was too far removed to really care about the project. It had its fun moments, and I was glad that for EPICS 2 I got to work on a project I really believed in with some friends (it was a considerable improvement). But this is an example of a project I contemplate and eye over longingly, even outside the context of a course. Similar projects can cost on the order of a couple hundred dollars and are relatively feasible, even for freshman engineers. To have something you built venture farther from the earth than any one of us likely ever will, bring back pictures and live to tell the tale would be extremely rewarding.

Had there been projects like this when I was in school, I know that my experience would have been that much more enriched.

Tagged with:
 

OpenGLot Release

A short while ago I posted a new release of OpenGLot, which featured parametric curves, scalar fields, contour lines and flow fields all implemented in GLSL shaders.

And they support time dependence.

It can plot virtually any function in x, y and t, and on my MacBook with its NVIDIA GeForce 9400M it has been getting 10k+ fps. I’m still a little surprised by this number, but it seems to be running at that speed.

Flow (vector) fields appear as advected dye. They're currently streamlines, but in the near future I hope to support streaklines and particle flow as well.

Flow (vector) fields appear as advected dye. They're currently streamlines, but in the near future I hope to support streaklines and particle flow as well.

Scalar fields appear as a mapping of height onto color.  If this function were to be plotted in 3D, it would like a sheet rippling, but sometimes it's more useful to see it in 2D.

Scalar fields appear as a mapping of height onto color. If this function were to be plotted in 3D, it would like a sheet rippling, but sometimes it's more useful to see it in 2D.

On of the great thing about implementing this on the graphics card is that it doesn’t require much CPU time on the machine running it. Even at 10k frames per second, my MacBook never uses more than 30% of a single core’s time. A place where this particularly shines is on tiled displays – a bunch of HDTVs tiled together to run as if it were one large screen. In such setups, a computer will control 2-4 screens, and each computer’s graphics card has enough power to run the animation for its portion of the screen. There are still some bugs to be worked out, but I ran a proof-of-concept on one of the tiled displays at KAUST.

Running a demo of OpenGLot on a KAUST tiled display

Running a demo of OpenGLot on a KAUST tiled display

Lately I’ve been working on getting the 3D analogs of the various 2D primitives working, again all with time dependence (it’s the support for animation that really makes this shine in my mind). So far it’s surfaces, parametric curves and surfaces and flow fields, but the flow fields have some work yet. It turns out that while modern hardware is definitely capable of handling 3D flow fields, it doesn’t actually make much sense when you see the result – it’s just too busy. To be able to easily visualize flow in 3D is very much an open problem.

3D streamlines end up just becoming confusing more than they are helpful.

3D streamlines end up just becoming confusing more than they are helpful.

In order to get some interesting shapes working, I had to add support for cylindrical and spherical coordinates which is actually providing an interesting challenge – how best to generate the shaders. The shader source code (that runs on the graphics card) is generated and compiled when you run OpenGLot, and I’ve not found an altogether easy and intuitive interface for adding simple coordinate transformations to it. Still, it works, but the programatic interface will likely change.

This is a torus of sorts, which I got as an example from Grapher.app

This is a torus of sorts, which I got as an example from Grapher.app


This is the same torus, just colored by using its surface normals as RGB values

This is the same torus, just colored by using its surface normals as RGB values

In order to determine surface normals (which are something usually determined when one defines the geometry of an object), the vertex shader approximates various derivatives numerically. So far, the shading results have been pretty decent.

A trigonometric function, colored by mapping the surface normals to colors

A trigonometric function, colored by mapping the surface normals to colors


The superimposition of two trigonometric functions, lit based on their surface normals and a texture to give visual clues about distortion

The superimposition of two trigonometric functions, lit based on their surface normals and a texture to give visual clues about distortion

I’m still working on making video of this in action available, but so far a number of the tools I would usually use have come up short. I’ve been trying to integrate a video encoder into a utility library for OpenGLot so it can record video straight out of the box, but the framerate is still too low.

Tagged with:
 

VTK and Volume Visualization

This week for Scientific Visualization, we’re talking about volume rendering and using VTK to explore some data. I got some datasets from The Volume Library and after a little tinkering, got VTK to render them. (And now a quick aside on how to do this as I didn’t find much information on the subject).

I used a tool (pvm2raw) available as part of the V^3 library to convert the pvm files to raw, but VTK requires its own simple header. I actually found that this particular header didn’t work (perhaps a VTK versioning problem?) and so taking guidance from this, checked the header of one of the VTK-included volumes:

bash $> head VTKData/ironProt.vk

This header more or less included a little information on the grid size, spacing and representation of the data:

# vtk DataFile Version 1.0
<Name of File>

BINARY

DATASET STRUCTURED_POINTS

DIMENSIONS <x> <y> <z>
ASPECT_RATIO 1 <y/x> <z/x>
ORIGIN 0 0 0

POINT_DATA <x * y * z>
SCALARS scalars <unsigned_char|unsigned_short>
LOOKUP_TABLE default
<remember to include a newline here>

Concatenating the header with the raw:

bash $> cat header CT-Head.raw > CT-Head.vtk

At that point, I was in business and was able to move on to generating pretty pictures. Granted, these datasets are pretty sparse, but still VTK did a pretty reasonable job. Update: a comment asked for a little bit more detail on this assignment, and so I’m including my report for the project.

I was amazed today that we can see inside of things… without taking them apart. What an age to live in. Especially the virtual autopsy table I read about recently. In 20 years, we’ll have Firefly-style real-time holographic body scans (ignore music, skip to 0:45):

Tagged with:
 

A professor of mine recently criticized some graphs I submitted on a paper and handed me a book by Edward Tufte called The Visual Display of Quantitative Information. It shreds on graphs made in order to show four numbers, or obvious flaws in design giving misleading impressions of numbers.

He talks about the misconception that graphics lie. Of course some do, but his attitude encapsulates well what I think is great about visualization – good representations convey understanding. Graphics can be the most effective way to get a handle on data, or a trend, and they should reveal what underlies the numbers. But in a world of Excel and every insignificant and meaningless piece interrelationship being plotted in an impressive-looking format, it’s easy to forget this.

A quote I heard recently in my Scientific Visualization course (thanks, Thomas!) puts it well:

Visualize to inform, not to impress. If you really inform, you will impress. – Fred Brooks. SIGGRAPH 2003

Although a child can understand a time series, it wasn’t until a couple hundred years ago that they were actually used, as Tufte points out, but its power to convey is obvious. Similarly, just from glancing at a map like this one from the census bureau, one can almost instantly understand the distribution of income across the United States – literally tens of thousands of pieces of data.

A US Census Bureau graphic depicting the income of the 3000+ counties of the United States.

A US Census Bureau graphic depicting the income of the 3000+ counties of the United States.

In this vein of conveying understanding, I remember several years ago now watching a TED Talk that immediately captivated me with visualization. Hans Rosling talks about how often when we see the rows about rows and tables upon tables of the massive amounts of census data, not only do our eyes glaze over but it becomes very difficult to keep it all in one’s head at any one time. Visualizing the data is thus a key tool for gaining the insight we seek.

The book is full of tremendous insight about how ink should be used as efficiently as possible (within reason – Tufte is quick to emphasize this point) and that the human eye has a great capacity for handling dense data sets if presented efficiently. It is an entirely necessary resource for anyone who intends to pursue any science, nay, anyone intends to pursue any discipline dealing with numbers.

He has several other books, all of which I intend to read as I was virtually unable to put down the book; I was constantly floored by the myriad examples of strong and weak graphics alike. He also published a book by his mother that I happened to encounter recently via Cool Tools.

I’ll close with a brief excerpt from his book with which I was taken:

Words and pictures belong together. Viewers need the help that words can provide. Words on graphics are data-ink, making effective use of the space freed up by erasing redundant and non-data-ink. It is nearly always helpful to write little messages on the plotting field to explain the data, to label outliers and interesting data points, to write equations and sometimes table son the graphic itself, and to integrate the caption and legend into the design so that the eye is not required to dart back and fort between textual material and the graphic.

Tagged with:
 

KAUST – A Month’s Reflection

One month ago, I stepped onto Saudi Arabian soil for what I anticipated to be a magical experience coming to KAUST. Well, yes and no.

For our first three weeks here, 350+ students were stowed in a hotel. Granted, the Intercontinental is a nice hotel but they told us that they’d be bringing us here early so that we might get settled – buy the things like blenders and speakers that we needed, and work the kinks out of our newly minted apartments. We did take care of things like applying for iqamas (our residency permits), but outside of that, we were by and large sitting around.

One event they put on for us that I know I enjoyed was they managed to take 100 students into the desert to go four-wheeling. That was actually pretty awesome.

Five days of orientation beginning the last days of August, largely filled with cultural sensitivity issues and massively behind schedule. There seems to be some cultural disagreement about punctuality, but with no exaggeration, one of these mornings the opening presentations scheduled for 8 am did not get under way until 10. And when you tack on an hour-and-a-half commute from the hotel to the campus, you get a bunch of tired students who would much rather be elsewhere. As a final `can’t believe it’s so’ moment, it was all scheduled during Ramadan – so students who were fasting and who would otherwise be sleeping had to be awake and active.

Getting to campus was another ordeal. We were all very excited to move in, and then largely disappointed to find everything from rodents to black mold, leaky pipes to bottled `leavings’ of construction workers. A few days later, ceilings began to collapse in some units.

At this point, school had started, of course. Like many others, for the first few days of class I was sleeping on a friend’s couch. When I and about a dozen other students were scheduled to move in (getting up at 7:30 to come to campus in time), we were told that it would be about an hour until we could be given keys and move in, but ended up waiting 7 hours to be told that there was no way we would be able to move in, and had to go back to Jeddah.

Books for most classes have still not arrived. We haven’t any clusters online for high-performance computing. In some disciplines, labs won’t be online until 2010. The second fastest supercomputer in academia sits dormant in the basement of one of our buildings because the data center is not clean.

I would like to make it clear that I understand that anything this big getting off the ground so quickly is bound to have problems. There were going to be wrinkles (if not kinks) to work out, and I can appreciate that. I hope to not descend into a rant as frankly I’m all ranted out.

There have been perks – the food on campus is free to students for an indeterminate amount of time; our books will be purchased for us this semester; there have been goodies abundant to be had (from t-shirts to thumb-drives). As much as I love a thumb drive, I would have preferred something else – a home.

That said, the students have mobilized. We’ve signed petitions, we’ve organized, and we’ve gotten interim student representation in place. We wanted to convey the idea that we don’t want to perpetually complain but would like to help out if that means us coming into a better situation. And despite some of our expectations, within two days, the administration had contacted us to schedule meetings and put us in contact with the contractors in charge of this and that (IT, housing, etc.). It’s actually been very inspiring to see the actions we take have tangible results. Had to talked to me two days ago, you would have found me a very tired and disenchanted man, but today I’m very hopeful.

In terms of academics, I am really happy with the faculty. I’ve secured a TA position, and I spend a couple hours a day with this prof in a constant stream of geeking out. And I spoke yesterday to a prof for two hours about the research he’s doing and how I might get involved on that front. Depending on how this goes, I’d be willing to consider staying on for a PhD!

I’ve made instant friends with a couple of students here, and three of us have gotten a license to host a local TED event: TEDxKAUST. We’ll replay some of our favorite talks, and those we think would be most inspiring to students here, and we hope to get a couple of professors to present as well. In our budget, we’ve been able to allocate funds to booths and demos and if all goes well (read: gets approved), we’ll have a Ruben’s Tube.

Tagged with:
 

I recently finished up school, and part of that was finishing up my ray tracing project. At the last minute, I implemented Gouraud shading which is a technique to try to smooth out a triangulated surface. What it really does is just linearly interpolate the normal vectors, where the normal of a vertex is calculated as a weighted average of the normals of the triangles using that vertex.

Long story short:

A render of the Stanford bunny with my raytracer without Gouraud shading.

A render of the Stanford bunny with my raytracer without Gouraud shading.

A render of the Stanford bunny with smooth Gouraud shading.

A render of the Stanford bunny with smooth Gouraud shading.

Also, thanks to an improvement in my parallelization of the problem and a speedup in octtree traversal, I was able to render the Stanford dragon model (~1 million triangles):

The Stanford dragon model.

The Stanford dragon model.

Tagged with:
 

Tomorrow!

Tomorrow!

Tomorrow!

Tagged with:
 

It occurred to me today that I could render a scene several times with slight perturbations and then mesh them together into a movie. It took about 15 minutes to render on a cluster at Mines, and then about a minute to stitch together with Mencoder. At 18 frames per second, here is the result. Enjoy!

Tagged with:
 

This afternoon I was able to successfully parallelize the ray tracer I wrote for Graphics II to run on the Alamode cluster at Mines. Using 17 machines, I was able to render a 4,096 x 4,096 pixel image with 25 passes and up to 5 reflections. It took only 1 minute and 20 seconds.

Reflective spheres rendered at high resolution on a small cluster.

Reflective spheres rendered at high resolution on a small cluster.


Another image rendered on the same cluster

Another image rendered on the same cluster

For the benefit of those who are not computer scientists, this is what the input file looks like:

8192 8192
0 0 20
-1 -1 1
2 0 0
0 2 0
3 10 10 0.8
0.2
9
# These next few lines will define a triangle
T
# With one of the points at (1, 1, 1)
1 1 1
# and the next point here:
0.12321 0.12321 -1
# and the last point here:
-1 1 1
# and with this color setting
1 1 1 1 1 1 0 1 0.7
T
-1 1 1
-0.12321 0.12321 -1
0.12321 0.12321 -1
1 1 1 1 1 1 0 1 0
T
1 -1 1
0.12321 -0.12321 -1
-1 -1 1
1 1 1 1 1 1 0 1 0
T
-1 -1 1
-0.12321 -0.12321 -1
0.12321 -0.12321 -1
1 1 1 1 1 1 0 1 0
T
1 1 1
0.12321 0.12321 -1
1 -1 1
1 0 0 1 0 0 0 1 0
T
1 -1 1
0.12321 -0.12321 -1
0.12321 0.12321 -1
1 0 0 1 0 0 0 1 0
T
-1 1 1
-0.12321 0.12321 -1
-1 -1 1
1 1 0 1 1 0 0 1 0
T
-1 -1 1
-0.12321 -0.12321 -1
-0.12321 0.12321 -1
1 1 0 1 1 0 0 1 0
S
0 0 0 0.5
1 0 1 1 0 1 0 1 0.3

Tagged with:
 

Grading

As it’s my first semester T.A.’ing, it’s also my first semester grading. I picked up the first homework from Prof. Qiu this morning, and I just got done grading it. There are about 40-45 kids and it took about 3 hours. So, 4-5 minutes per homework – I can live with that.

Tonight was also the first time that a student in the class scheduled an appointment to get help with her homework. I hadn’t looked at the upcoming homework as they just finished the first assignment, but I was very pleased when I was able to jump right in and know exactly the problem. It’s a great feeling to know the entirety of a class without needing a refresher, and being able to take any section and just go.

In short, so far so good.

Tagged with: