toxi.in.process

Friday, September 30, 2005

Two small helpers for doing multiscreen 3D

My current work project involves displaying a panoramic 3D scenery "seamlessly" across a multi-screen/multi-machine setup. The system needs to support a flexible number of viewports and screen dimensions, so each client will have to be coded with a flexible view frustum in mind: Say, if there're 6 machines used, each box will have to render 60 degrees of the panorama...

Now the issue at hand is that Processing, Shockwave3D and many other 3D engines based on OpenGL usually specify their view angle (FOV) in the vertical direction, not horizontally (as I always assumed since it's far more natural). That's not very helpful in my situation above as I need to figure out the horizontal orientation of each machine's camera/viewport:

Machine #1 camera rotation @ 30 (renders 0-60 degrees)
Machine #2 camera rotation @ 90 (renders 60-120 degrees)
etc.

Since most displays are not squared, but rectangular, the horizontal FOV will be larger than the vertical, but exactly how much? Of course there're ways to easily compute this horizontal angle, only googling for a solution did take me quite a while - and of course I found it where I'd thought I would - on Paul Bourke's site (incidentally, one of my favourite websites)

So here's a tiny code snippet to convert FOV bothways, in case you'll ever run into similar situations:

/**
* computes horizontal FOV from window size and vertical FOV
* @param fov vertical FOV (in degrees)
* @return horizontal FOV (in degrees)
*/
float apertureV2H(float fovV) {
fovV=radians(fovV);
return degrees(2*atan(width*tan(fovV/2)/height));
}

/**
* computes vertical FOV from window size and horizontal FOV
* @param fov horizontal FOV (in degrees)
* @return vertical FOV (in degrees)
*/
float apertureH2V(float fovH) {
fovH=radians(fovH);
return degrees(2*atan(height*tan(fovH/2)/width));
}


Monday, September 26, 2005

1st Ave Machine

Usually I don't do link blogging, but there're exceptions to every rule.

1st Ave Machine is a CG animation/postproduction house in NYC, doing some very slick projects mixing (semi)generative 3d and real world footage to blur the line between "what we perceive as real and impossible". Mutated botanics, weird worm-like creatures, glossy urchins, near perfect light matching, shaky cam, added film grain - the works. It's a model citizen of Uncanny Valley. A very inspiring one, I think...

Now if only that'd be interactive, some of the creatures would make some cute cyber pets ;)