1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
23 for m
in bpy
.data
.materials
:
24 if m
.subsurface_scattering
.use
:
29 for p
in bpy
.data
.particles
:
30 if (p
.type == 'EMITTER'):
31 bpy
.particleBakeWarning
= True
32 if (p
.type == 'HAIR'):
33 if (p
.child_type
== 'SIMPLE'):
34 p
.child_type
= 'INTERPOLATED'
35 bpy
.childParticleWarning
= True
37 def hasParticleSystem():
38 if (len(bpy
.data
.particles
) > 0):
39 print("Found particle system")
44 for o
in bpy
.data
.objects
:
47 print("Found simulation: " + str(t
))
51 def hasFluidSimulation():
52 return hasSimulation(bpy
.types
.FluidSimulationModifier
)
54 def hasSmokeSimulation():
55 return hasSimulation(bpy
.types
.SmokeModifier
)
57 def hasClothSimulation():
58 return hasSimulation(bpy
.types
.ClothModifier
)
60 def hasCollisionSimulation():
61 return hasSimulation(bpy
.types
.CollisionModifier
)
63 def hasSoftbodySimulation():
64 return hasSimulation(bpy
.types
.SoftBodyModifier
)
66 def hasUnsupportedSimulation():
67 return hasSoftbodySimulation() or hasCollisionSimulation() or hasClothSimulation() or hasSmokeSimulation() or hasFluidSimulation()
69 def isFilterNode(node
):
71 return t
==bpy
.types
.CompositorNodeBlur
or t
==bpy
.types
.CompositorNodeDBlur
75 sce
= bpy
.context
.scene
79 # Necessary settings for BURP
80 rd
.resolution_x
= ore
.resox
81 rd
.resolution_y
= ore
.resoy
82 sce
.frame_start
= ore
.start
83 sce
.frame_end
= ore
.end
86 bpy
.file_format_warning
= False
87 bpy
.simulationWarning
= False
88 bpy
.texturePackError
= False
89 bpy
.particleBakeWarning
= False
90 bpy
.childParticleWarning
= False
92 if (rd
.image_settings
.file_format
== 'HDR'):
93 rd
.image_settings
.file_format
= 'PNG'
94 bpy
.file_format_warning
= True
96 # Convert between Blender's image format and BURP's formats
97 if (rd
.image_settings
.file_format
== 'PNG'):
98 ore
.file_format
= 'PNG_FORMAT'
99 elif (rd
.image_settings
.file_format
== 'OPEN_EXR'):
100 ore
.file_format
= 'EXR_FORMAT'
101 elif (rd
.image_settings
.file_format
== 'OPEN_EXR_MULTILAYER'):
102 ore
.file_format
= 'EXR_MULTILAYER_FORMAT'
103 elif (rd
.image_settings
.file_format
== 'HDR'):
104 ore
.file_format
= 'PNG_FORMAT'
106 ore
.file_format
= 'PNG_FORMAT'
108 if (ore
.engine
== 'cycles'):
109 bpy
.context
.scene
.cycles
.samples
= ore
.samples
111 if (ore
.subsamples
<= 0):
114 if (ore
.samples
/ ore
.subsamples
< 100.0):
115 ore
.subsamples
= float(ore
.samples
) / 100.0
117 # Multipart support doesn' work if SSS is used
118 if ((rd
.use_sss
== True and hasSSSMaterial()) and ore
.parts
> 1):
121 if (hasParticleSystem()):
124 bpy
.particleBakeWarning
= False
125 bpy
.childParticleWarning
= False
127 if (hasUnsupportedSimulation()):
128 bpy
.simulationWarning
= True
130 bpy
.simulationWarning
= False
132 def _prepare_scene():
135 print("Packing external textures...")
137 bpy
.ops
.file.pack_all()
138 bpy
.texturePackError
= False
139 except Exception as e
:
140 bpy
.texturePackError
= True
143 linkedData
= bpy
.utils
.blend_paths()
144 if (len(linkedData
) > 0):
145 print("Appending linked .blend files...")
147 bpy
.ops
.object.make_local(type='ALL')
148 bpy
.linkedFileError
= False
149 except Exception as e
:
150 bpy
.linkedFileError
= True
153 print("No external .blends used, skipping...")
155 # Save with a different name
156 print("Saving into a new file...")
158 bpy
.originalFileName
= bpy
.data
.filepath
160 bpy
.originalFileName
= 'untitled.blend'
161 print("Original path is " + bpy
.originalFileName
)
163 # If the filename is empty, we'll make one from the path of the user's resource folder
164 if (len(bpy
.originalFileName
) == 0):
165 print("No existing file path found, saving to autosave directory")
166 savePath
= bpy
.utils
.user_resource("AUTOSAVE")
169 except Exception as ex
:
172 savePath
= savePath
+ "_renderfarm"
173 except Exception as ex
:
176 bpy
.ops
.wm
.save_mainfile(filepath
=savePath
)
177 except Exception as ex
:
180 print("Saving to current .blend directory")
181 savePath
= bpy
.originalFileName
182 savePath
= savePath
+ "_renderfarm.blend"
183 bpy
.ops
.wm
.save_mainfile(filepath
=savePath
)
184 except Exception as e
:
187 print(".blend prepared")