20
20
"name": "Animated Render Baker",
21
21
"author": "Janne Karhu (jahka)",
23
"blender": (2, 65, 0),
24
24
"location": "Properties > Render > Bake Panel",
25
25
"description": "Renderbakes a series of frames",
26
26
"category": "Object",
27
'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
28
'Scripts/Object/Animated_Render_Baker',
29
'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
30
'func=detail&aid=24836'}
27
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
28
"Scripts/Object/Animated_Render_Baker",
29
"tracker_url": "https://projects.blender.org/tracker/index.php?"
30
"func=detail&aid=24836"}
33
from bpy.props import *
33
from bpy.props import IntProperty
35
35
class OBJECT_OT_animrenderbake(bpy.types.Operator):
36
36
bl_label = "Animated Render Bake"
92
97
self.report({'ERROR'}, "Save the image that's used for baking before use")
93
98
return {'CANCELLED'}
100
if img.packed_file is not None:
101
self.report({'ERROR'}, "Can't animation-bake packed file")
95
104
# make sure we have an absolute path so that copying works for sure
96
absp = bpy.path.abspath(img.filepath, library=img.library)
98
print("Animated baking for frames " + str(start) + " - " + str(end))
100
for cfra in range(start, end+1):
101
print("Baking frame " + str(cfra))
105
img_filepath_abs = bpy.path.abspath(img.filepath, library=img.library)
107
print("Animated baking for frames (%d - %d)" % (start, end))
109
for cfra in range(start, end + 1):
110
print("Baking frame %d" % cfra)
103
112
# update scene to new frame and bake to template image
104
113
scene.frame_set(cfra)
106
115
if 'CANCELLED' in ret:
107
116
return {'CANCELLED'}
109
#currently the api doesn't allow img.save_as(), so just save the template image as usual for every frame and copy to a file with frame specific filename
118
# Currently the api doesn't allow img.save_as()
119
# so just save the template image as usual for
120
# every frame and copy to a file with frame specific filename
111
shutil.copyfile(absp, self.framefile(absp, cfra))
122
img_filepath_new = self.framefile(img_filepath_abs, cfra)
123
shutil.copyfile(img_filepath_abs, img_filepath_new)
124
print("Saved %r" % img_filepath_new)
113
print("Saved " + self.framefile(absp, cfra))
114
126
print("Baking done!")
116
128
return{'FINISHED'}
118
# modified copy of original bake panel draw function
119
def draw_animrenderbake(self, context):
131
def draw(self, context):
120
132
layout = self.layout
122
rd = context.scene.render
134
scene = context.scene
124
136
row = layout.row()
125
row.operator("object.bake_image", icon='RENDER_STILL')
127
#----------- beginning of modifications ----------------
128
137
row.operator("object.anim_bake_image", text="Animated Bake", icon="RENDER_ANIMATION")
129
row = layout.row(align=True)
130
row.prop(context.scene, "animrenderbake_start")
131
row.prop(context.scene, "animrenderbake_end")
132
#-------------- end of modifications ---------------------
134
layout.prop(rd, "bake_type")
136
multires_bake = False
137
if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
138
layout.prop(rd, 'use_bake_multires')
139
multires_bake = rd.use_bake_multires
141
if not multires_bake:
142
if rd.bake_type == 'NORMALS':
143
layout.prop(rd, "bake_normal_space")
144
elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
145
layout.prop(rd, "use_bake_normalize")
147
# col.prop(rd, "bake_aa_mode")
148
# col.prop(rd, "use_bake_antialiasing")
152
split = layout.split()
155
col.prop(rd, "use_bake_clear")
156
col.prop(rd, "bake_margin")
157
col.prop(rd, "bake_quad_split", text="Split")
160
col.prop(rd, "use_bake_selected_to_active")
162
sub.active = rd.use_bake_selected_to_active
163
sub.prop(rd, "bake_distance")
164
sub.prop(rd, "bake_bias")
166
if rd.bake_type == 'DISPLACEMENT':
167
layout.prop(rd, "use_bake_lores_mesh")
169
layout.prop(rd, "use_bake_clear")
170
layout.prop(rd, "bake_margin")
138
rowsub = row.row(align=True)
139
rowsub.prop(scene, "animrenderbake_start")
140
rowsub.prop(scene, "animrenderbake_end")
173
144
bpy.utils.register_module(__name__)
175
146
bpy.types.Scene.animrenderbake_start = IntProperty(
177
description="Start frame of the animated bake",
148
description="Start frame of the animated bake",
180
151
bpy.types.Scene.animrenderbake_end = IntProperty(
182
description="End frame of the animated bake",
185
# replace original panel draw function with modified one
186
panel = bpy.types.RENDER_PT_bake
187
panel.old_draw = panel.draw
188
panel.draw = draw_animrenderbake
153
description="End frame of the animated bake",
156
bpy.types.RENDER_PT_bake.prepend(draw)
190
159
def unregister():
191
160
bpy.utils.unregister_module(__name__)
193
162
# restore original panel draw function
194
bpy.types.RENDER_PT_bake.draw = bpy.types.RENDER_PT_bake.old_draw
195
del bpy.types.RENDER_PT_bake.old_draw
196
163
del bpy.types.Scene.animrenderbake_start
197
164
del bpy.types.Scene.animrenderbake_end
166
bpy.types.RENDER_PT_bake.remove(draw)
199
169
if __name__ == "__main__":