Submission Script Tile Rendering?

I’m trying to hack the code Bobo wrote to submit to Deadline in one click, but I need to add Tile Rendering, i’ve set the SMTD settings to be Tile rendering, defined my tiles… The submission script runs without errors… but only creates 2 Frames in the tasks list… one of which looks correct but isn’t the correct output size… and the second is “-1”? (see attachment)I was hoping the SubmitMaxToDeadline_Functions.ms would cover all the hassle behind creating a Tile Job. Am I missing a SMTDSetting?

[code](
rendSaveFile = true
global SMTDSettings --this is the global variable that will contain the submission settings of SMTD
global SMTDFunctions --this is the global variable that will contain the submission functions of SMTD

local theNetworkRoot = "" --this variable will hold the network root path - the path to the Repository
local theHomeRoot = "" --this variable will hold the local home folder of Deadline


--------------------------------------
--MAIN SUBMISSION CODE
--------------------------------------
	
            theNetworkRoot = "\\\\zzz.yyy.com\\DeadlineRepository" --edited...
	format "Network Root is '%'\n" theNetworkRoot 
				
	--First, we load the script file with the function definitions
	local remoteScript = theNetworkRoot + "\\submission\\3dsmax\\SubmitMaxToDeadline_Functions.ms"  --this is the file name on the Repository
	local localScript = getDir #scripts + "\\SubmitMaxToDeadline_Functions.ms" --to speed things up, we will copy it locally first, then we will load it
	if doesFileExist remoteScript then --if the remote file exists,
	(
		deleteFile localScript --we delete the local file in case it exists already
		copyFile remoteScript localScript --then we copy the remote file over
		fileIn localScript quiet:true --and execute it (equivalent to Main Menu > MAXScript > Run Script...)
		
		--At this point, SMTDFunctions should have been initialized to the latest version found on the Repository.
		--Now we have to make sure all defaults (both global and local) are loaded, otherwise the SMTDSettings struct would contain factory defaults
		SMTDFunctions.loadSettings()
												
		---### use currently open file
		f = maxfilepath + maxfilename
		
		SMTDSettings.JobName = getFileNameFile f + " [BATCH SUBMISSION BETA]" --we could for example set the job name to the name of the max file and any custom text we want
		SMTDSettings.Comment = "Submitted from the batch Custom Submitter" --we could set the comment field
		SMTDSettings.Priority = 20 --we can override the priority, for example we could increment the priority based on the order of the files or something else
		SMTDSettings.ChunkSize = 1
		SMTDSettings.SubmitScene = true 
		
		--## DW
		--setIniSetting SMTDPaths.InIFile "TilesRendering" "TilesRendering" "True"
		--setIniSetting SMTDPaths.InIFile "TilesRendering"  "TilesInY" "10"
		--setIniSetting SMTDPaths.InIFile "TilesRendering"  "TilesInX" "10"
		--setIniSetting SMTDPaths.InIFile "TilesRendering" "SingleTileJob" "True"
		--setIniSetting SMTDPaths.InIFile "TilesRendering" "SingleTileJobDependent" "True"
		--setIniSetting SMTDPaths.InIFile "TilesRendering" "SingleTileJobCleanup" "True"
		SMTDSettings.TilesRendering = true
		SMTDSettings.TilesInY = 10
		SMTDSettings.TilesInX = 10
		SMTDSettings.SingleTileJob = true
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = true
		--##
		
		--Note that the simple act of loading SMTDFunctions has also initialized a SMTDPaths struct with default paths - type 'show SMTDPaths' to see what paths are available
		local SubmitInfoFilename = SMTDPaths.tempdir + "\\max_submit_info.job"  --we define the submit info file name which will contain info about the submission settings
		local JobInfoFilename = SMTDPaths.tempdir  + "\\max_job_info.job" --and the job info file which will contain info about the job's settings (most of them can be changed in the job's Properties dialog of the Monitor
		
		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFilename --we then call the function to create a submit info file based on the current SMTDSettings values
		
		--We also call the function to create a job info file. It will contain all info about the current scene like renderer settings, list of cameras etc.
		--This function accepts optional overrides for the render output filename, the tiles to render and the camera to render. 
		--We can specify these if we know them: renderOutputOverride:"" tileString:"" forceCamera:"" 
		SMTDFunctions.CreateJobInfoFile JobInfoFilename  --renderOutputOverride: could be set to a string that points at the network location to write the images from the scene being submitted instead of using the renderer's output settings!
			
		--Now that we have all the files we need for a submission (the scene file, the submit info and the job info file), we can call the submitter!
		--To do this, we will have to create an argument list to pass to DeadlineCommandBG
		local initialArgs = "\"" + SubmitInfoFilename + "\" \"" + JobInfoFilename  + "\" \"" + f + "\" " 
		
		--We call the DeadlineCommandBG with our arguments and the timeout (which you can customize)
		local retcode = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
		
		--Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
		local renderMsg = SMTDFunctions.getRenderMessage() 
		SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
		
		if retCode == #success then --if the return code from the call was #success, we show a positive message
		(
			format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath f) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
			SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
		)	
		else --if the code was anything else, we print the message as error message
			format "Remaining Frames Job Submission FAILED.\n\n%" renderMsg 
				
)--end if root resolved

)–end script[/code]
tiles_error.jpg

