Saturday, December 31, 2005

Kids Nowadays...

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

Joel Spolsky recently blogged about the perils of Java schools. The introduction goes like this:

...When I was a kid, I learned to program on punched cards. If you made a mistake, you didn't have any of these modern features like a backspace key to correct it. You threw away the card and started over.

That instantly reminded me of my favorite Dilbert - one I have handy now because I used it in one of the first few slides in my JavaPolis presentation. I think it portrays a pretty common attitude in the programming world - "it was hard and we liked it that way!"

Thursday, December 29, 2005

Real 3D Graphics

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

I've been on vacation this week - and I took last week off too. One of the things I did was to take my kids to a movie called
Polar Express.
We saw it last year - but this year it has been re-released in IMAX theaters in full 3D.

Lots of games claim to be in 3D - but what you're really seeing is a projection of 3D onto a 2D surface like your monitor. Cues like perspective and occlusion lets your brain figure out (through educated guessing) the spatial relationships. However, we can do better than that. If you look around, you can actually perceive depth around you. If you look with just one eye, the depth perception disappears (and you're back to the two dimensional view again where you guess things based on size, appearance, occlusion, etc.).

The trick to presenting a real 3D view, is to project two different images to the viewer - one for the left eye, and one for the right eye. Objects far away appear in the same place in the two pictures, but objects closer will appear in different places. A finger held right in front of your face obviously looks different from the left eye than from the right eye, even though the distant background stays roughly the same.

A number of things have been tried. One way is with color glasses - usually one red lens, and one blue lens (anaglyph stereo). The whole trick here is that the 3D image can be presented as a mixture of red and blue. Since these colors are complementary, the overlaid red and blue images blended together will be split apart again by the red and blue eyeglass lenses. (The red lens will see only the blue colored image, and vice versa). The problem with this approach is that you can only do "grayscale" images - the red and blue lenses obviously warp any attempts to do full color images. Here's an example of such an image. I created this with a raytracer I wrote ten years ago, back when I was really into graphics and real 3D in particular. It's a simple model of some screenshots from the product I was working on at the time (Sun's Workshop debugger) along with a 3D model of the signature green "Run" debugging arrow:

Another approach is to use 3D shutter glasses. Here you're using a special headset which very rapidly opens and closes the left and right eye lenses in succession. This is synchronized with a computer, which shows the left image followed by the right image. This allows full color 3D, since you're using time rather than color to do the image separation. I've never tried this technology so I don't know how well it works but I believe it's been used in games.

Another approach is the original, historical approach to viewing 3D images - "free" viewing. Here you simply show the two images, right next to each other. With a little training, it's easy to view this image and visually fuse the two together in your head (by changing your eye focus to be behind the screen) and suddenly see a 3D picture in the middle. Try it.

In the Polar Express IMAX version, however, they were using another technique which relies upon light polarization. The trick here is to use two movie projectors, projecting through perpendicular polarizing filters. Viewers then also view through glasses with perpendicular polarization lenses. The net result is that you get to view beautiful (full color, no time lapse) stereo images. I assume it was fairly easy for the creators of the Polar Express to create a 3D version - they already had the full 3D models; they "simply" had to render all the scenes over again - twice, one from each eye location. Hope they had good rendering hardware.

I had heard a lot about the polarization technique - but this was the first time I actually saw it. It looked fantastic - and of course the "screen resolution" in IMAX films is fabulous. But there is one remaining problem. I discovered that I tend to lean my head to one side or the other during a long (two hour) movie - and as soon as you do, you start seeing visual artifacts. Your head had better be completely aligned with the polarization axes! (And the images also were rendered assuming a horizontal pair of eyes).

All in all it was definitely the movie experience of the year - yes, there have been movies I enjoyed more, but the combination of cool technology and seeing a movie that the kids loved so much and really put them in the mood for Santa was ..... priceless.

(P.S. That's a good thing since the tickets were nearly twice what I'm used to - $15 for adults and $10 for kids!)

Tuesday, December 13, 2005

Spoona Sutra - another Java conference trip report

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

I'm spending this week in Europe. Yesterday I was in Antwerp for
JavaPolis - an annual Java conference in Belgium hosted by the local
(and very active) user group. I did a talk on Creator. I basically
lost my voice the previous night through heated and interesting
discussion... so talking for two hours the following afternoon
was pretty tough. And not good for voice recovery - so I'm not
sure I can do a remote podcast with
the guys
this week. Too bad, since I had dinner with
Romain Guy
last night and can finally pronounce his name correctly!

The conference was held in a really interesting venue: a modern
movie theater (which perhaps explains the name - the movie
theater is named Metropolis).
That meant the seating was unbelievably comfortable -
soft seats, tall backs (tall enough that you can rest your head),
and best of all - a giant projection screen - the movie
screen itself. It's pretty amazing to see your tool running on
a giant movie screen! No need to worry about small fonts... The
picture on the right shows
Ludo in action.

To combat the jetlag I went and grabbed some coffee. I added
sugar, but couldn't find spoons anywhere. So I had to stir with my
finger. Then I noticed

where all the spoons had gone - and what they're doing!

(Yes, that's the official artwork used by the
conference - on slide templates, on publicity posters, on T-shirts, etc!)

Unfortunately I could only stay in Antwerp one day. I'm spending the
rest of the week in Prague, where we're having many important
planning meetings. I'm sure I will miss many interesting presentations.
During Ludo's presentation yesterday morning he demoed
a new AJAX-ified version of PetStore. It looked fabulous. He also
mentioned the high performant "Grizzly" engine in Glassfish, which
uses java.nio to get extremely high performance. I'm going to find
out more!

Thursday, December 1, 2005

Performance profiler - now for the Mac!

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

Milestone 11
of the NetBeans Performance Profiler
was released today. It's mostly a bug fix release, but it sports one big new feature: Support for Apple OSX!
This is a big deal. The NetBeans Profiler is based on
JFluid, a new
approach to performance profiling. Rather than using the standard JVM performance interface, it used
a special modification of the VM to do its profiling more accurately. Because of this, you had to download
special VMs to run your application - and of course, those modified VMs did not include OSX (where the VM
is provided by Apple rather than Sun).

The JFluid hotspot modifications have been integrated into the JDK. As of JDK 5 update 4 (or thereabouts)
you can use a standard JDK with the profiler and everything works beautifully. And I guess Apple's recent
update to JDK 5 must have synced up to the codebase which includes the JFluid modifications, since the profiler now works.

The "What's New" document describes this feature as experimental - so of course I had to try it! It seemed to work well on my test case. I created a sample project (the Anagram sample that ships with NetBeans), then invoked the Profiler. After calibrating the timers I needed to restart profiling. From there everything went smoothly; I hit the GUI button a bunch of times, then clicked on the Take Snapshot button in the profiling panel. Voila! The result screen pops up letting me drill into both the hotspots and the overall cumulative time view.

Click on the screenshot for full size. And check out the Profiler Screenshots off the profiler main page; as you can see there are various telemetry views and other goodies there.

Very promising. If you're a Mac Java user, be sure to try it out and provide feedback and bug reports to the profiler team such that this feature is stabilized as quickly as possible!