<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kendeepp</title>
    <description>The latest articles on DEV Community by Kendeepp (@kendeepp).</description>
    <link>https://dev.to/kendeepp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4184272%2F0343d297-8762-481f-99cf-82a9e3a9b632.png</url>
      <title>DEV Community: Kendeepp</title>
      <link>https://dev.to/kendeepp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kendeepp"/>
    <language>en</language>
    <item>
      <title>Why your Blender bakes freeze the UI, and how to bake in a background process instead</title>
      <dc:creator>Kendeepp</dc:creator>
      <pubDate>Fri, 16 Oct 2026 07:50:00 +0000</pubDate>
      <link>https://dev.to/kendeepp/why-your-blender-bakes-freeze-the-ui-and-how-to-bake-in-a-background-process-instead-53dd</link>
      <guid>https://dev.to/kendeepp/why-your-blender-bakes-freeze-the-ui-and-how-to-bake-in-a-background-process-instead-53dd</guid>
      <description>&lt;p&gt;Disclosure: this article was created with the help of AI. I'm the author of a Blender add-on in this space, but this post is a standalone tutorial and doesn't link to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;bpy.ops.object.bake() blocks Blender's UI thread. A long or stuck bake means a frozen window, and a crash can cost you unsaved work.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern: one background process per map
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Save a temporary &lt;em&gt;copy&lt;/em&gt; of the .blend (never bake on the file you have open):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;   &lt;span class="n"&gt;bpy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ops&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save_as_mainfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tmp_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Launch a worker per map:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   blender &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="nt"&gt;--factory-startup&lt;/span&gt; tmp.blend &lt;span class="nt"&gt;--python&lt;/span&gt; bake_one.py &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--map&lt;/span&gt; normal &lt;span class="nt"&gt;--out&lt;/span&gt; /path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In bake_one.py: parse your own args after "--" (sys.argv[sys.argv.index("--")+1:]), make the target mesh selected and active, use the Cycles render engine (bake only works in Cycles), add an Image Texture node with a new image to the object's material and make that node the &lt;em&gt;active&lt;/em&gt; node, then call bpy.ops.object.bake(type='NORMAL') (or 'ROUGHNESS', 'AO', ...). The mesh needs a UV map. The baked image is only in memory: set image.filepath_raw and call image.save(), or the result is lost when the worker exits.&lt;/li&gt;
&lt;li&gt;In the parent, use subprocess.Popen and poll; enforce a timeout (e.g. 3× an estimate, minimum 60 s). On overrun call terminate(), wait a few seconds, then kill() if it is still alive, and continue with the next map.&lt;/li&gt;
&lt;li&gt;Cancel = terminate the child process, not just set a flag.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Gotchas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;--factory-startup avoids user add-ons interfering, but you must re-enable anything the bake needs.&lt;/li&gt;
&lt;li&gt;Normal map conventions differ (OpenGL vs DirectX); check your target engine.&lt;/li&gt;
&lt;li&gt;Test on the Blender versions you support; behaviour around extensions changed in 4.2. (The steps above were run on Blender 4.2.23 LTS and 5.2.2 LTS in background mode.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article was written with AI assistance; the code steps were run and checked in Blender 4.2 and 5.2 before publishing.&lt;/p&gt;

</description>
      <category>blender</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
