[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3464] trunk/py/scripts/tools/bi_farm: add blender initialization script
Campbell Barton
ideasman42 at gmail.com
Wed Jun 6 09:52:18 CEST 2012
Revision: 3464
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3464
Author: campbellbarton
Date: 2012-06-06 07:52:16 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
add blender initialization script
Modified Paths:
--------------
trunk/py/scripts/tools/bi_farm/master_avi_gen.py
trunk/py/scripts/tools/bi_farm/new_node_update_frames.sh
Added Paths:
-----------
trunk/py/scripts/tools/bi_farm/new_blender_setup.py
Modified: trunk/py/scripts/tools/bi_farm/master_avi_gen.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/master_avi_gen.py 2012-06-06 07:44:05 UTC (rev 3463)
+++ trunk/py/scripts/tools/bi_farm/master_avi_gen.py 2012-06-06 07:52:16 UTC (rev 3464)
@@ -1,3 +1,25 @@
+#!/shared/software/python/bin/python3.2
+
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8-80 compliant>
+
# runs on a node, generates avis, last arg is dir full of exrs
import os
Added: trunk/py/scripts/tools/bi_farm/new_blender_setup.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/new_blender_setup.py (rev 0)
+++ trunk/py/scripts/tools/bi_farm/new_blender_setup.py 2012-06-06 07:52:16 UTC (rev 3464)
@@ -0,0 +1,192 @@
+# runs on the nodes inside blender
+
+import bpy
+import os
+import sys
+import math
+import base64
+
+#try:
+# import finals_config
+#except:
+# print("finals_config not found")
+# sys.exit(1)
+
+output_fpath = sys.argv[-4]
+render_frame = int(sys.argv[-3])
+quality = sys.argv[-2] + " " + sys.argv[-1]
+print(quality)
+
+
+def get_ip():
+
+ import socket
+ import fcntl
+ import struct
+
+ def get_ip_address(ifname):
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915, # SIOCGIFADDR
+ struct.pack('256s', ifname[:15].encode('ascii'))
+ )[20:24])
+
+ for iface in "eth0", "eth1", "eth2", "eth3", "eth0_rename":
+ try:
+ ip = get_ip_address(iface)
+ break
+ except:
+ ip = socket.gethostname()
+
+ return ip
+
+
+def get_revision():
+ '''returns the revision of this blendfile'''
+ import subprocess
+ lines = subprocess.Popen(["svn", "info", bpy.data.filepath], stdout=subprocess.PIPE).communicate()[0].splitlines()
+ rev = b""
+ for l in lines:
+ if l.startswith(b'Revision: '):
+ rev = l.split()[-1]
+
+ if rev:
+ return int(rev)
+ else:
+ return -1
+
+def main():
+
+ ip = get_ip()
+ fpath = bpy.data.filepath
+ fname = os.path.splitext(os.path.basename(fpath))[0]
+ output_fname = os.path.splitext(os.path.basename(output_fpath))[0]
+ scene_current = bpy.context.scene
+ tmpdir = "/tmp/mango_farm" + str(render_frame)
+
+ print("loaded:", fpath, scene_current)
+
+ # not working
+ os.system("rm -rf %s" % tmpdir)
+ os.system("mkdir %s" % tmpdir)
+ bpy.context.user_preferences.filepaths.temporary_directory = tmpdir
+
+ #bpy.context.user_preferences.system.image_tile_memory_limit = 256
+ print("Setting up all scenes")
+ for scene in bpy.data.scenes:
+ rd = scene.render
+
+ # file output
+ rd.image_settings.file_format = 'OPEN_EXR'
+ rd.image_settings.color_depth = '16'
+ rd.image_settings.use_preview = True
+ rd.filepath = "/render/mango/frames/%s/%s_######" % (output_fname, fname)
+ rd.use_file_extension = True
+ rd.use_placeholder = False
+ rd.use_overwrite = False
+ rd.use_free_unused_nodes = True
+
+ rd.use_stamp_note = True
+ rd.use_stamp_render_time = True
+ rd.stamp_note_text = "rev:%s, art_rev:%s, %s" % (bpy.app.build_revision, str(get_revision()), ip)
+
+ # stamp
+ if quality != "File settings":
+ rd.use_stamp = False
+ rd.stamp_font_size = 18
+ rd.stamp_foreground = 1.0, 1.0, 1.0, 1.0
+ rd.stamp_background = 0.0, 0.0, 0.0, 0.75
+
+ # performance/memory
+ rd.use_free_image_textures = True
+ rd.use_save_buffers = True
+ # XXX fixed for now because it gives different results for hair
+ # rd.threads_mode = 'AUTO'
+ rd.threads_mode = 'FIXED'
+ if ip in ("192.168.4.75", "192.168.4.76"):
+ rd.threads = 4
+ else:
+ rd.threads = 8
+
+ if ip == "192.168.3.190":
+ scene.cycles.device = 'GPU'
+
+ print("rendering using %d threads" % (rd.threads))
+ rd.use_local_coords = False
+ if rd.parts_x < 32: rd.parts_x = 32
+ if rd.parts_y < 16: rd.parts_y = 16
+ rd.raytrace_method = 'AUTO'
+
+ # resolution
+ if quality != "File settings":
+ rd.resolution_x = 2048
+ rd.resolution_y = 1080
+
+ rd.resolution_percentage = 100
+ rd.use_border = False
+ rd.image_settings.color_mode = 'RGB'
+ rd.use_simplify = False
+
+ # quality
+ if quality == "Preview 1K":
+ rd.resolution_percentage = 50
+
+ rd.use_simplify = True
+ rd.simplify_subdivision = 0
+ rd.simplify_child_particles = 1.0
+ rd.simplify_shadow_buffer_samples = 1
+ rd.simplify_shadow_buffer_size = 512
+ rd.simplify_ao_sss = 0.2
+ #if scene.world:
+ # scene.world.lighting.use_cache = False
+ # scene.world.lighting.samples = 1
+ elif quality == "NoShading 1K":
+ rd.resolution_percentage = 50
+
+ rd.use_textures = False
+ rd.use_raytracing = False
+ rd.use_sss = False
+ rd.use_shadows = False
+ elif quality == "Simplified 1K":
+ rd.resolution_percentage = 50
+
+ rd.use_textures = True
+ rd.use_raytracing = False
+ rd.use_sss = False
+ rd.use_shadows = False
+
+ rd.use_simplify = True
+ rd.simplify_subdivision = 0
+ rd.simplify_child_particles = 0.1
+ #rd.simplify_mipmap_levels = 5
+ elif quality == "Final 4K":
+ # is this resolution right?
+ rd.resolution_percentage = 200
+ elif quality == "Final 1K":
+ rd.resolution_percentage = 50
+ elif quality == "Final 0.5K":
+ rd.resolution_percentage = 25
+ elif quality == "Final HD":
+ rd.resolution_percentage = 100
+ rd.resolution_x = 1920
+ rd.resolution_y = 1080
+ scene.frame_start = render_frame
+ scene.frame_end = render_frame
+
+ print("rendering frame %d" % (render_frame))
+
+ # TODO, 02.f.blend has this bug!
+ # scene_current.frame_set(scene_current.frame_current)
+
+ for sce_iter in bpy.data.scenes:
+ sce_iter.frame_set(scene_current.frame_current)
+
+
+ # TODO, some valid file test would be nice.
+ if not fpath.startswith("<memory"):
+ bpy.ops.render.render(animation=True)
+
+
+if __name__ == "__main__":
+ main()
Property changes on: trunk/py/scripts/tools/bi_farm/new_blender_setup.py
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/py/scripts/tools/bi_farm/new_node_update_frames.sh
===================================================================
--- trunk/py/scripts/tools/bi_farm/new_node_update_frames.sh 2012-06-06 07:44:05 UTC (rev 3463)
+++ trunk/py/scripts/tools/bi_farm/new_node_update_frames.sh 2012-06-06 07:52:16 UTC (rev 3464)
@@ -26,8 +26,9 @@
for FRAME in $*
do
# -a doesnt work. TODO, find out why, render with operator until then.
-$FARM_DIR/new_node_command.sh nice -n 19 $FARM_DIR/blender_farm.sh -b -noaudio $BLEND -P $FARM_DIR/new_blender_setup.py -- $OUTPUT_BLEND $FRAME $QUALITY &
-#$FARM_DIR/new_node_command.sh nice -n 19 $FARM_DIR/blender_farm.sh -noaudio $BLEND -P $FARM_DIR/new_blender_setup.py -- $OUTPUT_BLEND $FRAME $QUALITY &
+$FARM_DIR/new_node_command.sh nice -n 19 $FARM_DIR/blender_farm.sh --background -noaudio $BLEND --python $FARM_DIR/new_blender_setup.py -- $OUTPUT_BLEND $FRAME $QUALITY &
+# no background for testing...
+# $FARM_DIR/new_node_command.sh nice -n 19 $FARM_DIR/blender_farm.sh -noaudio $BLEND --python $FARM_DIR/new_blender_setup.py -- $OUTPUT_BLEND $FRAME $QUALITY &
done
wait
More information about the Bf-extensions-cvs
mailing list