Author Topic: Change render passes with Command line rendering  (Read 2896 times)

2020-06-01, 19:25:24

grasshopper

  • Active Users
  • **
  • Posts: 20
    • View Profile
I have recently been playing with submitting jobs through command line and am now trying to create custom bat file to control my renders.

Is there any way to change the pass limit or noise threshold limit or indeed any on the corona settings whist submitting through command line?

Sorry I forgot to note 3dsMax 2018 & Corona 5

Thanks
G
« Last Edit: 2020-06-01, 22:27:53 by grasshopper »

2020-06-02, 11:48:43
Reply #1

Frood

  • Active Users
  • **
  • Posts: 1932
    • View Profile
    • Rakete GmbH
Have not tried it but you obviously can use the switch "-preRenderScript <filename>". Then for example as "myScript.ms":

renderers.current.progressive_passLimit = 120

Same for every other renderer property.


Good Luck



Never underestimate the power of a well placed level one spell.

2020-06-02, 16:11:08
Reply #2

grasshopper

  • Active Users
  • **
  • Posts: 20
    • View Profile
Thanks Frood, I am not an experienced coder so didn't know about that. I'll add a prescript as you have shown and try and get it working. I had reverted to loading a render preset but that isn't ideal as has a lot of changeable values and would need a separate file for every alternative. (and they are encoded so can't be edited ina txt editor)

Is there reference anywhere to other script commands for corona settings?
Also can you run more than one prescript from each bat file?

Thanks again you have opened up a new avenue for investigation.

2020-06-02, 17:49:36
Reply #3

Frood

  • Active Users
  • **
  • Posts: 1932
    • View Profile
    • Rakete GmbH
Is there reference anywhere to other script commands for corona settings?

Hmm, usually those are enough:

1. https://forum.corona-renderer.com/index.php?topic=28201.msg166040#msg166040 ("Corona listener" and "show renderers.current")
2. https://corona-renderer.com/wiki/maxscript

Also can you run more than one prescript from each bat file?

Never used command line rendering (iirc that is - what a shame :) but I presume it works just like having a script in Render Setup -> Common -> Scripts -> Pre-Render. I don't have "the" script there but a "script_root" which reads all subsequent scripts that we need using the maxscript "fileIn" command. Quoting:

Code: [Select]
scripts_dir="\\\\path\\to\\central\\scripts\\directory\\scripts_Max2020"
logsystem.logEntry(" * Processing prerender root (production).") info:true

-- Disable CoronaVFB Regions when getting a network/BB job:
try (
fileIn (scripts_dir+"\\Prerender_CoronaVFB_RegionCheck.ms") quiet:true
)
catch()

-- Log EXR settings:
try (
fileIn (scripts_dir+"\\Prerender_EXR_Settings.ms") quiet:true
)
catch()

-- Beauty (jpg) copy with logo overlay:
try (
fileIn (scripts_dir+"\\Prerender_ImageOverlay.ms") quiet:true
)
catch()

-- Corona Dr Information and automatic removal of a master from slave list:
try (
fileIn (scripts_dir+"\\Prerender_Corona_DR_Info.ms") quiet:true
)
catch()

-- Corona Custom Renderstamp (CCR):
try (
fileIn (scripts_dir+"\\CoronaCustomRenderstamp.ms") quiet:true
)
catch()

-- Log Corona renderstats
try (
fileIn (scripts_dir+"\\Postrender_ListCoronaRenderStats.ms") quiet:true
)
catch()

--- And more...


So you are free to load as may scripts as you like. But if you want to do something like "rendermystuff.cmd scene_A.max -passes 120" you would most probably have to create the pre-render script on the fly in the batch and invoke max commandline rendering in a second step using it. Maybe just tell what's on your mind.

a new avenue for investigation.

Without question, yes ;]


Good Luck



Never underestimate the power of a well placed level one spell.

2020-06-02, 18:32:31
Reply #4

grasshopper

  • Active Users
  • **
  • Posts: 20
    • View Profile
Thanks again Frood,

