Archive for the ‘Code Snippets’ Category

A Million Objects

Sunday, December 9th, 2007

From a Zen Kōan:

Gyosan asked Isan, “If a million objects come to you, what should you do?” Isan answered, “A green object is not yellow. A long object is not short. Each object manages its own fate. Why should I interfere with them?” Gyosan bowed in homage.

It’s good advice for programming multi-core, too.

What is Ambient Occlusion?

Tuesday, November 27th, 2007

Ambient occlusion is a lighting technique that is commonly used to create soft shadows on objects. Ambient occlusion isn’t used to create the type of shadows that are cast from objects with a light shining directly on them. Instead, ambient occlusion generates the type of deep shadows that appear in the corners or creases of things, where it is hard for the light to reach.

Technically speaking, ambient occlusion is a global illumination technique. However, in common usage of the term it is often referred to as a cheap alternative to global illumination. To clear up any confusion, what most renderers refer to as “global illumination” is actually an amalgamation of several techniques such as radiosity, metropolis light transport, image-based lighting or photon mapping. The actual techniques used differ slightly from renderer to renderer. Some renderers include an ambient occlusion term as part of their global illumination calculation; others do not.

Like most global illumination techniques, ambient occlusion is dependent on the other geometry in the scene. Ambient occlusion on its own generates less realistic lighting than “full” global illumination. However, ambient occlusion is much faster and less complex to calculate than other methods which is why it is still popular among game developers and in production animation.


(Left) Without Ambient Occlusion. (Right) With Ambient Occlusion
Click for larger image.

(more…)

Finger Tracking with Wii Remote

Tuesday, November 13th, 2007

Johnny Lee shares a simple but clever approach for implementing finger tracking with the Wii remote:

[youtube:http://www.youtube.com/watch?v=0awjPUkBXOU 350 292]

Content Aware Image Resizing

Tuesday, October 30th, 2007

A friend at work just showed me this, and boy is it cool. “Seam Carving” is a new algorithm for image retargeting. Image retargeting is an alternative to scaling and cropping, but it is content-aware. Scaled images suffer from the problem that the re-sized content may be too small to see. Cropped images may eliminate important content. Image retargeting solves both problems by keeping the image elements the same size and simply eliminating the “unimportant” parts of the image.

Graphic artists occasionally modify images this way by hand when doing page layouts for magazines–think of it like a visual form of copy-fitting–but an automated approach opens a world of possibilities. The number of of potential practical applications are immense, and include everything from dynamic web page re-flowing to widescreen-to-standard aspect texture fitting for games.

[youtube:http://www.youtube.com/watch?v=vIFCV2spKtg 350 292]
A better version of the video as well as the research paper can be found on Dr. Shamir’s home page. What’s really neat is how straight-forward the method seems to be. The paper is well worth the read if you are interested in graphics algorithms.

If you’d like to play around with this technique on your own images, someone’s already implemented the algorithm in Flash.

Export Outlook Task Lists

Friday, October 26th, 2007

Outlook 2007 has a very cool feature that lets you embed your current calendar in an e-mail and send it someone else. Wouldn’t it be nice if you could e-mail your To-Do list as well? Now you can! This macro shows you how to generate a formatted e-mail that contains all of your current tasks, as well as a list of any messages that you’ve flagged for follow-up.

(more…)