I have a high poly model and I want to bake its diffuse texture to a low poly model.

So here is what I have:

Download the Blender file here:

The result of baking from selected to active looks like this:

However my goal is to replace the transparent background with meaningful color data. Specifically I want the color of the margins to expand into the transparent areas. Let me show you...

the desired result should look something like this:

I don't want to do it manually. The goal is to do it automatically with the help of the Blender Python API.

Currently I use something similar to the following code to bake with the Python API:

bake_image = bpy.data.images.new('bake_image',width=2048, height=2048)
bake_node.image = bake_image
self.bake_image.filepath_raw = 'bake_image.tif'

1 Answer 1


You can set a bigger margin without perturbing the bake itself:

enter image description here

So the result is:

enter image description here

And the models are still quite nice:

enter image description here

So for the api, use the margin parameter:

bpy.ops.object.bake(type='DIFFUSE', margin=512)
  • $\begingroup$ Oh wow, I thought turning up the margin will result in an overlap. But I guess blurring the margin isn't an easy task? (such that it doesn't look like a barcode) $\endgroup$ Sep 10, 2020 at 16:22
  • $\begingroup$ Well maybe bluring mixing 0 margin and big margin, so two bakes (or use the UV map export)... the alpha of the first could be a mask for bluring the second... and something around mixing that with compositor and extract the view result after that... a bit long for me to do it. But you can? Yes? $\endgroup$
    – lemon
    Sep 10, 2020 at 16:29
  • $\begingroup$ Additionnaly yes previous versions of Blender did not like big margin (if I remember well). $\endgroup$
    – lemon
    Sep 10, 2020 at 16:30
  • $\begingroup$ Ok great! I'll figure out the rest on my own. Thanks for your help! $\endgroup$ Sep 10, 2020 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .