Speeding up baking for the same shape (but different texture with the same size)

Hi! I’m wondering that once texture is baked for a given shape, any following baking for the same shape (but with different input texture (with the same size for the sake im simplicity)) should be possible to optimize. Also for the sake of simplicity let’s skip lighting or complex material, let’s assume that baking output is exact same (on color level) as input texture. Do you have any ideas for optimizations or experience with such use case? Ultimately I’m considering baking texture first time with blender, and then using some lighting fast solution omitting bledner itself (with pure python script for example). What do you think?

baking is in Cycles, handled via C++. Using python, you could alter the settings of a bake, but you’re not going to make the baking operations faster that way. What you can do is find different bake operations that go faster, such as baking emit instead of something else in which case you only need 1 sample. So baking individual PBR maps can be faster if you can bake it that way. Note: normals, AO, and others that rely on the geometry will not bake that way.

1 Like

Ttechnically, yes, but practically, the kind of baking that can be optimized is so fast that it’s not worth the trouble of setting up some kind of barely optimized pipeline.

If you have two identical objects, baking, for example, a diffuse color from one set of idientical UVs to a different set of identical UVs, you could just bake your old UV coordinates onto your new UV coordinates and then bake each texture using a plane with a special material, that looked up coordinates on a texture to look up a texture… And it’s hard to beat the transformation time for four verts…

But you’d need to have to do that a few hundred times to make that optimization worth it. And baking diffuse color only from one uv to another can usually be done with 1 sample, no bounces, and copy/pasted into a separate Blender process if you don’t want to hide the rest of your geometry to prevent it from getting evaluated. Shouldn’t take long at all.

@bandages For input texture I use images with high resoulution (6912x3456) for a quite simple shape and baking (1 sample) takes about 15 seconds on my pretty old desktop (12GB RAM, i5 750 2.6 Ghz, graphic card is not important, in the end I plan to use relatively cheap cloud VM with no decent graphic card). In your opinion it’s relatively good time that it takes, or is there any setting which could drastically speed up the process? I tried to tune up it already (with the number of samples), but maybe I missed something imaportant?

15 secs isn’t bad. That seems reasonable. I’ve never paid attention to times in that range. 100 times 15 seconds is 20 mins, less than you’d save with optimizations minus time to set up optimizations.

But also, drop bounce count if you don’t need them. Blender isn’t smart enough to pay attention to whether something actually needs to bounce. (Like a diffuse color bake, or an emit shader.)

1 Like

@bandages Thanks, if 15s is reasonable for this sort of operation, then it’s fine.