- 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…