Related to this: Baking textures on headless machine (batch baking)
Is there a way to batch the baking of textures over all frames? I have an animation and since the light is changing at each frame, would like to bake out the texture of each frame into an image sequence.
- I've set my render mode to cycles
- I've added a Image Texture Node and have it set to image sequence
- My UV is unwrapped to the image sequence
If I put this in console, I can bake one frame to the sequence:
bpy.data.objects["Cube"].select = True
bpy.context.scene.frame_current = 1
bpy.ops.object.bake(type='COMBINED')
Similarly, I can bake another frame:
bpy.data.objects["Cube"].select = True
bpy.context.scene.frame_current = 2
bpy.ops.object.bake(type='COMBINED')
However, when I try to put this in a for loop to bake multiple frames like this:
for i in range(1,30):
bpy.context.scene.frame_current = i
bpy.data.objects["Cube"].select = True
bpy.ops.object.bake(type='COMBINED')
It will only bake the texture of the first frame in the loop. It appears like it is looping through all the frames and it is baking them, but the images in those frames do not get updated once the script is finished. Any ideas on what is happening?