Trying to bake in Blender Internal to achieve equirectangular rendering with Blender Internal.
this is the code:
import bpy
# remember current frame to switch back after the script is finished
current_frame = bpy.context.scene.frame_current
mesh = bpy.context.scene.objects.active.data
for i in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end+1):
# set current frame
bpy.context.scene.frame_current = i
# create an image which will store the baked data
image = bpy.data.images.new(str(i)+'.png', bpy.context.scene.render.resolution_x, bpy.context.scene.render.resolution_y, alpha = 0)
image.file_format = 'PNG'
image.filepath = "//"+str(i)+".png"
#image.save()
#set the active image for each uv:
for uvface in mesh.uv_textures.active.data:
uvface.image = image
# set texture as active for the material
# add texture (slot) if missing
if mesh.materials[0].texture_slots[0] == None:
mesh.materials[0].texture_slots.add()
mesh.materials[0].texture_slots[0].texture = bpy.data.textures.new(str(i), type = 'IMAGE')
mesh.materials[0].texture_slots[0].texture.image = image
mesh.materials[0].active_texture = mesh.materials[0].texture_slots[0].texture
# bake
bpy.ops.object.bake(type='COMBINED')
# resave image with baked data
image.save()
print ("Frame "+str(i)+" complete")
# switch back to the frame you were on before running this code
bpy.context.scene.frame_current = current_frame
This is the blend file: http://www.pasteall.org/blend/37804
THis is the error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\internal.blend\Text", line 30, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.75\scripts\modules\bpy\ops
.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: No active image found in material "Material.002" (0) for ob
ject "Sphere"