AWS Thinkbox Discussion Forums

Vray lightcache prerender?

As Edwin suggested, the current SMTD does not have this built in yet, but you could script your own submitter UI based on the SMTD functions and settings. In fact, you could pretty much use the SMTD UI for everything, and write a simple MacroScript that sets up the lighting pass, calls the submit function of the SMTD UI, then sets up the dependent render pass, and submits that too.

If you want to discuss the details, please let me know.

Hi Bobo,

Yes, I would love the details on how to get that lighting pass working.

Thanks!

Heh. I’m curious too Bobo! :smiley:

Ok, here is a very basic implementation of the steps outlined in the original request:

(--start local scope
	
--If SMTD has not been opened yet, or has been closed since the start of 3ds Max, launch its UI:
if SMTD_MainRollout == undefined or not SMTD_MainRollout.open do macros.run "Deadline" "SubmitMaxToDeadline" 

local theRenderer = renderers.current					--get the current renderer
if isKindOf theRenderer VRay do							--if it is VRay, we are good to go
(
	--Render final image is disabled, light cache is set to render in the output dir
	local oldRenderDialogState = renderSceneDialog.isopen()		--see if the render dialog was open
	renderSceneDialog.close()								--close it before submission
	rendSaveFile = false										--disable output file saving
	theRenderer.options_dontRenderImage = true			--disable the rendering
	local lcpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + ".vrlmap"	--build the LC path name
	theRenderer.lightcache_autoSave = true					--enable LC auto-save 
	theRenderer.lightcache_autoSaveFileName = lcpath			--and set the file name to the cache path
	
	--Job sends to deadline
	SMTDSettings.PreviousJobsArray = #() 					--clear the dependencies list
	SMTDSettings.SubmitAsDependent = false 					--disable dependencies for first job submission

	SMTD_MainRollout.getNameFromMaxScene()				--update the job name in the UI
	local oldJobName = SMTDSettings.JobName 				--store the current job name
	SMTDSettings.JobName = oldJobName+" [VRay LC]"			--set the LC job's name
	local batchName = oldJobName + " [VRay LC + Render]"		--a batch name to combine the two jobs
	SMTDFunctions.SubmitJobFromUI batchName:batchName		--submit the job to Deadline as part of the batch

	--Render final image is enabled, lc is switched to "from file" and uses the precalced light cache 
	rendSaveFile = true									--re-enable output file saving
	theRenderer.options_dontRenderImage = false				--re-enable rendering 
	theRenderer.lightcache_autoSave = false					--disable the auto save mode
	local old_lightcache_mode = theRenderer.lightcache_mode	--store the old mode
	theRenderer.lightcache_mode = 2						--set LC mode to From File
	theRenderer.lightcache_loadFileName = lcpath				--set the load file to the cached path from the previous submission

	--Job sends to deadline with the first as a dependency.
	SMTDSettings.SubmitAsDependent = true					--enable dependencies
	SMTDSettings.DependencyJobItems = #{1}					--set the dependency on the first entry from the list
	SMTDSettings.DependOnPreviousJobMode = #last			--set the mode to last, so only the last job is concidered
	SMTDSettings.JobName = oldJobName+" [VRay Render]"		--set the job name
	SMTDFunctions.SubmitJobFromUI batchName:batchName		--submit to Deadline as part of the same batch

	SMTDSettings.JobName = oldJobName					--restore the job name
	SMTDSettings.SubmitAsDependent = false					--disable dependencies
	SMTDSettings.DependencyJobItems = #{}					--and clear the dependency jobs bitarray flags
	theRenderer.lightcache_mode	= old_lightcache_mode 		--restore the old cache mode
	
	if oldRenderDialogState do renderSceneDialog.open() 		--reopen the render dialog if needed
)--end if
)--end local scope

Some notes:

  • I assumed Deadline 9 here. The call for opening Deadline 8’s SMTD is
macros.run "Deadline" "SubmitMaxToDeadline8"
  • Currently it assumes that the 3ds Max render output filename is being used. It uses it to build the LC name, and to save the image. If the VRay VFB is to be used, it would require some modifications.
  • All current settings of SMTD are being used (pools, groups, priority etc.). However, the multi-job submission options will be skipped - these include Stereo Camera submission, Batch Job submission, and State Sets submission. It would be possible to respect those, but I would need to modify the code a bit.
  • The automatic Sanity Check will not be performed even if it was enabled in the SMTD UI.
  • It is not handling the case where Jigsaw or other region rendering mode might have been selected. It would require some additional code to turn that off when submitting the LC job.
  • The Job Name is set from the MAX file, and the same is used for the Batch name. If the same MAX scene is submitted more than once, the jobs will gather in the same batch group.
  • Other than most SMTD scripting tutorials you might have seen, this one operates at a very high level, basically just opening the SMTD UI and calling the function that is more or less triggered by the SUBMIT button. So it is rather artist friendly and does not require deep understanding of SMTD’s functions and settings.

Hi Bobo,

Thanks for having a look at it, it will make things a lot easier for our guys.

Saying that, it’s not working for me :slight_smile:

It seems to send the render job, not both (and no dependency)

This is the submit log:

[code]-- BEGIN - 25-4-2017 10:41:48 - WKS18/jaime - 3ds Max 2016
---- OPEN DIALOG : 25-4-2017 10:41:48 ----
[10:41:49] : >Querying Maximum Priority…
[10:41:50] : +Maximum Priority of 100 Queried in 1.218 sec.
[10:41:50] : >Collecting Pools…
[10:41:51] : +5 Pools Collected in 1.036 sec.
[10:41:51] : >Collecting Groups…
[10:41:53] : +14 Groups Collected in 1.13 sec.
[10:41:53] : +Current 3ds Max Scene: C:\Users\jaime\Desktop\temp.max
[10:41:53] : +Job Name Changed To Scene Name [temp]
[10:41:53] : >Job Submission Started…
[10:41:53] : >BatchName: [temp [VRay LC + Render]]
[10:41:53] : >Checking For Missing External Files…
[10:41:53] : +State Sets Dialog Closed.
[10:41:53] : +Closed Material Editor…
[10:41:53] : +Cleared Material Editor…
[10:41:53] : >Purifying the Render Elements Names…
[10:41:53] : >Submitting 3dsmax Render Job to Local Repository…
[10:41:53] : >Saving Scene For Submission to [C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\temp.max]
[10:41:53] : >Initiating Regular Job Submission…
[10:41:53] : >Submitting All Frames In One Job…
[10:41:54] : >Region Mode: none | Assembler Mode: DRAFT
[10:41:54] : Command Line Arguments: [-outputfiles
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\submitOutput.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\submitExitCode.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\max_submit_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\max_job_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_53\temp.max
]

[10:41:54] : +Restored the Material Editor Samples…
[10:41:54] : >Job Submission Started…
[10:41:54] : >BatchName: [temp [VRay LC + Render]]
[10:41:54] : >Checking For Missing External Files…
[10:41:55] : >Missing Files:
[10:41:55] : \p\Projects\2017\R_n_D\bfbf\temp.vrlmap
[10:41:55] : +State Sets Dialog Closed.
[10:41:55] : +Closed Material Editor…
[10:41:55] : +Cleared Material Editor…
[10:41:55] : >Purifying the Render Elements Names…
[10:41:55] : >Submitting 3dsmax Render Job to Local Repository…
[10:41:55] : >Saving Scene For Submission to [C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\25_04_2017_10_41_54\temp.max]
[10:41:55] : >Initiating Regular Job Submission…
[10:41:56] : >Submitting All Frames In One Job…[/code]

Also, is the script able to submit the render as a tile rendering job? (128 tiles for whatever image size with a padding of 200)

Am I right in guessing I can just add in the commands to save out an irradiance map as well as the light cache (we are moving to brute force, but irrmap at the moment whilst everything gets tested)

Thanks again.

We will have to add some debug prints (or log entries) to understand what is going on in your case.
What version of Deadline are you using?
In general, each time a job is submitted, SMTD should add its data to the SMTDSettings.PreviousJobsArray property.
It would be nice to add a

print SMTDSettings.PreviousJobsArray
to the code right after to first occurrence of SMTDFunctions.SubmitJobFromUI batchName:batchName to see whether it is being populated correctly.

From the log it is not possible to tell anything, since you did not include all the SMTDSettings being dumped to it. Just attach the whole LOG file so I can go through the details.

Tiles could be done, but will require some special handling - for the LC job you would have to turn off region rendering so only one job would be submitted, then restore its state so if you are doing animation, many jobs can be submitted, one for each tile.

You can add whatever you want to the code, I don’t see why not. But let’s first get it working in basic terms. It worked in my tests, but it is possible that our Deadline versions are different…

Hi Bobo,

I can’t find an actual full log file, but this is the output from the listener:

[code]Resolving Network Path: 1517ms
SMTD_AutoLoadSuccessful = true
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\RegionManipulator.ms”
Loading RegionManipulator.ms: 43ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\TileManipulator.ms”
Loading TileManipulator.ms: 7ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_Functions.ms”
Loading SubmitMaxToDeadline_Functions.ms: 5024ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck_Private.ms”
Loading SubmitMaxToDeadline_SanityCheck_Private.ms: 74ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck_General.ms”
Loading SubmitMaxToDeadline_SanityCheck_General.ms: 10ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck.ms”
Loading SubmitMaxToDeadline_SanityCheck.ms: 8ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline.ms”
Loading SubmitMaxToDeadline.ms: 9ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_Defaults.ini”
Loading SubmitMaxToDeadline_Defaults.ini: 8ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_StickySettings.ini”
Loading SubmitMaxToDeadline_StickySettings.ini: 12ms
Total SMTD Launcher Time: 14647ms
– Error occurred in i loop; filename: C:\Users\jaime\AppData\Local\Autodesk\3dsMax\2016 - 64bit\ENU\scripts\SubmitMaxToDeadline_Functions.ms; position: 185226; line: 4081
– Frame:
– i: 1
– called in CreateSubmitInfoFile(); filename: C:\Users\jaime\AppData\Local\Autodesk\3dsMax\2016 - 64bit\ENU\scripts\SubmitMaxToDeadline_Functions.ms; position: 185283; line: 4083
– Frame:
– theSlaveListString: “”
– theRenderOutput: undefined
– reExtension: undefined
– kvpIndex: undefined
– customFrameSequence: “”
– formattedComment: “3ds Max 2016 Scene Submission”
– pluginToUse: “3dsmax”
– outputDirectoryIndex: undefined
– LimitGroups: undefined
– formattedExtraInfo8: undefined
– rendererID: undefined
– outputFilenameIndex: undefined
– paddingString: undefined
– formattedExtraInfo3: undefined
– theKeyword: “Blacklist”
– RPMDataNet: undefined
– is_fxr: undefined
– customPlugin: unsupplied
– theSpecialLabel: undefined
– Delimiter: undefined
– includeBothOutputs: false
– SubmitInfoFile: <File:C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\max_submit_info.job>
– isperpassdependency: undefined
– framesSS: undefined
– reFilename: undefined
– formattedExtraInfo5: undefined
– currentTileString: “”
– theRenderer: undefined
– reFilenameOnly: undefined
– formattedExtraInfo0: undefined
– batchName: “temp [VRay LC + Render]”
– basePath: undefined
– baseType: undefined
– elementsToSkip: undefined
– rendID: undefined
– formattedJobName: “temp [VRay Render]”
– previouslysubmittedJobs: undefined
– stereoCameraToken: undefined
– formattedExtraInfo7: undefined
– theJobs: #(1)
– doPassDependency: undefined
– PADDING: undefined
– formattedExtraInfo2: undefined
– theBlackWhiteList: #()
– theFilenameProps: undefined
– tileRender: undefined
– stereoCameraLabel: “”
– totalRegions: undefined
– stereoCameraNameToken: undefined
– limitGroupsToUseArray: undefined
– formattedExtraInfo9: undefined
– filename: “C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\max_submit_info.job”
– depJobIds: “”
– activeRegions: undefined
– tempFile: undefined
– CoronaRenderer: undefined
– formattedExtraInfo4: undefined
– customOutputFile: unsupplied
– passDependencyList: undefined
– filenameOnly: undefined
– baseName: undefined
– coronaVersion: undefined
– is_exr: undefined
– frameMode: #both
– NotificationNote: undefined
– currentJobsArray: #()
– frames: undefined
– reCount: undefined
– rend_type: undefined
– oldJobName: “temp [VRay Render]”
– ChunkSize: undefined
– theFile: undefined
– reManager: undefined
– formattedExtraInfo6: undefined
– overrideExtraInfo: false
– rpmdata: undefined
– theIndex: undefined
– alreadyExported: undefined
– formattedExtraInfo1: undefined
– called in SubmitJobFromUI(); filename: C:\Users\jaime\AppData\Local\Autodesk\3dsMax\2016 - 64bit\ENU\scripts\SubmitMaxToDeadline_Functions.ms; position: 567453; line: 11836
– Frame:
– backupSceneFileSaved: false
– renderMsg: “–”
– extension: undefined
– MultiRegionRendering: false
– VRAY_lowThreadPriority: undefined
– theMaxFileName: undefined
– oldrendOutputFilename: undefined
– val: undefined
– theSceneXRefsCount: 0
– oldAmarettoExportMode: undefined
– theFilterTime: undefined
– RPMDataNet: undefined
– txt: “File”
– oldSSDialogState: false
– theFn: undefined
– oldMaxScriptFile: “”
– theBitmapsFileName: “”
– TempMaxFile: “C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\temp.max”
– initialArgsFile: <File:C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\initialArgsFile.txt>
– result: false
– oldSubmitMaxScript: false
– theAnswer: undefined
– queryExternalFiles: true
– oldVRayVFBState: false
– failedToRemove: undefined
– directory: undefined
– filenameToRender: undefined
– batchName: “temp [VRay LC + Render]”
– oldMatEditorOpenState: false
– theLine: undefined
– taskLimit: undefined
– warnAboutMissingFiles: true
– previouslysubmittedJobs: undefined
– sizeInMB: undefined
– Amaretto: undefined
– BRAZIL_lowThreadPriority: undefined
– initialArgsFileName: ““C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\initialArgsFile.txt””
– badRegions: 0
– oldRenderDialogState: false
– doPassDependency: undefined
– theTime: undefined
– forceCamera: “”
– ssPi: dotNetObject:Autodesk.Max.StateSets.Plugin
– theEFLFile: undefined
– stereoCameraLabel: “”
– canSubmitQT: true
– oldSceneExplorerStates: #()
– oldMeditLockedState: true
– initialArgs: StringStream:"-outputfiles
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\submitOutput.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\submitExitCode.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\max_submit_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\max_job_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\temp.max
"
– externalFilesList: “”
– activeRegions: 0
– retCode: #success
– path: undefined
– filename: undefined
– oldPriority: undefined
– passDependencyList: undefined
– ssP: dotNetObject:Autodesk.Max.StateSets.Plugin
– imsqFilename: undefined
– oldStereoPriority: 100
– theNetworkPath: undefined
– TilesRendering: false
– bitmapFilenames: #()
– BitmapsCopyData: undefined
– numViews: undefined
– copyresult: undefined
– done: undefined
– theXRefObjects: #()
– rpmdata: undefined
– theMessage: "The Scene Contains 1 Missing External File.

"
– OutputFilenameByUserPattern: undefined
– called in anonymous codeblock; filename: ; position: 3079; line: 42
– Frame:
– old_lightcache_mode: 0
– lcpath: “\piknas003\Projects\2017\R_n_D\bfbf\temp.vrlmap”
– theRenderer: V_Ray_Adv_3_50_04:V_Ray_Adv_3_50_04
– batchName: “temp [VRay LC + Render]”
– oldRenderDialogState: true
– oldJobName: “temp”
– No ““get”” function for undefined
[/code]

And the SMTD log output:

-- BEGIN - 26-4-2017 09:36:49 - WKS18/jaime - 3ds Max 2016
---- OPEN DIALOG : 26-4-2017 09:36:49 ---- 
[09:36:50] : >Querying Maximum Priority...
[09:36:52] : +Maximum Priority of 100 Queried in 1.589 sec. 
[09:36:52] : >Collecting Pools...
[09:36:53] : +5 Pools Collected in 1.418 sec. 
[09:36:53] : >Collecting Groups...
[09:36:55] : +14 Groups Collected in 1.363 sec. 
[09:36:55] : +Current 3ds Max Scene: C:\Users\jaime\Desktop\temp.max
[09:36:55] : +Job Name Changed To Scene Name [temp]
[09:36:55] : >Job Submission Started...
[09:36:56] : >BatchName: [temp [VRay LC + Render]]
[09:36:56] : >Checking For Missing External Files...
[09:36:56] : +State Sets Dialog Closed.
[09:36:56] : +Closed Material Editor...
[09:36:56] : +Cleared Material Editor...
[09:36:56] : >Purifying the Render Elements Names...
[09:36:56] : >Submitting 3dsmax Render Job to Local Repository...
[09:36:56] : >Saving Scene For Submission to [C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\temp.max]
[09:36:56] : >Initiating Regular Job Submission...
[09:36:56] : >Submitting All Frames In One Job...
[09:36:57] : >Region Mode: none | Assembler Mode: DRAFT
[09:36:58] : Command Line Arguments: [-outputfiles
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\submitOutput.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\submitExitCode.txt
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\max_submit_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\max_job_info.job
C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_56\temp.max
]


[09:36:58] : +Restored the Material Editor Samples...
[09:36:58] : >Job Submission Started...
[09:36:58] : >BatchName: [temp [VRay LC + Render]]
[09:36:58] : >Checking For Missing External Files...
[09:36:58] : >Missing Files:
[09:36:58] :    \\piknas003\Projects\2017\R_n_D\bfbf\temp.vrlmap
[09:36:58] : +State Sets Dialog Closed.
[09:36:58] : +Closed Material Editor...
[09:36:58] : +Cleared Material Editor...
[09:36:58] : >Purifying the Render Elements Names...
[09:36:58] : >Submitting 3dsmax Render Job to Local Repository...
[09:36:58] : >Saving Scene For Submission to [C:\Users\jaime\AppData\Local\Thinkbox\Deadline9\temp\26_04_2017_09_36_58\temp.max]
[09:36:59] : >Initiating Regular Job Submission...
[09:36:59] : >Submitting All Frames In One Job...

Using Deadline 9.0.1.1

Thanks.

JFYI, the full log of SMTD can be opened by pressing one of the two buttons at the very bottom of the SMTD UI (Open Log In Notepad or Open Log In Default Editor), or by going to the Tools menu of SMTD, and selecting “Explore SMTD Log Folder”, then locating the most recent file.

It looks like the first job fails to submit, and the second causes an error because PreviousJobsArray is empty, and we try to read the first entry from it, but there are zero entries. So the MAXScript error in the Listener is from the second job’s submission crashing. Now we need to understand why the first submission does not succeed. The full log would have had the message, but…

I have added prints of the results of the submission functions to the Listener:

(--start local scope
   
--If SMTD has not been opened yet, or has been closed since the start of 3ds Max, launch its UI:
if SMTD_MainRollout == undefined or not SMTD_MainRollout.open do macros.run "Deadline" "SubmitMaxToDeadline" 

local theRenderer = renderers.current               --get the current renderer
if isKindOf theRenderer VRay do                     --if it is VRay, we are good to go
(
   --Render final image is disabled, light cache is set to render in the output dir
   local oldRenderDialogState = renderSceneDialog.isopen()      --see if the render dialog was open
   renderSceneDialog.close()                        --close it before submission
   rendSaveFile = false                              --disable output file saving
   theRenderer.options_dontRenderImage = true         --disable the rendering
   local lcpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + ".vrlmap"   --build the LC path name
   theRenderer.lightcache_autoSave = true               --enable LC auto-save 
   theRenderer.lightcache_autoSaveFileName = lcpath         --and set the file name to the cache path
   
   --Job sends to deadline
   SMTDSettings.PreviousJobsArray = #()                --clear the dependencies list
   SMTDSettings.SubmitAsDependent = false                --disable dependencies for first job submission

   SMTD_MainRollout.getNameFromMaxScene()            --update the job name in the UI
   local oldJobName = SMTDSettings.JobName             --store the current job name
   SMTDSettings.JobName = oldJobName+" [VRay LC]"         --set the LC job's name
   local batchName = oldJobName + " [VRay LC + Render]"      --a batch name to combine the two jobs
   local result = SMTDFunctions.SubmitJobFromUI batchName:batchName      --submit the job to Deadline as part of the batch
   format "%\n" result

   if SMTDSettings.PreviousJobsArray.count == 0 do return false
	   
   --Render final image is enabled, lc is switched to "from file" and uses the precalced light cache 
   rendSaveFile = true                           --re-enable output file saving
   theRenderer.options_dontRenderImage = false            --re-enable rendering 
   theRenderer.lightcache_autoSave = false               --disable the auto save mode
   local old_lightcache_mode = theRenderer.lightcache_mode   --store the old mode
   theRenderer.lightcache_mode = 2                  --set LC mode to From File
   theRenderer.lightcache_loadFileName = lcpath            --set the load file to the cached path from the previous submission

   --Job sends to deadline with the first as a dependency.
   SMTDSettings.SubmitAsDependent = true               --enable dependencies
   SMTDSettings.DependencyJobItems = #{1}               --set the dependency on the first entry from the list
   SMTDSettings.DependOnPreviousJobMode = #last         --set the mode to last, so only the last job is concidered
   SMTDSettings.JobName = oldJobName+" [VRay Render]"      --set the job name
   local result = SMTDFunctions.SubmitJobFromUI batchName:batchName      --submit to Deadline as part of the same batch
   format "%\n" result
   
   SMTDSettings.JobName = oldJobName               --restore the job name
   SMTDSettings.SubmitAsDependent = false               --disable dependencies
   SMTDSettings.DependencyJobItems = #{}               --and clear the dependency jobs bitarray flags
   theRenderer.lightcache_mode   = old_lightcache_mode       --restore the old cache mode
   
   if oldRenderDialogState do renderSceneDialog.open()       --reopen the render dialog if needed
)--end if
)--end local scope

What I don’t understand is why there is no submission report in the Log you sent me. Right after the command line arguments there should be the actual report from the deadline command call, but there is nothing, just the Restored the Material Editor Samples row. I have never seen anything like that… Let’s see what the modified script will print, if anything.

Hi Bobo,

Log attached and listener output.

[code]Resolving Network Path: 1210ms
SMTD_AutoLoadSuccessful = true
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\RegionManipulator.ms”
Loading RegionManipulator.ms: 10ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\TileManipulator.ms”
Loading TileManipulator.ms: 6ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_Functions.ms”
Loading SubmitMaxToDeadline_Functions.ms: 4159ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck_Private.ms”
Loading SubmitMaxToDeadline_SanityCheck_Private.ms: 52ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck_General.ms”
Loading SubmitMaxToDeadline_SanityCheck_General.ms: 6ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_SanityCheck.ms”
Loading SubmitMaxToDeadline_SanityCheck.ms: 6ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline.ms”
Loading SubmitMaxToDeadline.ms: 8ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_Defaults.ini”
Loading SubmitMaxToDeadline_Defaults.ini: 8ms
Running submission script “\piknas003\DeadlineRepository9\submission/3dsmax/Main\SubmitMaxToDeadline_StickySettings.ini”
Loading SubmitMaxToDeadline_StickySettings.ini: 7ms
Total SMTD Launcher Time: 11746ms
–DEADLINE SUBMISSION CANCELED BY THE USER.

– Return: not inside a function[/code]
SubmitMaxToDeadline - [WKS18] - 26-04-2017-0014.log (14.5 KB)

Oh, right, the latest version of SMTD has some code in it to allow canceling the job via the submit button. Originally, a variable SMTDIsCurrentlySubmitting was initialized to false, and set to true when the checkbutton is pressed. In your version, it remains false, and causes the WaitForCommandToComplete function to bail out early. So in your version the first job might submit, but the rest of the SMTD functions would never know.

Recently I changed this variable to start as undefined because it was causing exactly this premature canceling of the deadlineCommand wait in other scripts, including all non-Deadline integrations like Krakatoa, XMesh, Stoke etc. That fix might be in 9.0.2.0, but you don’t have it yet. The fix makes the variable basically have 3 states - undefined, true, and false.

  • undefined means “outside of submission process”,
  • true means “submission started and not canceled”, and
  • false means “user just canceled by unchecking the UI SUBMIT checkbutton”…

Here is a fix where we set the variable to true before submission, and to undefined when it is done…

[code](–start local scope

–If SMTD has not been opened yet, or has been closed since the start of 3ds Max, launch its UI:
if SMTD_MainRollout == undefined or not SMTD_MainRollout.open do macros.run “Deadline” “SubmitMaxToDeadline”

local theRenderer = renderers.current --get the current renderer
if isKindOf theRenderer VRay do --if it is VRay, we are good to go
(
–Render final image is disabled, light cache is set to render in the output dir
local oldRenderDialogState = renderSceneDialog.isopen() --see if the render dialog was open
renderSceneDialog.close() --close it before submission
rendSaveFile = false --disable output file saving
theRenderer.options_dontRenderImage = true --disable the rendering
local lcpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + “.vrlmap” --build the LC path name
theRenderer.lightcache_autoSave = true --enable LC auto-save
theRenderer.lightcache_autoSaveFileName = lcpath --and set the file name to the cache path

–Job sends to deadline
::SMTDIsCurrentlySubmitting = true
SMTDSettings.PreviousJobsArray = #() --clear the dependencies list
SMTDSettings.SubmitAsDependent = false --disable dependencies for first job submission

SMTD_MainRollout.getNameFromMaxScene() --update the job name in the UI
local oldJobName = SMTDSettings.JobName --store the current job name
SMTDSettings.JobName = oldJobName+" [VRay LC]" --set the LC job’s name
local batchName = oldJobName + " [VRay LC + Render]" --a batch name to combine the two jobs
local result = SMTDFunctions.SubmitJobFromUI batchName:batchName --submit the job to Deadline as part of the batch
format “%\n” result

if SMTDSettings.PreviousJobsArray.count > 0 do
(
–Render final image is enabled, lc is switched to “from file” and uses the precalced light cache
rendSaveFile = true --re-enable output file saving
theRenderer.options_dontRenderImage = false --re-enable rendering
theRenderer.lightcache_autoSave = false --disable the auto save mode
local old_lightcache_mode = theRenderer.lightcache_mode --store the old mode
theRenderer.lightcache_mode = 2 --set LC mode to From File
theRenderer.lightcache_loadFileName = lcpath --set the load file to the cached path from the previous submission

–Job sends to deadline with the first as a dependency.
SMTDSettings.SubmitAsDependent = true --enable dependencies
SMTDSettings.DependencyJobItems = #{1} --set the dependency on the first entry from the list
SMTDSettings.DependOnPreviousJobMode = #last --set the mode to last, so only the last job is concidered
SMTDSettings.JobName = oldJobName+" [VRay Render]" --set the job name
local result = SMTDFunctions.SubmitJobFromUI batchName:batchName --submit to Deadline as part of the same batch
format “%\n” result

SMTDSettings.JobName = oldJobName --restore the job name
SMTDSettings.SubmitAsDependent = false --disable dependencies
SMTDSettings.DependencyJobItems = #{} --and clear the dependency jobs bitarray flags
theRenderer.lightcache_mode = old_lightcache_mode --restore the old cache mode
)
if oldRenderDialogState do renderSceneDialog.open() --reopen the render dialog if needed
::SMTDIsCurrentlySubmitting = undefined
)–end if
)–end local scope[/code]

Capture.JPG

Well that looks like it is working!

Any idea about sending it as a tile job with padding whilst you are in the code zone? :slight_smile:

Thanks again.

  • Open SMTD from the Deadline menu before running the script
  • Set up Tile rendering (e.g. Single Frame Tile Rendering) as usual
  • Run the modified script below…
(--start local scope
	
--If SMTD has not been opened yet, or has been closed since the start of 3ds Max, launch its UI:
if SMTD_MainRollout == undefined or not SMTD_MainRollout.open do macros.run "Deadline" "SubmitMaxToDeadline" 

local theRenderer = renderers.current							--get the current renderer
if isKindOf theRenderer VRay do									--if it is VRay, we are good to go
(
	--Render final image is disabled, light cache is set to render in the output dir
	local oldRenderDialogState = renderSceneDialog.isopen()		--see if the render dialog was open
	renderSceneDialog.close()									--close it before submission
	rendSaveFile = false										--disable output file saving
	theRenderer.options_dontRenderImage = true					--disable the rendering
	local lcpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + ".vrlmap"	--build the LC path name
	theRenderer.lightcache_autoSave = true						--enable LC auto-save 
	theRenderer.lightcache_autoSaveFileName = lcpath			--and set the file name to the cache path
	
	--Handle Region Rendering - LC Job should always be full frame
	local oldRegionMode = SMTDSettings.RegionRenderingMode		--store whatever Region mode SMTD was in
	SMTDSettings.RegionRenderingMode = #none					--and force full frame submission
	
	--Job sends to deadline
	::SMTDIsCurrentlySubmitting = true							--raise the flag showing we started submission and it is not canceled
	SMTDSettings.PreviousJobsArray = #() 						--clear the dependencies list
	SMTDSettings.SubmitAsDependent = false 						--disable dependencies for first job submission

	SMTD_MainRollout.getNameFromMaxScene()						--update the job name in the UI
	local oldJobName = SMTDSettings.JobName 					--store the current job name
	SMTDSettings.JobName = oldJobName+" [VRay LC]"				--set the LC job's name
	local batchName = oldJobName + " [VRay LC + Render]"		--a batch name to combine the two jobs
	local result = SMTDFunctions.SubmitJobFromUI batchName:batchName		--submit the job to Deadline as part of the batch
	SMTDSettings.RegionRenderingMode = oldRegionMode			--restore the Region Rendering mode
	
	if SMTDSettings.PreviousJobsArray.count > 0 do				--if a previous job exists to depend on,
	(
		--Render final image is enabled, lc is switched to "from file" and uses the precalced light cache 
		rendSaveFile = true										--re-enable output file saving
		theRenderer.options_dontRenderImage = false				--re-enable rendering 
		theRenderer.lightcache_autoSave = false					--disable the auto save mode
		local old_lightcache_mode = theRenderer.lightcache_mode	--store the old mode
		theRenderer.lightcache_mode = 2							--set LC mode to From File
		theRenderer.lightcache_loadFileName = lcpath			--set the load file to the cached path from the previous submission

		--Job sends to deadline with the first as a dependency.
		SMTDSettings.SubmitAsDependent = true					--enable dependencies
		SMTDSettings.DependencyJobItems = #{1}					--set the dependency on the first entry from the list
		SMTDSettings.DependOnPreviousJobMode = #last			--set the mode to last, so only the last job is concidered
		SMTDSettings.JobName = oldJobName+" [VRay Render]"		--set the job name
		SMTDFunctions.SubmitJobFromUI batchName:batchName		--submit to Deadline as part of the same batch

		SMTDSettings.JobName = oldJobName						--restore the job name
		SMTDSettings.SubmitAsDependent = false					--disable dependencies
		SMTDSettings.DependencyJobItems = #{}					--and clear the dependency jobs bitarray flags
		theRenderer.lightcache_mode	= old_lightcache_mode 		--restore the old cache mode
	)
	::SMTDIsCurrentlySubmitting = undefined						--lower the cancel submission flag since we are done
	if oldRenderDialogState do renderSceneDialog.open() 		--reopen the render dialog if needed
)--end if
)--end local scope

Note that I have removed the debug print from the Listener showing the submission result now that we know what the problem was.
The main change is that before submitting the LC job, we store the current region mode in a variable, and reset the SMTDSettings.RegionRenderingMode to #none to disable tile rendering. Then after the first submission we restore it to the original state. The function SMTDFunctions.SubmitJobFromUI() takes care of submitting region rendering if it is enabled, so we don’t have to do anything more.

I am currently testing a single frame to confirm it works as it should.
I still need to see what happens when rendering an animation…

Yes, as expected we are not handling animation correctly - if you have set it to 100 frames, the LC job will submit 100 tasks, which will overwrite each other’s vrlmap files. This will require additional handling, but let’s discuss how you intend to use it if you plan to do animation…

Hi Bobo,

I’ve been testing this out today and it all looks like it is working well. I added in the components to save/load an irradiance map as well as the light cache and that works fine.

Will it be possible to integrate the tile rendering into your script as a one-click solution? All the tile jobs I send are split into the same number of tiles every time.

I’m thinking just being able to load a maxscript that sends a prepass, then sets the tile job and number of tiles as the dependency without having to call SMTD then run an additional script.

As for using it for animations, we usually just precalc the irr/lightcache and render a frame per slave on 1080p renders, but do have active jobs now that are 10k in size and have animated elements over a number of frames, so being able to just submit an animation as tiles with a precalc for each frame would work well if possible.

Thanks.

Adding the Tiling to the script should be trivial.
Instead of the current line

SMTDSettings.RegionRenderingMode = oldRegionMode --restore the Region Rendering mode
which restores the previous region rendering mode after the lighting cache pass has been submitted and before the render pass goes out, you have to set the mode to Tiles, and specify any other relevant options:

	SMTDSettings.RegionRenderingMode = #singleFrameTiles --switch to tile mode
	SMTDSettings.TilesInX = 8 --number of tile columns
	SMTDSettings.TilesInY = 6 --number of tile rows
	TilesPadding = 5 --whatever padding you want to use
	SMTDSettings.SingleTileJobDependent = true --submit a dependent Draft Tile Assembly job

Hi Bobo,

I’ve been doing quite a few tests using this script over the long weekend here, and everything looks to be working really well.

Is it possible to add the camera name to the job submission name (or as a comment?) otherwise if you send a few renders from the same file they all get combined on the Deadline queue without knowing which is which.

Thanks.

The line

local batchName = oldJobName + " [VRay LC + Render]"

defines the Batch name that groups the jobs together in the Monitor. You can modify that, for example you could add the Camera, and/or the current time string to make each group unique. For example,

local batchName = oldJobName + " [VRay LC + Render] " + localTime

You could get the current viewport’s camera name if it exists, but you have to be mindful of cases where the view is locked in the render dialog, and handle that too…

Thanks Bobo, thought it was that line. It seems to be quite picky about what commands it accepts so i’ll have a bit of trial and error :slight_smile:

Do you have any pointers on speeding up region rendering with this script/method?

At the moment the script sets the precalc to full frame rendering with this part:

local oldRegionMode = SMTDSettings.RegionRenderingMode --store whatever Region mode SMTD was in SMTDSettings.RegionRenderingMode = #none --and force full frame submission

The problem with this is that when I run Deadline and setup some jigsaw regions and run the script, the precalc has to calculate the whole image again, even when you just want a small region.

Setting it from #none to #maxRegion seems to get it to only precalc the specific 3dsmax region, but you lose the ability for multi regions with Jigsaw.

Usually any regions that we render would be feathered into the main image, so having the precalc being a bit different isn’t a problem.

Any thought on this?

You can either have one lighting precalc job and many region jobs, or one precalc job for each region. In the later case, you will have to make sure it actually produces consistent results. I would expect it to, but you have to be sure.

I suspect that if you are subdividing the image into N regions and rendering them all, submitting N+1 jobs is better than 2*N jobs.
But if you are rendering only one or two regions out of the whole image, then precalculating the lighting of the whole image would be a waste, unless you expect the rest of the regions to come in later anyway…

So it is up to you to decide how you want it - let me know if anything does not work right.

Thanks Bobo,

I see where you are coming from with that. If we had to render lots of little regions, then we would usually just rerender the whole image just to save on headaches.

The reason we needed the precalc submission was that you could see the tile joins on the final image, even when padding to the max. That doesn’t happen anymore using this method where the slaves load the irradience map.

I’ve managed to get a bit of a working workflow by using the 3dsmax region as the precalc with DBR enabled (to speed it all up), then the script changes it to Jigsaw and creates the Jigsaw region from the 3dsmax region and submits (with DBR off)

This seems to work, but I can’t get it to split into tiles - it just gets sent as a jigsaw job with 1 tile.

This is the code which I thought would work, but maybe a Jigsaw submission doesn’t read it as tiles?

SMTDSettings.RegionRenderingMode = #singleFrameMultiRegion --switch to jigsaw SMTD_MultiRegionRendering.createFromMaxRegion -- create region from max region SMTDSettings.TilesInX = 8 --number of tile columns SMTDSettings.TilesInY = 8 --number of tile rows TilesPadding = 0 --tile padding SMTDSettings.SingleTileJobDependent = true --submit a dependent Draft Tile Assembly job

Any idea on how it should be defined to get it to split into 8x8 tiles?

Thanks.

Privacy | Site terms | Cookie preferences