« Anatomy Practice: Shoulder Girdle | Main | ColorTalk »

November 15, 2004

Camera Projection Fun

camProjSwoop.gif
Here, for fun, is a short tutorial on how to turn a 2D photograph into a 3D animation using Maya camera mapping. The move you see is entirely virtual. This technique forms a useful basis for "view-dependent texturing" of foreground objects, as well as for imposing a 3D move on a 2D matte painting background.

forBox.jpg
Here's a simple photo of a cardboard box sitting on the floor.

forFloor.jpg
Here's a "clean plate" of the floor alone. I retouched it a bit in Photoshop to let a little of the original box remain around the base. This little trick lets me be a little sloppy in alignment later on.

matchModel.jpg
Using measurents from a ruler, I match model a virtual box with the same proportions. I don't sweat the details (like the folded cardboard flaps on top) - I keep it simple.

matchPosition.jpg
I create camera 1 and position it so that the 3D wireframe box I modelled lines up with the photograph of the box.

constrainCameras.jpg
I create a second camera -- camera 2 -- and match it precisely to camera one by editing its attributes, and by using point- and aim-constraints.

projectionNetwork.jpg
I use "perspective projection" from camera 2 to project the image of the box onto the virtual box. I use the same camera to project the "clean floor" plate onto a matched position virtual floor object.

projectionAttrEd.jpg
To eliminate blurry mapping artifacts on the box, I found I had to turn off filtering in the file node.

The trick of this project is to decouple camera 1 from camera 2 -- to break the constraints so that the projecting camera and the rendering camera are no longer in the same place.

Notice how my original box photo shows three sides visible on the box. When designing my animation, I purposely chose an initial position that hid one of the three box sides, and revealed it over the course of the move. The reveal of the third side makes for a fun, unexpected surprise.

I first started using camera mapping in in the Eighties, although the technique itself was already well-known to some in the CG world before then. The concept of camera projection is older than CG itself, and was used to great effect in analog form in the theater world for decades.

dolphinCamProj.jpg
When the photograph matches the foreground object, and when the projection can be made to "stick" to the object while the object flexes (through reference objects, or projection of UV's into vertices) then camera projection can be used as the basis for creating view-dependent texture maps.

AmCinCamProj.jpg
When the photograph matches the background, it can be used to impose a 3D move on a 2D matte painting.

HowCamProj.jpg

danaCamProj.jpg
When the photograph contains an object with no matching 3D geometry, (as it does in this test I tried in 1992) the photographic object can appear normal when viewed from one place, and "painted on the wall" or "cast like a shadow" when viewed from another place.

Conversely, when a 3D object exists but is not represented in the photograph, the 3D object can, when viewed from the right place, vanish like a chameleon into the background. Look at the character "Reptile" in the movie Mortal Kombat, to see this technique in action.

UPDATE 1/16/2006
Here are some fun "real world" examples of the principles of camera projection in action:

Felice Varini: Denial of Perspective

Kurt Wenner: Amazing Sidewalk Chalk Artist

Posted by digital artform at November 15, 2004 12:10 AM

Comments

is this maya what is being used?

Posted by: omar at November 15, 2004 09:25 AM

I'm using Maya 6, but any version of Maya will do, as far as I know -- and although the workflow will differ, the principles hold true in any 3D package that has implemented the idea of camera projection -- which is really nothing more than projection using rays which all radiate from a single discrete 3D point.

Posted by: Joseph Francis at November 15, 2004 10:13 AM

i appreciate this tutorial as it is something i've been having problems with. is it possible to email you (i can't seem to find any contact information on this site)? i have a question about a particular situation where camera projection might be used, and i thought perhaps you could steer me in the right direction. thank you.

Posted by: hai at November 24, 2004 08:45 AM

I'm still learning how to handle a Movable Type-based blog, so at the moment there isn't too much information on the page that wasn't in the default layout.

You can reach me by email at jfrancis at earthlink dot net

Posted by: Joseph Francis at November 24, 2004 08:52 AM

Hey!

I Like It!
By!

Posted by: Hiren Dave at February 14, 2005 04:07 AM

Cool - cant quite get all the way though. I'm a little lost here. ok
francis you say - I use "perspective projection" from camera 2 to project the image of the box onto the virtual box." I cant see where it goes into the the camera projection setup for cam2. I've got the clean floor plate showing up fine - coming from the place2DTexture in the shader line up.

camera 1 is the rendering camera plus the one you animate?
camera 2 is the projecting camera?
is that right

sorry to be a pain in the butt!, I'm sure I'm missing something real obvious. any answers would be great

Posted by: luke at February 16, 2005 02:54 PM

hi this is an excellent artical on camera projection. Theres some part I'm can't fully replicated your scene, for example

1. how did you match the camera1 with the real camera that your shot from(or did you not do it?)

2.was the box model a perfect box or did you tweek the vertex so to match the perspective distortion your see of the texture image viewed from camera1? (I can't seem match it)

Posted by: yinako at February 18, 2005 11:20 PM

I matched the wireframe to the photo only by eye.

The box is a true box.

You'll never get this image:
http://www.digitalartform.com/archives/images/matchModel.jpg
exactly as shown in your viewport. I pushed the box wireframe closer to the channel box so that you could see both at the same time. I also may have rolled the camera a bit. The unusual placement and perspective may make you think that I pulled a corner or two. I actually did not.

This is just a manipulation of the screengrab of the gui. The scene itself is quite straightforward.

Posted by: Joseph Francis at March 14, 2005 09:46 AM

I was able to follow the tutorial, except I was initially unclear as to actually setup the projection. You're other tutorial on the same subject cleared it up. Also, just duplicating the camera seems to work just fine for me, instead of going through the process of constraining and unconstraining.

Posted by: Jeremy at April 24, 2005 12:43 PM

You're right. Duplicating the camera does work well, and when this sort of thing comes up, I do it all the time that way now.

I'm not sure why I didn't always do it that way, but there you go. For whatever reason it didn't occur to me.

Posted by: Joseph Francis at April 24, 2005 09:38 PM

looks like alot of fun but..

where is the perspective projection button? what needs to be selected when i click it? how do i find the point/aim constraint buttons and use them to match up the cameras? how do i decouple the two cameras afterwards, and why do they need to be matched up in the first place? what would happen if i tried to view the box from behind? would it just be untextured?

Posted by: joe at June 1, 2005 10:17 AM

I actually work on a movie where we use extensively the camera mapping method. So I tried to make it work with maya and mental ray (as we do not use maya, but mental Ray), but the projection is non working when rendering with MR (we get a kind of hjdkfqlr zfc,hufize...)

maybe someone got an idea to make MR understand the projection node ?

Posted by: PierreV at June 18, 2005 12:17 PM

Hi, I recently played around with camera projections for the first time.

I was wondering if you could give some pointers on using it for modeling purposes as well.

I tried using a photo I found on the web to model a house and use the same image as a camera projected texture and it worked out pretty good. So I tried the same thing on more random photos from the web and had absolutely no luck.

I've made a post about it over on cgsociety. Photogrammetry Thread

Posted by: thinsoldier at February 2, 2006 04:23 PM

I just went through the tutorial and it was a big help to me. (see my results here; 'projection1' )


Thanks again:)

Posted by: forcemd at May 7, 2006 12:28 PM

I just watched your video; very nice job

Posted by: Joseph Francis at May 7, 2006 12:59 PM

Post a comment




Remember Me?

(you may use HTML tags for style)