3
$\begingroup$

I am sending my .blends to another remote machine for rendering, and then I render them using command-line. Sometimes, the size of the .blends become as high as 100s of MBs. If I need to adjust only the no. of samples to be used for rendering, I need to upload the whole file again, which I don't want to do.

$\endgroup$
6
  • 1
    $\begingroup$ You can find the list of all arguments here: Command Line Arguments and there is nothing for setting the samples. So I don't think it's possible, I'm afraid. $\endgroup$ Commented Mar 7, 2022 at 7:56
  • 1
    $\begingroup$ of course you could do it by starting a script, which sets the sample it gets from the command line and then render that out $\endgroup$
    – Chris
    Commented Mar 7, 2022 at 10:08
  • $\begingroup$ @Chris But with which command line argument do you give the samples to the script? $\endgroup$ Commented Mar 7, 2022 at 10:12
  • 1
    $\begingroup$ like this: blender.stackexchange.com/questions/6817/… $\endgroup$
    – Chris
    Commented Mar 7, 2022 at 10:13
  • 1
    $\begingroup$ @Chris Maybe you could evaluate that as an answer... from which I read there I don't understand how to create a script changing the samples of a file on a remote machine. $\endgroup$ Commented Mar 7, 2022 at 10:19

1 Answer 1

5
$\begingroup$

There are several ways you can accomplish this. Probably the easiest is to have your command line include a python expression for Blender to execute. If you look at the manual entry for Command Line Arguments you will find

--python-expr <expression>

Run the given expression as a Python script.

Assuming that your scene's name hasn't changed, the expression you want is

import bpy
bpy.data.scenes["Scene"].cycles.samples = VALUE

replacing VALUE with the number you want. So your command line needs to look something like

PATH_TO_/blender.exe BLENDER_FILE.blend --python-expr "import bpy ; bpy.data.scenes[\"Scene\"].cycles.samples = VALUE"

Notice that the expression has to fit on one line, so I used a semicolon (;) to separate the import statement from the assignment.

Notice also that the expression contains spaces so I had to enclose it in double quotes and then use backslash to escape the double quotes used in the assignment statement. You may have to adjust this depending on the command line shell that you're using on the remote machine.

One thing to be aware of. The meaning of cycles.samples changed between 2.9x and 3.x because of the introduction of Cycles X. Prior to 3.0 it meant the actual number of samples. Since 3.0 it means the maximum number of samples. In Cycles X, Blender will stop sampling when the Noise threshold is reached. You may want to consider leaving samples alone and changing cycles.adaptive_threshold instead if you're using 3+.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .