In this article we give you an introduction to node-based compositing and show you how to do a basic green screen composite shot with Blender.
Not Easy Being Green
Obviously, to get the best green screen composites you have to shoot good “plates.” “Plates” are the main bits of the shot that you bolt together in movie visual effects. You have the foreground plate and the green screen bit with an actor filmed in front of a green screen. Then you have the background plate which is the bit you want to show through the green bits of the foreground, making the whole thing look as though the background and foreground were filmed at the same time. There are plenty of examples around the web of shots you can play with. They tend to be professionally shot which is a boon but are usually compressed which is not. Uncompressed shots make for better composites, but for the purposes of a demo, we’ll take what we can get. Our green screen shots in this instance came from the excellent free green screen library at Hollywood Camerawork.
The background plate (because we needed to fake a pan across a city skyline) is a really high-resolution panoramic shot of Singapore by Erwin Soo from Wikipedia.
Making the Assets
We need to make the assets we are using a common size so they fit together in the composite. We need to end up with two videos of 720p at 30fps. How you do this is not relevant to the tutorial. (Resizing videos, making videos out of image sequences and sliding large images to make pans are outside the scope of this article, but we will return to these techniques at another time.) The green screen shot was single frames (a common way to work with uncompressed footage), so to make that easy to handle you have to make it into a video. It is also horizontally compressed (a mistake probably, as you can see above) as the dimensions are 1280 by 1080 which mixes two standard HD formats – 1280×720 OR 1920×1080, not both. To save drive space and hang onto as much resolution as we can from the footage, we can resize this either with Quicktime 7 or a video editing program to a proper HD resolution of 1280×720 at 30fps. The background is a LONG panorama, so use a video editing program to line it up so the photo fills the screen vertically, focus on one end of the panorama and then slide the panorama across the screen (using keyframes and motion) as if panning the camera. The green screen footage starts looking at her front and ends looking at her right side, so the “pan” needs to be a little less than 90 degrees to the “right.” As there are no tracking markers on the green screen plate, you need to do this to the background plate by just eyeballing it.
Putting It All Together
So we need to pull these two elements into Blender and pull a key on the green bits to make the background show through in as naturalistic a way as possible. Blender is a node-based compositor which means the control mechanism is nodes or little LEGO blocks of love which you place on the screen and link with little strings which form your signal path. To get set up for compositing, start Blender. (If you don’t have it, go here and pick up your free copy for your platform. Install the program and open it.) Locate the drop-down (it goes up, actually, but you know what we mean) at the bottom of the view, and select “Movie Clip Editor.”
Click the “Open” button and choose and load your green screen footage. (You can also load sequences of images for uncompressed keys in this step if you have the space, and the footage is the right size.)
Once the clip is loaded, go back to the drop-down and select Node Editor.
The screen will be blank, but just go to the bottom of the view and click the middle button marked “Node Tree Type” to Display, and then check the Use Nodes and Backdrop buttons.
Select the “Render Layers” node, and because we won’t need it you can delete it (on the Mac this is the Forward Delete key). Then move the Compositing node out of the way because we won’t need it yet.
Note: to zoom in and out of the nodes, use the centre scroll wheel of the mouse if you have it. To zoom in and out of the images you are working on, use the V and Alt-V keys.
Compositing Nodes
Click the Add menu in the bar at the bottom of the view and select “Input -> Movie Clip.” Select the green screen clip you added in the Movie Clip Editor. This is the input. We have to push this through a keyer to remove the green and make those areas transparent.
Important: in this program flow goes from left to right, so node inputs are on the left of a node, and outputs are on the right of a node. Now select “Add -> Matte -> Keying” to add a keying node. Also “Add -> Output -> Viewer” to make the output from the key visible. Click on the little yellow dot next to Image output on the Input node, and drag it to Image input on the Keying node. Then drag the little dot next to Image output on the keying node, and drag it to the image input on the viewer node.
You now have to select the key colour, the colour which the keyer is changing to transparent. Click the Key Colour button on the Keying node, and this displays a colour selector. Click the eyedropper, and click on the image in the background somewhere on the green screen. If you look carefully, you will see that there are some areas which still have a bit of colour and are not fully transparent. You can check this more accurately by dragging the string from the Matte output on the Keying node and linking to the input on the viewer. This is the key you have made. As you can see, the dark bits are supposed to be totally black, and there are still greys showing through. (This is because the source material wasn’t perfect.)
There are many different ways to fix this depending on the shot, but if it’s a reasonably well-shot green screen, all you will need to do is the following. Adjust the Black Clip slider to expand the amount of greens which turn to black. Then adjust the White Clip to push the whites to prevent them from becoming transparent.
Once you have pure white and pure black, reconnect the image output of the keying node to the image input on the viewer, and you’ll see you have a decent key.
You can adjust the amount of fringing and spill (reflections from the green screen on the model), but generally the keyer does a good job of guessing that for you with a decently-shot green screen.
Adding the background
After this, adding the background is more of the same with a slight twist. “Add -> Input -> Movie Clip,” navigate to your background clip and load it.
To blend the two layers, you have to make a mix of the two clips so that the background shows through the now transparent bits of the foreground. “Add -> Colour -> Mix node”. Take the output from the background clip, and feed it to the top image input of the mix node. Take the output from the keying node, and feed it into the lower image input on the mix node.
Click the Alpha channel button next to the drop-down on the mix node.
And finally we have our key. The background is way too sharp and makes the green screen footage look really soft and crappy, so we need to soften the background. There is a really nice Bokeh Blur filter in blender for just this purpose to make the background look out of focus and add lots of gorgeous Bokeh blobs. “Add -> Filter -> Bokeh Blur” and put it between the background clip and the mix. In Blender, if you add a node and place it over a string between two nodes, the string goes yellow, and dropping it will automatically insert the new node into the signal path connecting inputs and outputs.
Finally add an image to the Bokeh Blur for the shape you want the bokeh to be; we opted for a donut-shaped iris pattern. To render out your video, connect the output of the Mix node to the input of the compositing node we left lying about earlier. It’s okay for this output to be connected to the input node of the viewer, too, as this means we see progress while rendering.
Make sure you are set up to render the right amount of frames at 30fps in the render panel on the far right. 30fps for 5 seconds (the duration of our clip) is 150 frames. Insert 150 where it says End Fr.
Select a place and a filename to output to in the Output panel further down the right-hand side. Then to render, select the info menu bar from the top-left drop-down, and finally choose “Render Menu -> Render Animation,” and the render will begin.
Here is the finished result. While the tracking isn’t great, if there are tracking markers you can track the motion of the green screen and bolt the background down so it moves like the foreground, but we’ll cover that in another tutorial. It looks a bit like she’s on a flying carpet, but you can fix that by tracking only in the Y (or up and down) axis, but again, that’s outside the scope of this article. Also, if you were shooting it yourself, you could light her from below as if she’s standing on a building, or at least add some contrast in the lighting to make it more moody. But this is just to show you the basics. On the whole, considering it was done by hand and guessed, it’s a decent shot. If you have any ideas about future compositing articles or have any questions about compositing in Blender, please let us know in the comments below.