3
$\begingroup$

I'm trying to bake a transparent png image with Cycles. It drives me crazy trying to work out how to do this. Can anyone guide me how to accomplish it, or is it possible at all?

White background Texture with white background

Transparent background Texture with transparent background

$\endgroup$
7
$\begingroup$

As far as I know it's not possible to bake images with transparency in Cycles, but it's possible to figure out some workarounds, depending on what you want to achieve.

To bake a transparent shadow texture:

  1. Set up your scene. I'll just use a simple tree in my example. Place a plane under your objects and scale it big enough to catch all the shadows.

    Scene setup

  2. Create a new image in the UV/Image Editor and unwrap the plane.

    Create a new image

  3. Create a simple diffuse material for the plane. Add an Image Texture node to the material and select the new image you just created.

    Material

  4. In the Render Panel set Samples to a nice number (depending on your scene) and set Bake Type to Shadow.

    Render Panel

  5. Bake the image. You should have something like this:

    Baked image

  6. Go to Compositing, select Use nodes and delete the default nodes. Then set up the nodes like this:

    Compositing

  7. In the UV/Image Editor select Viewer Node from the drop down list.

    Image Editor

  8. Save the image as an RGBA file (*.png, *.tga - whatever you need).

    Save the image

  9. Your baked transparent shadow texture is ready.

    Transparent shadow texture

$\endgroup$
  • $\begingroup$ Happy I could help - it was an interesting challenge to figure out :) $\endgroup$ – Karolina Nov 27 '15 at 12:32
  • $\begingroup$ Sorry just one thing about the point 6. i think you must check "alpha" in the "invert" panel also because if you don't check it the image results empty. $\endgroup$ – Colpo Wexler Jul 7 '16 at 18:42
  • $\begingroup$ You don't have to check the Alpha option in the Invert Node. This option activates the alpha channel inversion and since our baked image doesn't really have an alpha channel (we're just creating one), there's no point to invert it. The only thing we're doing here is inverting the colours of the baked image. Black becomes white, and white becomes black. You can notice this change if you connect the Invert Node Color output with Image input of the Viewer Node (take a look at the Viewer Node output - like in the step 7 of my tutorial above). $\endgroup$ – Karolina Jul 14 '16 at 19:38
  • $\begingroup$ Just to explain what happens here: black in the alpha channel means transparent and white means visible. We connect the Invert Node Color output with Alpha input of the Viewer Node and this basically tells Blender to take the colour of the Image input of the Viewer node and paint the image with this colour (I chose black, but you can choose any colour). Then take the inverted black and white version of the baked image from our Invert Node and use these colours to create an alpha channel for the image (again, look at the Viewer Node output as you make these changes). $\endgroup$ – Karolina Jul 14 '16 at 19:38
  • $\begingroup$ It may seem the resulting image is full black, but if you open it in a Photoshop (or any other software that can read alpha channels), you'll notice that it actually does have an alpha in the shape of the baked shadow. The Viewer Node output in Blender also shows what will be visible and what will be transparent in the final image (checkered background means transparent). If this is still confusing, choose red as the colour in the Image input of the Viewer node and it will be easier to see the image is not actually empty. $\endgroup$ – Karolina Jul 14 '16 at 19:38

protected by Community Mar 27 at 22:37

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.