As I said I was sending render by command line through batch script but the process is growing arms and legs now a colleague of mine has got involved and he is familiar with unity and is putting together a UI allowing me to submit jobs and change some options. His interface will basically output a batch file which I can run to send jobs to render without opening them. My colleague isn't familiar with corona or maxscript so trying to work out what changes we can make to render settings. Pass limit was a must but prior to your response I could only change it through render presets which is ideal. To add noise thresholds, changing from still frame to animation and changing post\lightmix setting would be a few other useful settings. The script by Phasma that you pointed to in one of your posts looks very useful but it's going to take me a while to digest all of this and investigate further.

Thanks again for your insight, I fear you may not of heard the last of me on this subject. :)

2020-06-03, 16:58:24
Reply #5

Frood

  • Active Users
  • **
  • Posts: 1932
    • View Profile
    • Rakete GmbH
So basically you are creating a kind of GUI for 3dsmaxcmd.exe with integrated renderer properties script creation for Corona. Problem remains here, that you cannot access the max file settings. You will always just "blindly" set parameters without knowing their current state in the scene or if they are required to be changed at all. But let's see :]


Good Luck



Never underestimate the power of a well placed level one spell.

2020-06-11, 14:36:34
Reply #6

grasshopper

  • Active Users
  • **
  • Posts: 20
    • View Profile
Thats right Frood, So I am thinking it will be more of a Settings override system. We are working remotely atm as we are isolated. So we set up scenes as we need them locally, sync all scenes back to the office and then am looking for a way to send renders to the farm with the option to change useful settings without having to re-open the files. It's something that might be relevant to a lot of people at the moment.

As you mentioned we are not able to access the max file settings and simply change the existing settings so it relies on knowledge of the scene being rendered but I think it still justifies being a worth while exercise.

One issue I notice when sending to backburner using commandline is that without specifying the camera (and the only way is knowing the camera by name) it is always perspective of ortho even if the camera is specified correctly in the saved file. I can send suspeded and change the view in backburner but it would be great to have a solution for that.

I managed to write a script (very pleased with myself even if it is simple) and it analyses the open scene and outputs a txt list of the cameras in a specified location. The Unity guy can use that list to produce a camera selection drop down.

Cams = for Cam in cameras where (superclassof Cam == camera) collect Cam
if Cams.count > 0 then
out_file = createfile ("C:\\temp\TestCams.txt")
for Cam in Cams do format "%\n" Cam.name to:out_file
close out_file

Any idea how I can I pre run this script prior to sending the render (get camera list button) without opening the max file?

2020-06-15, 20:27:42
Reply #7

Frood

  • Active Users
  • **
  • Posts: 1932
    • View Profile
    • Rakete GmbH
No idea to run that maxscript without running any max of course :) You could use a COM session and run a script, or then even use a COM interface to get the cameras (there is one), but it would also spawn a max as COM server, but you want a lightweight solution of course.

There is a straight, dirty option to extract the cam names from a max file without having to load the entire file at first. Max uses structured storage as file format, in short: different streams in one file. One stream is the DocumentSummaryInformation, basically the stuff you can see in File Properties -> Contents. All you need to do is to load that small stream and search for the cams. Here is a basic python example using the "olefile" package:

Code: [Select]
#get the olefile package with "pip install olefile" first
import olefile
from sys import argv

if len(argv)<2:
print "Please specify a max file"
quit()

ole=olefile.OleFileIO(argv[1])
data=ole.openstream('\x05DocumentSummaryInformation').read()

i=0
camlist=[]
while data.find('Render Camera '+'{:02d}'.format(i))>0:
camlist.append(data[data.find('Render Camera '+'{:02d}'.format(i))+17:data.find('\x00',data.find('Render Camera '+'{:02d}'.format(i)))])
i+=1
ole.close()
print camlist

The example just searches for "Render Camera X" as a string until the next terminator (\x00) with incrementing X until it finds no more cams and stores the result in an array.

Example output:
Code: [Select]
C:\Python27>python c:\temp\ListCams.py c:\temp\temp.max
['CoronaCamera002', 'PhysCamera001_with_Spaces_and_a_Long Name#']

The package equivalent for C# to access streams in such files (assuming your mate uses C#) for example would be https://sourceforge.net/projects/openmcdf/ it seems.


Edit: And it should be possible to do this with .net as well :)


Good Luck





« Last Edit: 2020-06-15, 20:48:10 by Frood »
Never underestimate the power of a well placed level one spell.