Added a few more parameters and got 100 frames rendered, the tasks in deadline had the correct names, but region rendering wasn’t enabled and regions weren’t defined if I enabled it… So i got 100 frames of the full rgb save out as Image_0xxx.jpg not as _tile_1x1_10x10 etc…

SMTDSettings.RegionRendering = true SMTDSettings.SingleTileJobLeft = "0" SMTDSettings.SingleTileJobRight = "3000" SMTDSettings.SingleTileJobTop = "0" SMTDSettings.SingleTileJobBottom = "2000" --SingleTileJobFilename:"" --SingleTileJobReFilename:"" SMTDSettings.SingleTileJobTileCount = 100 SMTDSettings.TileBlowupMode = false --SingleTileJobFrameList:"" SMTDSettings.TilesPadding = 0 --TilesSubmissionJobIDs:#() --SMTDSettings.TilesRendering = true SMTDSettings.TilesInY = 10 SMTDSettings.TilesInX = 10 SMTDSettings.SingleTileJob = true SMTDSettings.SingleTileJobDependent = true SMTDSettings.SingleTileJobCleanup = true

(
   rendSaveFile = true
   global SMTDSettings  --this is the global variable that will contain the submission settings of SMTD
   global SMTDFunctions --this is the global variable that will contain the submission functions of SMTD

   local theNetworkRoot = "" --this variable will hold the network root path - the path to the Repository
   local theHomeRoot = "" --this variable will hold the local home folder of Deadline


   --------------------------------------
   --MAIN SUBMISSION CODE
   --------------------------------------
      
      theNetworkRoot = "\\\\YourShare\\DeadlineRepository" --repository location
      format "Network Root is '%'\n" theNetworkRoot 
               
      --First, we load the script file with the function definitions
      local remoteScript = theNetworkRoot + "\\submission\\3dsmax\\SubmitMaxToDeadline_Functions.ms"  --this is the file name on the Repository
      local localScript = getDir #userscripts + "\\SubmitMaxToDeadline_Functions.ms" --to speed things up, we will copy it locally first, then we will load it
      if doesFileExist remoteScript then --if the remote file exists,
      (
         deleteFile localScript --we delete the local file in case it exists already
         copyFile remoteScript localScript --then we copy the remote file over
         fileIn localScript quiet:true --and execute it (equivalent to Main Menu > MAXScript > Run Script...)
         
         --At this point, SMTDFunctions should have been initialized to the latest version found on the Repository.
         --Now we have to make sure all defaults (both global and local) are loaded, otherwise the SMTDSettings struct would contain factory defaults
         SMTDFunctions.loadSettings()
                                       
         local TempMaxFile = maxfilepath + maxfilename
         
         SMTDSettings.JobName = getFileNameFile TempMaxFile + " [BATCH SUBMISSION BETA]" --we could for example set the job name to the name of the max file and any custom text we want
         SMTDSettings.Comment = "Submitted from the batch Custom Submitter" --we could set the comment field
         SMTDSettings.Priority = 20 --we can override the priority, for example we could increment the priority based on the order of the files or something else
         SMTDSettings.ChunkSize = 1
         SMTDSettings.SubmitScene = true 
         
         SMTDSettings.TilesRendering = true --we don't really have to enable this, because the call to spawnTileJobs() will set it to true anyway
         SMTDSettings.TilesInX = 4 --we define the horizontal tiles count
         SMTDSettings.TilesInY = 2 --and the vertical tiles count
         SMTDSettings.SingleTileJob = true --we will submit a single frame as one job where each task will represent a tile
         SMTDSettings.SingleTileJobDependent = true --we will submit a dependent job to combine the tiles
         SMTDSettings.SingleTileJobCleanup = true --and we will clean up after us, leaving the assembled image but deleting the tiles files. Set to false if you want to rerender later.
         retCode = SMTDFunctions.spawnTileJobs forceMaxFile:TempMaxFile  --this is the function that does all the useful work spawning the tile render
         
         --Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
         local renderMsg = SMTDFunctions.getRenderMessage() 
         SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
		 
         if retCode == #success then --if the return code from the call was #success, we show a positive message
         (
            format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath TempMaxFile) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
            SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
         )   
         else --if the code was anything else, we print the message as error message
            format "Job Submission FAILED.\n\n%" renderMsg 
               
   )--end if root resolved
)--end script

