Commit d9359c9a authored by Christopher Gearhart's avatar Christopher Gearhart

Now includes option for users to define 'Samples Per Job' for current frame renders

parent a1ad0fc6
......@@ -97,18 +97,24 @@ def register():
min=1, max=8,
default=1)
bpy.types.Scene.maxSamples = IntProperty(
name="Max Samples",
description="Maximum number of samples to render when rendering current frame",
min=100, max=9999,
default=750)
bpy.types.Scene.timeout = FloatProperty(
name="Timeout",
description="Time (in seconds) to wait for client servers to respond",
min=.001, max=1,
default=.01)
bpy.types.Scene.samplesPerFrame = IntProperty(
name="Samples Per Job",
description="Number of samples to render per job when rendering current frame",
min=10, max=999,
default=10)
bpy.types.Scene.maxSamples = IntProperty(
name="Max Samples",
description="Maximum number of samples to render when rendering current frame",
min=100, max=9999,
default=1000)
bpy.types.Scene.renderType = []
bpy.types.Scene.renderStatus = {"animation":"None", "image":"None"}
......
......@@ -231,11 +231,6 @@ class sendFrame(Operator):
elif self.state[i] == 2:
bpy.props.needsUpdating = False
jobsPerFrame = scn.maxSamples // self.sampleSize
if jobsPerFrame > 100:
self.report({"ERROR"}, "Max Samples / Samples > 100. Try increasing samples or lowering max samples.")
setRenderStatus("image", "ERROR")
self.cancel(context)
return{"CANCELLED"}
self.processes[i] = renderFrames(str([bpy.props.imFrame]), self.projectName, jobsPerFrame)
self.state[i] += 1
setRenderStatus("image", "Rendering...")
......@@ -327,14 +322,7 @@ class sendFrame(Operator):
bpy.props.imExtension = scn.render.file_extension
# Store current sample size for use in computing render results
if scn.cycles.progressive == "PATH":
self.sampleSize = scn.cycles.samples
if scn.cycles.use_square_samples:
self.sampleSize = self.sampleSize**2
else:
self.sampleSize = scn.cycles.aa_samples
if scn.cycles.use_square_samples:
self.sampleSize = self.sampleSize**2
self.sampleSize = scn.samplesPerFrame
# start initial render process
self.stdout = None
......
......@@ -124,6 +124,7 @@ def renderFrames(frameRange, projectName, jobsPerFrame=False):
if jobsPerFrame:
extraFlags += " -j {jobsPerFrame}".format(jobsPerFrame=jobsPerFrame)
extraFlags += " -s {numImSamples}".format(numImSamples=scn.samplesPerFrame)
# runs blender command to render given range from the remote server
renderCommand = "ssh -T -oStrictHostKeyChecking=no -x {login} 'python {remotePath}blender_task -v -p -n {projectName} -l {frameRange} --hosts_file {remotePath}servers.txt -R {remotePath} --connection_timeout {t} --max_server_load {maxServerLoad}{extraFlags}'".format(login=bpy.props.serverPrefs["login"], remotePath=bpy.props.serverPrefs["path"], projectName=projectName, frameRange=frameRange.replace(" ", ""), t=scn.timeout, maxServerLoad=str(scn.maxServerLoad), extraFlags=extraFlags)
......
......@@ -43,19 +43,10 @@ def jobIsValid(jobType, classObject):
jobValidityDict = {"valid":False, "errorType":"ERROR", "errorMessage":"RENDER FAILED: Output file format not supported. Supported formats: BMP, PNG, TARGA, JPEG, JPEG 2000, TIFF. (Animation only: IRIS, CINEON, HDR, DPX, OPEN_EXR, OPEN_EXR_MULTILAYER)"}
# verify that sampling is high enough to provide expected results
if not jobValidityDict and jobType == "image":
if scn.cycles.progressive == "PATH":
samples = scn.cycles.samples
if scn.cycles.use_square_samples:
samples = samples**2
if samples < 10:
jobValidityDict = {"valid":True, "errorType":"WARNING", "errorMessage":"RENDER ALERT: Render result may be inaccurate at {samples} samples. Try 10 or more samples for a more accurate render.".format(samples=str(samples))}
elif scn.cycles.progressive == "BRANCHED_PATH":
samples = scn.cycles.aa_samples
if scn.cycles.use_square_samples:
samples = samples**2
if samples < 5:
jobValidityDict = {"valid":True, "errorType":"WARNING", "errorMessage":"RENDER ALERT: Render result may be inaccurate at {samples} AA samples. Try 5 or more AA samples for a more accurate render.".format(samples=str(samples))}
if jobType == "image":
jobsPerFrame = scn.maxSamples // scn.samplesPerFrame
if jobsPerFrame > 100:
jobValidityDict = {"valid":False, "errorType":"ERROR", "errorMessage": "Max Samples / SamplesPerJob > 100. Try increasing samples per frame or lowering max samples."}
# verify that the user input for renderDumpLoc is valid and can be created
try:
......
......@@ -32,6 +32,6 @@ for scene in bpy.data.scenes:
scene.cycles.transparent_min_bounces = 0
scene.cycles.min_bounces = 0
scene.cycles.blur_glossy = 0
bpy.context.scene.render.use_overwrite = True
scene.render.use_overwrite = True
if scene.cycles.film_transparent:
scene.color_mode = 'RGBA'
......@@ -46,11 +46,12 @@ parser.add_argument("-i", "--hosts_file", action="store", default="remoteServers
parser.add_argument("-m", "--max_server_load", action="store", default=1, help="Max render processes to run on each server at a time.")
parser.add_argument("-a", "--average_results", action="store_true", default=None, help="Average frames when finished.")
parser.add_argument("-j", "--jobs_per_frame", action="store", default=False, help="Number of jobs to queue for each frame")
parser.add_argument("-s", "--samples", action="store", default=False, help="Number of samples to render per job")
parser.add_argument("-t", "--connection_timeout", action="store", default=.01, help="Pass a float for the timeout in seconds for telnet connections to client servers.")
# NOTE: this parameter is currently required
parser.add_argument("-n", "--project_name", action="store", default=False) # just project name. default path will be in /tmp/blenderProjects
# TODO: test this for directories other than toRemote
parser.add_argument("-s", "--local_sync", action="store", default="./toRemote", help="Pass a full or relative path to sync to the project directory on remote.")
parser.add_argument("-S", "--local_sync", action="store", default="./toRemote", help="Pass a full or relative path to sync to the project directory on remote.")
# NOTE: remote_results_path will sync the directory at results
parser.add_argument("-r", "--remote_results_path", action="store", default="results", help="Pass a path to the directory that should be synced back.")
# NOTE: passing the contents flag will sync back the contents from the directory given in remote_results_path
......@@ -179,8 +180,14 @@ def main():
os.mkdir(localResultsPath)
localResultsPath = os.path.join(localResultsPath, '.')
# Copy blender_p.py to project folder
subprocess.call("rsync -e 'ssh -oStrictHostKeyChecking=no' -a '{pyFilePathSource}' '{pyFilePathDest}'".format(pyFilePathSource=os.path.join(projectRoot, "blender_p.py"), pyFilePathDest=os.path.join(projectPath, "toRemote", "blender_p.py")), shell=True)
# Copy blender_p.py to project folder and append seed value if given
pyFilePathDest = os.path.join(projectPath, "toRemote", "blender_p.py")
subprocess.call("rsync -e 'ssh -oStrictHostKeyChecking=no' -a '{pyFilePathSource}' '{pyFilePathDest}'".format(pyFilePathSource=os.path.join(projectRoot, "blender_p.py"), pyFilePathDest=pyFilePathDest), shell=True)
if args.samples:
with open(pyFilePathDest, "a") as f:
f.write(" scene.cycles.progressive == 'PATH'\n")
f.write(" scn.cycles.use_square_samples == False\n")
f.write(" scene.cycles.samples = {samples}".format(samples=args.samples))
# Print frame range to be rendered
frames = json.loads(args.frame_range)
......
......@@ -140,6 +140,7 @@ class serversPanel(Panel):
col.label(text="Performance:")
col.prop(scn, "maxServerLoad")
col.prop(scn, "timeout")
col.prop(scn, "samplesPerFrame")
col.prop(scn, "maxSamples")
layout.separator()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment