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.