You are on page 1of 32

camera mapping tutorial

Camera Mapping Tutorial


by Janine Pauke - www.3dfluff.com

(additional proofreading and removal of hy-phens, "quote marks" and germanisms by Matthew O'Neill)

CINEMA 4D R9 is recommended, however most of the tutorial also works in 8.5 (with a few workarounds for certain parts).

You will need a bittorrent client to download the files that accompany this tutorial. If you don't already have a bittorrent client, I suggest installing
Azureus for Windows or MacOSX, a free java based client.

Download the bittorent file from this page and open it with your bittorrent client (if it doesn't open it automatically). Your client will then start
downloading a zip archive which includes the video tutorial, final project files, example animations and the painting in .psd format. Due to bandwidth
limitations I'm unable to host the files directly on 3dfluff. Bittorrent works by sharing the already downloaded parts with other people so please leave
your bittorrent client open for a few hours after you've finished downloading. The more people download the file and leave their client open, the faster
other people can download it. For information on bittorrent go here.

UPDATE: The C4D Portal is now hosting the tutorial as well! Without bittorrent but with direct download links instead. So if you don't want to use
bittorrent check out this link.

Introduction
http://www.3dfluff.com/cameramapping/cameramappingtut.htm (1 of 26) [07/09/2004 13:58:15]
camera mapping tutorial

This tutorial is about magically turning an image into 3D. Actually there isn't any magic involved but it is possible to some degree to turn a flat image
into something 3D. The method is called "camera mapping" or "camera projection". In Cinema 4D there is also a texture mapping method called "frontal
mapping" which is essentially the same. The image is projected through the camera onto the geometry. However, with frontal mapping the texture has
to be "stuck" to the geometry if you want to move the camera - either with uvw coordinates or a stick texture tag. It is also limited to just one camera.

Since release 8.5 there is an additional method called "Camera Mapping". There is no need to use UVWs or stick texture tags anymore - one camera, the
"projection camera", is used to project the texture while any other cameras can be used to animate and render the scene.

Camera mapping is mainly used for matte paintings in movies. These days matte paintings aren't just static flat paintings in the background. Matte
paintings can now be 2.5D - they are projected onto 3D geometry which allows for much more complex camera moves and perspective changes.

See how it works


I've done a video capture of the entire process in Cinema 4D R9 which you should watch first to get a rough idea of the workflow (download the
bittorrent file above and watch "cameraprojection_videotut.mov").

The video is showing the basic setup with just a floor plane, a sky dome and a few landscape objects that are positioned to roughly match the mountains
in the painting. In this tutorial I will go a bit more in depth and explain a few more things such as how to include an additional cg object and how to add
some atmospheric effects. This tutorial is not meant as a complete step by step tutorial (it would be the size of a book and most readers would probably
fall asleep before reaching the end). You should already know how to create polygon models, create and assign materials, deal with tags and so on. This
tutorial is probably more suitable for advanced users.

There are two ways to make a 2.5D environment - either start with the 3D geometry then paint a matching image to project onto the geometry or first
paint an image and then worry about the 3D geometry afterwards. In my case I did the image first.

The 2D bit
When I speak about painting I don't actually mean painting in the traditional sense, for this tutorial I mostly used photos of mountains, snow and clouds
and then painted over them to add or remove details. I also used a lot of adjustment layers in Photoshop to change the colour from daylight to night
time. Here are a few stages from the original image to the final painting (click to see bigger versions):

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (2 of 26) [07/09/2004 13:58:15]


camera mapping tutorial
I started the painting with night time illumination in mind but I kept all the source layers as daylight. Instead I set up several adjustment layers for
brightness, contrast, hue/saturation and levels to achieve the night time look. I used layer masks to apply the effect only where I wanted it. For
example I darkened the top of the sky and the ground in the foreground and darkened only the brightest areas of the mountains on the left. I kept the
mountains on the right a bit brighter since they're closer to where the light comes from. It may not be completely realistic, it just has to look good and
be convincing. To edit and add extra details to the landscape, I switched off all the adjustment layers and only switched them on occasionally to check
the night time result. I generally try not to reduce the contrast of any layer permanently. I always use adjustment layers. Once the contrast and colour
information is lost you can't get it back. If you darken your image so that all the dark areas become complete black you can't brighten up those areas
afterwards. They will become grey and the image levels look clipped. The same is true for brightening very bright areas. I also usually work with 16bits
per channel instead of 8. It doesn't help much with clipping but 16bit per channel images have more colour and brightness information inbetween 100%
black and 100% white, this helps to reduce banding in large areas with soft gradients. I have included the finished painting as Photoshop file (resized to
1024x1024 and with 8bits per channel to reduce the file size) so you can check out all the layers yourself. The .psd is included in the bittorrent file
above.

Now the 3D bit


Start by creating a material and loading the painting into the luminance channel. You will need to load it into the color channel later on but for simplicity
reasons just use luminance for now. Luminance will make it display with constant shading which is all we need for now.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (3 of 26) [07/09/2004 13:58:16]


camera mapping tutorial
The standard preview size for textures in the viewport is 256x256 pixels which is far too small and blurry (the original size of the painting is over
3000x3000 pixels). On the Illumination tab of the material you can change the texture preview size to 1024x1024 (or bigger if your graphics card can
handle it):

This should be big enough to see everything clearly in the viewport.

Small note: When loading a scene the colours for the texture display in the viewport may be reduced. This is because Cinema generates a copy of the
texture just for the viewport display. This preview texture gets saved in the scene file so it doesn't have to be recalculated everytime you open your
scene (which would otherwise take a lot of time with many textures). However, to keep the scene file size small the texture gets compressed which
results in reduced colours. If you want to revert the texture display back to its original state go to the material manager menu and choose Function >
Render Materials.

Sky and ground


Start building your environment by making a sphere for the sky (don't use the special sky object) and a ground plane. Actually I used a disc for the
ground but you could use a plane as well. Just make sure that the ground is large enough to meet the sky sphere on all sides.

The sky should be quite big and flat, not just a round sphere. The flatter you make it, the more of a 3D effect you will get when moving through the
http://www.3dfluff.com/cameramapping/cameramappingtut.htm (4 of 26) [07/09/2004 13:58:16]
camera mapping tutorial
environment. The clouds will appear to be hanging low above the environment. So change the flatness depending on your taste and how low you want
the clouds. Just make sure you don't make it too low, otherwise if the camera gets too close to the sky the texture resolution won't hold up and the
perspective will be too extreme.

Now assign the material to both the sky and ground and set the projection to "Camera Mapping":

You won't be able to see anything in the viewport yet. That's because we haven't assigned a camera to the projection. As I already mentioned, camera
mapping works by projecting the painting through a camera onto the geometry. So create a camera and rename it to "projection cam". Link the camera
to the perspective viewport and drag it from the object manager into the "Camera" input field of both texture tags. Also make sure that the projection is
set to the correct texture size, otherwise the painting will be squashed (press the calculate button):

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (5 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

There should be something to look at in the viewport by now and after doing a first rough camera aligning it should look similar to this in gouraud
shading with lines:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (6 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

(If it doesn't look exactly like this, have a look at the next paragraph about viewport shading).

Now rotate and position the camera so that the horizon is aligned with the horizon in the painting. Try to match the perspective as best as possible.
Finding the right height of the camera is a bit of guesswork, maybe have a look at the side view and try to imagine what the angle between the camera
and the ground would be. It doesn't have to be absolutely precise, the perspective in the painting probably isn't 100% correct anyway.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (7 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Now duplicate the projection camera and rename the new camera to "render cam" and link it to the perspective viewport. Make both cameras invisible
(upper visibility dot) so they don't get in the way.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (8 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

After this you shouldn't touch the projection camera anymore. If you don't trust yourself not to accidently move it, assign a protection tag to it (File >
CINEMA 4D Tags > Protection in the object manager).

You can now use the render cam to move around in the scene and get a feel for the 3D effect it creates.

A few notes about viewport shading


If your viewport display looks nothing like in the screenshots above then that's most likely because the subdivision of the ground is not high enough to
display the texture properly in the viewport. Increase the subdivisions for your ground object:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (9 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Higher subdivisions improve the viewport display of textures. This doesn't influence the rendered result though, the textures are always projected
properly in the final render no matter how high or low the subdivisions are.

With Release 9 Maxon added a number of new shading modes to Cinema 4D. The most important additions are Gouraud Shading (Lines) and
Constant Shading.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (10 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

"Constant shading" looks the same as "Gouraud Shading (Lines)" when using a material with 100% luminance. Maybe you're wondering why not just
use constant shading to start with? The answer is that constant shading always displays the wireframe. I don't always want the wireframe visible though
so that's why I choose to use gouraud shading and a luminance material. This way I can switch between gouraud shading both with and without lines.
The line shading modes are a great new addition, especially for camera mapping and matte painting.

Unfortunately in 8.5 there is no easy way to display shading and wireframe at the same time. A good workaround is to group your geometry, make an
instance, make sure the instance is in the same position, assign a Display Tag to the instance and set it to display as wireframe. The result is almost the
same as using gouraud shading with lines in release 9.

Modeling the mountains


Where to start... First of all switch back to the projection cam. You'll need to mainly model in this perspective and use the painting as a reference. After
spending some time thinking about where to start I decided it was probably easiest to first roughly sketch out the mountains with splines. A good
starting point in this case is to draw a spline around the base of a mountain and then project this spline onto the ground:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (11 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

This works perfectly because the ground in the painting is completely flat. If there wasn't a flat ground the situation would be more complicated and the
placement would be more difficult to work out (probably involving a lot of trial and error). I continued like this for all other foreground mountains. If you
look at the top view you can see how far the mountains will be stretching into the distance. So by projecting the splines you have already worked out
where they would be placed in relation to each other:

The next step is to draw additional splines along the contours and folds. The result should look something like this:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (12 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

We're not actually using the splines to build the models, the splines are just guidelines to get a rough idea of the shapes. You can now set up one of the
other viewports as perspective view and start building the mountains point by point, following the spline contours:

Use the create polygon tool or the bridge tool to connect the points:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (13 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Ctrl-drag one of the texture tags onto the new geometry and check out your first 3D mountain:

More 3D mountains:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (14 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

And here is the finished geometry - I had to subdivide the one on the right to add more detail. I also added more geometry for the smaller mountains in
the background:

Moving clouds
Cloud movement adds a bit of life to the otherwise static environment. I used a bone with a vertex map to deform the sky (yellow means strong
influence, red means less):

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (15 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

The vertex map adds a soft falloff. Rotate the bone and the clouds will appear to be moving, with the top clouds moving faster than the ones at the
horizon. For many cases this is good enough. For more "advanced" cloud movement you can use layers or planes of clouds with alpha maps and position
those in front of each other and animate them individually. However, this method needs more planning. When painting the sky in Photoshop, keep all
the clouds on seperate layers. This isn't always easy to do, especially if your sky is mainly based on one photo. It is difficult to seperate the clouds
afterwards. If you plan to use layers for the clouds you need to keep this in mind right from the start when painting the sky.

Before animating the bone, you need to stick the texture to the sky object, otherwise the geometry will move but the texture won't move along with it.
Select the texture tag on the sky object and choose Texture > Generate UVW Coordinates. That should take care of that. Also don't forget to fix the
bone (right click the bone in the object manager and choose Fix Bones) before animating it.

Adding an aerial
Now let's combine this environment with an additional cg element. Why not put an aerial (or something else suitable) in the foreground:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (16 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Until now we've been using the painting in the luminance channel of the material. This is just a shortcut to make it easier to display in the viewport. We
can't leave it in the luminance channel though. If you want to include other objects in the scene to cast a shadow on the geometry, you need to use the
color channel...

...and apply a compositing tag to all the mountains, sky and ground (File > CINEMA 4D Tags > Compositing in the object manager) and switch on
"Compositing Background":

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (17 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

The objects will still be rendered at 100% brightness but other objects (like the aerial) can cast shadows onto the environment geometry.

Unfortunately now the shading is looking different in the viewport. Now that the texture is in the colour channel, the geometry is shaded and in this case
mostly dark. You could use the Constant shading mode from the Display menu but the downside is that you would always have the wireframe visible as
well. There is a workaround though - make an environment object and set the Environment Strength value to 100%:

Now it should look like constant shading in the viewport. But don't forget to switch off the environment object for rendering (change the lower visibility
dot in the object manager to red). Now the shading is back to what it used to look like earlier:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (18 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Lighting the aerial


To illuminate the aerial and make it cast a shadow, I positioned a blue light to the right to match the light direction and colour of the painting:

I set it to cast an area shadow. I also set it to only include the ground and the aerial so none of the other objects can cast or receive any shadows (you
could also set them not to receive shadows but this is quicker):

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (19 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Ground fog, snow particles and other finishing touches


The only things left to do now are adding animated ground fog/shadows, snow particles, a nice camera move and actually render out the final result and
maybe tweaking it in a compositing application.

For the ground fog (well it's not actually fog, it looks more like moving shadows) I used a parallel square spot light without illumination but with visible
light. The visible light uses a noise which is animated.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (20 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

If the effect isn't visible enough you can turn up the "Dust" parameter on the "Visibility" tab. The dust parameter makes visible light visible even when it
is darker than the background (mainly useful for dark smoke effects and such). The light is pointing in the z direction and is scaled down on the y axis
(using the Object tool - the one that actually scales the axis, not the Model tool) so that it's flat on the ground:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (21 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

For some more atmosphere, add a particle emitter that is big enough to cover the entire environment:

To achieve a dense snowy atmosphere you need to turn up the number of particles a lot. I've set mine to 10000 particles in the renderer (and 1000 in
the editor to speed up the redraw). Actually 10000 particles is the limit for a single emitter. Now that shouldn't stop you of course! Just duplicate the
emitter to get more particles. Apart from a gravity object I'm also using a wind object with animated wind speed to blow the particles around. This is the
wind speed fcurve, the values vary between 0 and 50:

To speed up the rendertime and display you should place a particle destructor object underneath the ground to kill any particles that have gone through

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (22 of 26) [07/09/2004 13:58:16]


camera mapping tutorial
the ground.

Now we just need to get the particles to actually show up in the rendering. What I tried to achieve is the streak effect you get from motion blur. There
are several possibilities. You could use little spheres with a luminance material or visible lights and motion blur to get the streak effect. However, if
you're the lucky owner of the Sketch and Toon module, you have a very powerful particle drawing engine at your fingertips. Sketch and Toon doesn't
just make cartoony looking objects, it can also be used to draw particles as lines with varying length, thickness, colour, opacity and more (you could
even render them as lots of little arrows, the possibilites are endless).

To use Sketch and Toon, open the Effects page in the render settings and choose Sketch and Toon from the post effect popup. On the Main page, set
the control level to "Advanced" to get access to all options. On the Shading page, switch off the shading for Background and Objects. Now go to the
Lines page and uncheck all the line types and only switch on the Particles line type. At the bottom of the page there should now be a few options for the
particle line type. Set the Velocity Scale value to 1%. This value controls the length of the particle streaks and the faster the particles move the smaller
you should make the value:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (23 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

When creating a Sketch and Toon post effect a "Sketch" material is created automatically. This material defines all the line parameters like thickness,
colour etc. It doesn't need to be assigned to any object, it is used by the post effect directly. Open the material. The interesting pages are Color,
Thickness and Opacity. I've set the colour to a light blue and the thickness to 0.5 (this is measured in pixels). The Opacity is set to 70% and uses an
inverted spline curve to reduce the opacity of the particle streaks along the stroke length:

Now all that's left to do before rendering the scene is animating the camera. I'll leave you to that. I've done two example animations (in the bittorrent
file above, snowy_part1.mov and snowy_part2.mov) for inspiration. If you move the camera too high up or too much to the side you will probably
see some texture stretching. If you want to know how to deal with this problem, read the part a bit further down about fixing projection problems.

Lastly there is a lot you can do in compositing. You could change the levels, add more contrast, tweak the colours and maybe add a bit of film grain. I
also used multipass rendering so I could slightly blur the background to soften up the sharp lines between the mountains and the sky while keeping the
aerial crisp. Here is a still from one of the animations after compositing:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (24 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Fixing projection problems


You're probably wondering what happens if you move the render camera further up or to the side. What happens to the geometry that now gets
revealed behind the foreground geometry? Parts of the foreground are projected through onto the background, the image is stretched and repeated and
generally looks horrible. But there is a solution. If you notice these problems on one of the mountains for example, take the original painting and paint
in the missing areas for only that mountain and use this new painting in a new material and assign it to just this mountain. Here is an example, the
squiggly green line shows the edge of the first mountain. The texture gets projected through onto the mountain behind it. To correct this I've painted
over the area in Photoshop and assigned this new painting to the mountain which showed the problem:

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (25 of 26) [07/09/2004 13:58:16]


camera mapping tutorial

Or if the situation is very bad, render out a still from the perspective that is showing the problems and correct all the problem areas in Photoshop. Then
make a new material with the new painting, set up a second projection camera from this perspective and assign the new material to those models or
polygons that show the problem. To avoid seams you could also paint an alpha map to blend between the two paintings and only make the second
painting show up in certain areas.

So to summarise: The more you want to move the render camera, the more you will have to set up additional projection cameras with additional
paintings to cover up problem areas.

Random tips
Use Layers! If you're doing a matte painting in Photoshop, don't merge everything down. Keep it on seperate layers if you can. If the list of layers gets
too long, group your layers into folders. Now if for some reason you need to move an object to a different position you can just move the layers. If you
had merged all the layers down you would have to repaint everything.

This tutorial may not be reproduced or redistributed without prior permission of the author.

http://www.3dfluff.com/cameramapping/cameramappingtut.htm (26 of 26) [07/09/2004 13:58:16]


http://www.3dfluff.com/cameramapping/pics/stage1.jpg

http://www.3dfluff.com/cameramapping/pics/stage1.jpg [07/09/2004 14:03:02]


http://www.3dfluff.com/cameramapping/pics/stage2.jpg

http://www.3dfluff.com/cameramapping/pics/stage2.jpg [07/09/2004 14:03:17]


http://www.3dfluff.com/cameramapping/pics/stage3.jpg

http://www.3dfluff.com/cameramapping/pics/stage3.jpg [07/09/2004 14:03:37]


http://www.3dfluff.com/cameramapping/pics/stage4.jpg

http://www.3dfluff.com/cameramapping/pics/stage4.jpg [07/09/2004 14:03:51]


http://www.3dfluff.com/cameramapping/pics/stage5.jpg

http://www.3dfluff.com/cameramapping/pics/stage5.jpg [07/09/2004 14:04:06]


http://www.3dfluff.com/cameramapping/pics/stage6.jpg

http://www.3dfluff.com/cameramapping/pics/stage6.jpg [07/09/2004 14:04:29]

You might also like