Blender 3D: Noob to Pro/Further Compositing: A Portal Effect

From Wikibooks, open books for an open world
Jump to: navigation, search

You may be familiar with the time-travelling machine known as the TARDIS, which is much bigger inside than it appears from the outside. Alternatively, you may have come across the concept of a portal in science fiction, which lets you instantaneously move from one space/time location to another, just by taking a step.

In this tutorial, we will see how to create an animation where a doorway leads from one world into a completely different world that clearly cannot be occupying the same space as the original world. We will be making use of multiple scenes within a single Blender document, as well as matte nodes in the compositor to combine them together. The overall workflow will consist of these steps:

  • Create a scene representing the “Outer” world (the world outside the doorway, which is also the world where the observer is located.)
  • Assign a specially-coloured material to the doorway in the “Outer” scene, which will be come transparent when composited.
  • Define a camera movement panning around the “Outer” world, to accentuate the portal illusion.
  • Create a scene representing the “Inner” world, which is visible through the doorway.
  • Copy the exact same camera movement from the “Outer” world to the “Inner” one, so the view through the door remains consistent with what is seen on both sides. (This is why it is best to keep the two scenes in the same Blender document.)
  • Render out separate animation sequences for the “Outer” and “Inner” scenes.
  • Create a third scene purely for compositing purposes, bringing in the two previously-rendered animation sequences.
  • Render out the complete composited result sequence.

The actual modelling we are doing here will be very simple, not to say crude, just to illustrate the basic principle; feel free to create your own more elaborate and more interesting scenes, once you have mastered the basic technique!

The Outer Scene[edit]

Start with a new Blender document. Change the Scene name to “Outer”. We will use the default cube as our portal object (why not?). Make it taller, so the front face has about the right proportions for a doorway. Add a plane for a floor just underneath. Go back to the portal,  TAB  into Edit mode, select the front face, and  I nset it just a little bit, for a door frame. Switch to face-select mode, and select just the inner face; give this a new bright green material, and be sure to select the “Shadeless” option in the Shading panel under Materials Blender255MaterialContextButton.png settings. Making it shadeless ensures that the whole doorway has a uniform colour regardless of lighting; the exact colour doesn’t matter, so long as nothing else in the scene comes too close to the same colour. Green is the colour traditionally used for chroma-key work in movies.

BlenderCompositiongPortalScene1.png

Your basic scene setup should look something like this. Apart from the doorway material as discussed above, none of the other material assignments really matter. Note the egg-shaped object (stretched-out sphere) I added poking halfway through the doorway: this object will also appear in the inner scene, reinforcing the idea of a doorway between worlds that you can actually move through.

Animating The Camera[edit]

Still in the Outer scene, add an Empty object at the default 3D cursor location. Parent the camera to this; now  I nsert a LocRot keyframe for the Empty at frame 1, then go to, say frame 51, rotate the Empty about the Z axis by -90° (so the view moves across to the opposite side of the but still showing the doorway), and  I nsert another LocRot keyframe.

While you’re at it, make the following changes in the Render Blender255RenderContextButton.png Context:

  • Set the end frame for the animation frame range to 51.
  • In the Shading panel, make sure the output format is PNG, and set the Output path to //output frames/. Putting the rendered frames from this scene into their own directory will avoid any mixups with the other scene renders.

If you were to render this scene animation out now, you should end up with something that looks like at right.

The Inner Scene[edit]

BlenderCompositiongPortalScene2.png

In the Scene popup menu, click the “+” icon to create a second scene. Choose the option “Link Objects”: this means the new scene will initially share exactly the same objects as the first scene. (Sharing the same objects, rather than making copies of them, just makes it easier if you need to make any changes to those objects; those changes are automatically visible in all scenes sharing the same objects.) Name the new scene “Inner”. We only want it to share the camera (and its pivot Empty) and lighting, and that purple egg thingy that is travelling between the worlds. So select the portal box and floor, and delete them. Create some new objects to make up this inner world, something like at right. Note I gave the inner world its own floor, with a contrasting colour.

Inner scene with Outer as background

Tip: In the Scene Blender255SceneContextButton.png Context, there is a “Background” field in the Scene panel, where you can choose another scene to overlay this one. This is what I did in the screenshot at right, just so I could make sure those balls in the Inner world lie behind the portal door. Don’t forget to remove this Background scene setting when you are done. Otherwise the Outer scene will show up in the render for the Inner scene, which we don’t want!

Inner Scene Animation[edit]

When you created the Inner scene, it would have inherited the same Render Blender255RenderContextButton.png settings as for the first scene: the same frame rate and number of frames to render. Just make one change: in the Output panel, set the path to //inner frames/, so as to keep the rendered frames separate from the Outer scene.

Now when you render out the animation of this scene, you should end up with something like at right.

Compositing It All Together[edit]

Now, make a third Scene, just for the compositing. In the menu that appears when you click “+” next to the scene name, choose “New” to create a new Scene with nothing in it. Call this scene “Compositing”. Leave it empty; we won’t actually be rendering any 3D content in this scene.

Open up a Node Editor window, and change the node editor type to Compositing nodes. Check the “Use Nodes” box; you will see the usual initial two nodes, “Render Layers” (representing the rendering of the 3D objects in the scene), and “Composite” for the final output from the compositor. Get rid of the Render Layers node; we won’t need it at all (and anyway, it won’t work without a camera in this Scene).

Instead,  SHIFT + A dd an Input→Movie Clip node. Click its Open button, go to the “inner frames” subdirectory where the Inner scene has put its rendered frames, and select  A ll the PNG files you find there to make up this movie clip. Click the “Open Clip” button to confirm and return to the Node Editor.

 SHIFT + A add a second Input→Movie Clip node. Click its Open button, and this time go the “outer frames” subdirectory where the Outer scene has put its rendered frames, and select  A ll the PNG files you find there to make up this movie clip. Click the “Open Clip” button to confirm and return to the Node Editor.

BlenderCompositingPortalComposite.png

Now put together the complete node setup as at right. Note the use of a Matte→Color Key (not Chroma Key) node to make the doorway transparent. To choose the right colour, bring up the colour picker for the “Key Color” input terminal, and use the eye dropper to click on the door part of the thumbnail image in the Movie Clip node for the Outer scene. Note I had to add a Filter→Dilate/Erode node with a Distance of -1, otherwise I had a little trace of green showing at the edge of the doorway. The computed colour-key mask then feeds a Color→Mix node which causes the Inner scene to show through exactly where the door is located in the Outer scene, but nowhere else! Simple, isn’t it?

Now, make one final change to the Render Blender255RenderContextButton.png settings, setting the path in the Output panel to //composite frames/ to keep them separate from the two input scenes.

Now when you render out the Compositing scene, you should end up with an animation something like at right.

More On Lighting[edit]

In this example, I gave both scenes the same lighting. But in general there is no reason for this; in fact, giving the two scenes completely different lighting (e.g. night in one, day in the other) would emphasize the jarring discontinuity in moving between them.

However, you might then have to deal with the issue of light spilling from one world to the other through the doorway. This could be fakeddone by judicious placement of additional lights.

Further exploration of this issue is left up to the reader. ;)