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

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

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

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

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

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

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

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.

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:

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.

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.