Compositing Premultiplied 3D CG in Photoshop


The thing about 3D CG is it usually is rendered on black with a precisely-fitting alpha channel. We typically call this "premultiplied" CG.

Suppose you want to cut and paste it onto a background using Photoshop.

Here's a workflow which preserves soft edges and avoids matte lines.

The wrong way goes something like this: you load the alpha channel as a selection, cut the CG off of its black background using this selection, and paste it onto a background image.

Do that and you'll end up with a gray matte line around your solid edges, and a gray haze in your motion blur.

Let's try it a different way.

First, create a new layer above your beauty pass and fill it with pure black.

Next, Use the alpha channel to cut out this black color.

Now paste this black color directly onto your background image. In this example, the background image is a blue sky.

In the old days of optical printing, this technique was called creating a holdback matte.

Return to your beauty pass. Deselect the selection and dump from your beauty pass this newly created black layer. You don't need it anymore.

Finally, Grab the entire beauty pass, black background and all, and paste it on top of the blue sky-with-holdback matte.

Use the LINEAR DODGE blend mode. The LINEAR DODGE blend mode is arithmetically equivalent to a simple ADD. You are now performing what the optical printer guys called a double exposure or "DX" or burn-in

If for any reason your beauty pass is not aligned with your holdback matte, simply nudge it into place.

Voila. Perfect compositing of premultiplied 3D CG in Photoshop.

Here's the "wrong way" once again, for comparison.

UPDATE 3/23/2009:

So... LAYER > MATTING > REMOVE BLACK/WHITE MATTE is the official way to go.

If the official Photoshop workflow is giving you good results, then you are all set. If for some reason it isn't quite working (People seem to have mixed results on this issue) then here are some additional ideas:

First read Transparency Mapping and Matte Lines if you are not familiar with the idea of dividing the rgb of an image by its own alpha, and why you might want to do so. You'll even find a (last resort) method using Maya for doing so.

Next, consider undoing the premultiplication in your own particular case by using After Effects (if you have it) and John Knoll's unmult (free plugin) to render one frame.

Or if you have Shake, you'll find the necessary division node there.

Finally, you might try The Gimp. I understand it has a divide blend mode.

If you know of other methods for dividing in Photoshop, or elsewhere, I'd like to hear them.

btw - 'screen' is not literally the opposite of multiply; it is not identical to 'divide.'


i've been looking for a way to achieve this for ages. you had a similar tutorial using compositing software for footage, but i was never really able to replicate the workflow in photoshop easily... until now =) thanks for yet another "should-be-common-sense-but-for-some-reason-isn't" piece of information!

awsome just awsome, but I never thought it would take that many step to achieve in PS

this is cool... even if I may never use it, it's interesting to see how the linear+black layer could achieve such results

After playing with this,it seems this procedure might be simplified by copying the beauty pass's alpha channel directly and pasting it onto a layer between the beauty pass and the background. Then, just set the alpha channel layer's blending mode to multiply which effectively creates the holdback matte. Pasting the alpha channel directly should also ensure proper alignment of the holdback matte without nudging. If the user had rendered with a white background then just invert the pasted alpha layer and set to screen mode instead of multiply, and then set the beauty pass to linear burn instead of linear dodge. However, if the background color of the beauty pass is any color other than white or black then you may be out of luck... in any case, thanks again for the great tutorial!

Even better; thank you!

Am I wrong in that if one renders premultiplied on either a Black or White, then using photoshops':
will do this same thing in one shot?

I've been doing this for 3 years with no issues.

Am I missing something?

Just curious:)

Great site btw!!

Nope. You are right.

I tend to ignore Photoshop specific workflows whenever I can, because they are not portable to other apps.

I was up and running in Shake in a half hour because it allowed me to draw on all the math I already knew.

It took me literally years to warm up to Photoshop even to the extent that I have.

Thank's a lot.
Really useful tutorial !
Now I know why I always get ugly edge with PS...

Output = (A x M) + [(1-M) x B]

A= Foreground Image
B= Background Image
M= Alpha for image A

AxM basically is your premultiplied image.

Yes... Easy way is to use "remove Black Matte" in photoshop matting menu. Does the same thing as this tutprial but much easier.

Use Black matte if the premultiplied BG is black..

Comparison tested with Photoshop, Fusion, and Shake.

It's still a great tutorial to get "under the Hood" of compositing in PS! thanks


now this is your next task :-) :
What if I render a shiny glass with spec lights and all, and I want to transfer THAT onto a different backplate?

That´d be sooo cool to know, it´s the last compositing thing that still drives me nuts... always losing all those nice spec lights!

to Micha:

you'd have to render a Specular pass in order to keep those

good stuff

I tried an example recently of a soft-edged element with a perfectly-fitting soft-edged matte where I did the Photoshop > Layer > Matting > Remove Black Matte and the result looked very bad! The edges were not soft, but had hints of too much brightness and a bit of a sharp edge at the end of the soft region.

I tried it again using the soft black holdback matte and Linear Dodge "add" - and it looked beautiful.

Thank you for posting this alternative workflow!

About this Entry

This page contains a single entry by published on October 20, 2005 10:23 PM.

Proportional Dividers was the previous entry in this blog.

Clockstoppers / Cinefex Magazine is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.