Cheers Bobo, glad you guys code it in such a logical way.

I’m planning on trying to make a region Tile Renderer, is that going to be possible without some monumental bodging?

‘No Scene file was included with the job’ however…

SMTDSettings.SubmitScene = true

Any ideas?

Fixed, it wasn’t sending the scene file with the job as SMTDSettings.submitScene is for Deadline 4, SMTDSettings.submitSceneMode needed to be set. Also the reCode from SpanTileJobs() returns True rather than Sucess.

[code] (
rendSaveFile = true
global SMTDSettings --this is the global variable that will contain the submission settings of SMTD
global SMTDFunctions --this is the global variable that will contain the submission functions of SMTD

   local theNetworkRoot = "" --this variable will hold the network root path - the path to the Repository
   local theHomeRoot = "" --this variable will hold the local home folder of Deadline


   --------------------------------------
   --MAIN SUBMISSION CODE
   --------------------------------------
     
      theNetworkRoot = "\\\\bluearc.taylorjames.com\\DeadlineRepository" --repository location
      format "Network Root is '%'\n" theNetworkRoot
               
      --First, we load the script file with the function definitions
      local remoteScript = theNetworkRoot + "\\submission\\3dsmax\\SubmitMaxToDeadline_Functions.ms"  --this is the file name on the Repository
      local localScript = getDir #userscripts + "\\SubmitMaxToDeadline_Functions.ms" --to speed things up, we will copy it locally first, then we will load it
      if doesFileExist remoteScript then --if the remote file exists,
      (
         deleteFile localScript --we delete the local file in case it exists already
         copyFile remoteScript localScript --then we copy the remote file over
         fileIn localScript quiet:true --and execute it (equivalent to Main Menu > MAXScript > Run Script...)
         
         --At this point, SMTDFunctions should have been initialized to the latest version found on the Repository.
         --Now we have to make sure all defaults (both global and local) are loaded, otherwise the SMTDSettings struct would contain factory defaults
         SMTDFunctions.loadSettings()
                                       
         local TempMaxFile = maxfilepath + maxfilename
         
         SMTDSettings.JobName = getFileNameFile TempMaxFile + " [BATCH SUBMISSION BETA]" --we could for example set the job name to the name of the max file and any custom text we want
         SMTDSettings.Comment = "Submitted from the batch Custom Submitter" --we could set the comment field
         SMTDSettings.Priority = 100 --we can override the priority, for example we could increment the priority based on the order of the files or something else
         SMTDSettings.ChunkSize = 1
         SMTDSettings.SubmitSceneMode = #reposave --changed to +Mode in Deadline 5.1
         
         SMTDSettings.TilesRendering = true --we don't really have to enable this, because the call to spawnTileJobs() will set it to true anyway
         SMTDSettings.TilesInX = 10 --we define the horizontal tiles count
         SMTDSettings.TilesInY = 10 --and the vertical tiles count
         SMTDSettings.SingleTileJob = true --we will submit a single frame as one job where each task will represent a tile
         SMTDSettings.SingleTileJobDependent = true --we will submit a dependent job to combine the tiles
         SMTDSettings.SingleTileJobCleanup = true --and we will clean up after us, leaving the assembled image but deleting the tiles files. Set to false if you want to rerender later.
         retCode = SMTDFunctions.spawnTileJobs forceMaxFile:TempMaxFile  --this is the function that does all the useful work spawning the tile render
         
         --Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
         local renderMsg = SMTDFunctions.getRenderMessage()
         SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
		
		
		
         if retCode == true then --retCode returns true from SMTDFunctions.spawnTileJobs() if sucessful.
         (
           format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath TempMaxFile) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
            SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
         )   
         else --if the code was anything else, we print the message as error message
            format "Job Submission FAILED.\n\n%" renderMsg
               
   )--end if root resolved
)--end script

[/code]

Good news everyone, I’ve sucessfully managed to make a Crop Tile Rendering for Deadline, so you can now specify an area, choose your number of tiles and it will render the region using tiles, saving on memory and render time if you want to render just a small crop of a big image.

This is really only useful for those that do massive print sized renderings like we do, I’ll post all the code modifications up at some point soon.

I will probably make this a feature of SMTD in the future.
All we have to do is let SMTD produce black (or any color, for that matter) stand-ins for all tiles, then you can submit custom tiles for the area you want rendered, and the assembler will put them together, using both the rendered ones and the empty ones. The beauty of this approach is that you are not limited to a rectangular area, you can render ANY set of tiles…

We have that approach as well, I’ve got a post-script which creates all the missing blank tiles, but requires some manual processing at the moment, would be better to have it in the SMTD like you say, but this still makes a massive mostly blank file, and as the Tile settings aren’t persistent you need to rely on people checking the same Tiles again for re-renders. With the Crop render approach at least the region is stored in the file.