AWS Thinkbox Discussion Forums

Vray lightcache prerender?

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.

Of course :slight_smile:

The TilesInX and TilesInY properties have nothing to do with Jigsaw, they define the grid when using the old Tile Rendering mode (which is mostly unrelated to Jigsaw, except the option to create Jigsaw regions from the Tile Grid settings).

What you really need to look at is the Jigsaw definition itself, which is created and stored in SMTDSettings.MultiRegionData
Also remember to add the () after SMTD_MultiRegionRendering.createFromMaxRegion() as it would not create anything otherwise.
If you execute the function and check out the content of the property, you will see something like

SMTDSettings.MultiRegionData #(#(true, 0.1, 0.1, 0.8, 0.8, 1, 1, "3ds Max Region Gizmo [X:64 Y:48 W:512 H:384]", true))
The value of the property is an array of arrays defining all current Jigsaw regions. The values inside the sub-array define:
1: boolean value for the enabled state
2,3: upper left corner X and Y in normalized screen space
4,5: width and height of the region in normalized screen space
6,7: the tiles along X and Y - this is what you want to modify!
8: the name of the region
9: the selected state of the region
10: (optional, added when keyframed) the keys array
11: (optional, added when keyframed) the lock boolean value

So once you have created the Jigsaw region from the Max region, you can say

SMTDSettings.MultiRegionData[SMTDSettings.MultiRegionData.count][6]=8 --set the X tiles of the last region to 8
SMTDSettings.MultiRegionData[SMTDSettings.MultiRegionData.count][7]=6 --set the Y tiles of the last region to 6

If you look at the definition now, you will see

SMTDSettings.MultiRegionData #(#(true, 0.1, 0.1, 0.8, 0.8, 8, 6, "3ds Max Region Gizmo [X:64 Y:48 W:512 H:384]", true))
and in the Jigsaw rollout of the Tiles tab of the SMTD UI will see the actual tiles if you click again on the new region.

Remember that the Tiles tab must be selected in SMTD UI for the region creation function to work. If you prefer to create the Jigsaw from Max region without the Tiles tab selected, you can create your own function in your own script, and call that:

fn createJigsawFromMaxRegion = ( local theRect = if viewport.activeViewport > 0 then viewport.getRegionRect (viewport.activeViewport) else Box2 0 0 RenderWidth RenderHeight append SMTDSettings.MultiRegionData #(true, (1.0*theRect.x/RenderWidth), (1.0*theRect.y/RenderHeight), (1.0*theRect.w/RenderWidth), (1.0*theRect.h/RenderHeight), 1, 1, "3ds Max Region Gizmo [X:"+ theRect.x as string + " Y:"+ theRect.y as string + " W:"+theRect.w as string + " H:"+theRect.h as string + "]" ) ::SMTD_MultiRegionSettingsPersistentGlobal = SMTDSettings.MultiRegionData )

The above does the same as the function SMTD_MultiRegionRendering.createFromMaxRegion() you call, but it does not require the SMTD UI to be open at all or the Tiles tab to be selected. The ::SMTD_MultiRegionSettingsPersistentGlobal persistent global is used to remember the last Jigsaw setup between SMTD sessions. When you click on the Tiles tab of the SMTD UI, the content of this variable is copied into SMTDSettings.MultiRegionData, so if the persistent global is #(), it would destroy the region you just created. Thus we have to keep the two in sync in our function. Add the above function to the beginning of your script, and then use

SMTDSettings.RegionRenderingMode = #singleFrameMultiRegion --switch to jigsaw createJigsawFromMaxRegion() -- create region from max region using own function SMTDSettings.MultiRegionData[SMTDSettings.MultiRegionData.count][6]=8 --set the X tiles of the last region to 8 SMTDSettings.MultiRegionData[SMTDSettings.MultiRegionData.count][7]=6 --set the Y tiles of the last region to 6 SMTDSettings.TilesPadding = 0 --tile padding SMTDSettings.SingleTileJobDependent = true --submit a dependent Draft Tile Assembly job

Hope this helps.

Thanks for the detailed info Bobo, I’ve managed to make a few submitters that take care of single images, regions, jigsaw regions, brute force & lightcache, irradiance and lightcache and any other bits and bobs that people need thanks to this thread. :slight_smile:

Did you have any ideas on how to get an animation working with the prebake script, it’s the only thing missing now from my workflow.

Thanks again!

I am still unsure what you expect to happen, and what the technical issue is you need help with.

When rendering Animation Jigsaw regions, each job contains exactly one Max region, and could have a matching light cache job with the same region writing to a name that matches the tile signature.
Alternatively, one job with full frame calculations could be sent to calculate the cache for all regions, and all region jobs would be set to load its cache, and be dependent on it.

Both implementations should be trivial with the code you have, and it should be up to you to decide which of the two approaches you want. But that is a conceptual question, not a technical one. If you hit a snag in implementing the actual code, please let me know. :slight_smile:

Hi Bobo,

Is it possible to force the submission script to only render the precalc animation on one slave?

At the moment when the lightcache prerender job is sent, it sends as 20 tasks, which then 20 slaves start having a go and so the irradiance/lightcache map is overwritten each time.

Can you specify that a slave holds onto the scene file and renders the lightcache file fully as an animation, so it adds to it, rather than overwriting?

Thanks Sensei :slight_smile:

There are a few approaches, but the best would be to simply set the chunk size to the number of frames, or just to a very large number. This way there will be just ONE task in the job, forcing a single Slave to go through all frames in order. If it fails in the middle, it or another Slave will start from the beginning.

SMTDSettings.ChunkSize = 10000

Then for the actual render jobs, set it back to 1 or whatever chunk size you usually submit with.

Hi Bobo,

I’ve managed to get everything working like it should now, but i’ve noticed it failing to report a task as failed if the precalc job crashes.

This is taken from the log, so everything has been marked complete and still tries to render without the actual irradiance map/lightcache file.

2017-05-12 10:23:05: 0: INFO: V-Ray DBR: Updating cfg file for distributed render with the following machines: 2017-05-12 10:23:05: 0: INFO: V-Ray DBR: 10.3.222.107 2017-05-12 10:23:05: 0: INFO: V-Ray DBR: 10.3.222.105 2017-05-12 10:23:05: 0: INFO: V-Ray DBR: 10.3.222.110 2017-05-12 10:23:05: 0: INFO: V-Ray DBR: 10.3.222.112 2017-05-12 10:23:25: 0: STDOUT: 12/05/2017 10:23:24; BEGIN FRAME 0; TASK 1 OF 1; (C:\Users\PIkcells\AppData\Local\Thinkbox\Deadline9\slave\r9\jobsData\59157e5c0eb9411b14575590\3dsOutput_temp0Rl220\BAT_LAR_Establishing_UNITS0000.exr); 2017-05-12 10:45:33: 0: STDOUT: 12/05/2017 10:45:33; An unexpected exception has occurred in the network renderer and it is terminating. 2017-05-12 10:45:33: 0: STDOUT: 12/05/2017 10:45:33; Error rendering frame 0: An unexpected exception has occurred in the network renderer and it is terminating. 2017-05-12 10:45:34: 0: INFO: Moving output files and folders from C:\Users\PIkcells\AppData\Local\Thinkbox\Deadline9\slave\r9\jobsData\59157e5c0eb9411b14575590\3dsOutput_temp0Rl220 to \\piknas003\Projects\2017\FOREMOST\2_BATHS\STILLS\RENDERS\LARKEN\MAINPOOL\REGIONS 2017-05-12 10:45:34: 0: INFO: V-Ray DBR: Restoring backup config file: C:\Users\PIkcells\AppData\Local\Thinkbox\Deadline9\slave\r9\jobsData\59157e5c0eb9411b14575590\vray_dr.cfg to original location: C:\Users\PIkcells\AppData\Local\Autodesk\3dsmax\2016 - 64bit\ENU\en-US\plugcfg\vray_dr.cfg 2017-05-12 10:45:34: 0: INFO: V-Ray DBR: Marking other incomplete tasks as complete

Any ideas?

Also, i’m trying to get a sequence to render where it calcs a prepass/irradiance map for each frame (as objects go in/out on a 1 frame basis)

I thought I would just be able to set the rendering modes to animation prepass/animation rendering in the script, but it just renders 1 file (whereas the animation prepass should render separate precalcs for each frame)

Then (not surprisingly) Deadline errors out with vray saying the irradiance map cannot be used for this type…

This is the bulk of the code for creating the precalcs, which works for flythough animations. I can’t seem to see what the problem is though.

[code] --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
theRenderer.system_distributedRender = true --turn on dr (j)

local lcpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + “.vrlmap” --build the LC path name
–theRenderer = renderers.current
theRenderer.lightcache_mode =1 --set to flythrough (J)
theRenderer.lightcache_dontDelete = true
theRenderer.lightcache_autoSave = true --enable LC auto-save
theRenderer.lightcache_autoSaveFileName = lcpath --and set the file name to the cache path
theRenderer.lightcache_saveFileName = lcpath

SMTDSettings.ForceWorkstationMode = false
SMTDSettings.MergeSceneXRefsOnSubmission = false
SMTDSettings.MergeXRefsOnSubmission = false
SMTDSettings.Priority = 100
SMTDSettings.SingleTileJobDraftErrorOnMissing = true
SMTDSettings.SingleTileJobCleanup = false
SMTDSettings.RestartRenderer = true
SMTDSettings.RemovePadding = false
SMTDSettings.SubmitAsSuspended = false

rendNThFrame = 1  --sets nth to 1



local irpath = getFileNamePath rendOutputFilename + getFileNameFile rendOutputFilename + ".vrmap"   --build the IM path name



theRenderer.adv_irradmap_mode = 1  --1 is multiframe inc (J)
theRenderer.adv_irradmap_dontDelete = true
theRenderer.adv_irradmap_autoSave = true
theRenderer.adv_irradmap_autoSaveFileName = irpath
theRenderer.adv_irradmap_saveFileName = irpath

–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

       SMTDSettings.DBR = true					--turn on VrayDR (J)

SMTDSettings.DBRUse3dsCmd = true --turn on 3dscmd in deadline (J)
SMTDSettings.DBRServers = 5 --set 4 dr servers (J)

–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
SMTDSettings.ChunkSize = 10000 --chunk it so only 1 slave does the calc (J)
SMTDSettings.RemovePadding = false[/code]

Thanks for any pointers.

Hi Bobo,

Just an update on this.

I’ve sorted out the Anim Prepass/Rendering issue and it looks like it works properly now.

I’ve just encountered a small bug when using the create from 3dsmax region script to add it to jigsaw - it doesn’t seem to delete the new region data and hangs around even after deadline is closed.

So sending a single region after 2 other regions on different jobs have been sent, then next job will have 3 regions on the render.

I’m guessing the SMTDSettings.MultiregionData that adds it to Jigsaw needs deleting at the end of the submission?

The content of SMTDSettings.MultiRegionData is your responsibility. If you are appending to it, it will grow. You can always set it to

::SMTD_MultiRegionSettingsPersistentGlobal = SMTDSettings.MultiRegionData = #()

to clear. The ::SMTD_MultiRegionSettingsPersistentGlobal is stored with the MAX file and can be used to restore the SMTDSettings.MultiRegionData after a MAX scene has been loaded (at least that’s how SMTD is using it).

Hi Bobo,

I’ve been trying to get clever with this submission script, but it’s not working as intended when using the Vray Frame Buffer. Any pointers are appreciated!

What should happen:

Precalc job is sent first with DR slaves.

–This calculates the lightcache file and saves out that vrlmap and temp preview lightcache image in a new folder that is created (_temp\preview.jpg and _temp\jobname.vrlmap) The preview.jpg is specified in the 3dsmax output.

Main tile job is sent

– This loads the vrlmap from the temp folder. Tiles render and are saved into the output dir specified in the Vray Frame Buffer-Split Channels Option

Assembly Job runs

–And everything gets put back together again.

I have it able to make the new temp folder, save the new lightcache into that folder, create the preview.jpg image but then it all falls down and doesn’t render anything useful, just the RGB and Alpha when enabled on the Separate render channels option in the Vray Frame Buffer.

The tile jobs output on Deadline just lists the render elements with a .jpg extension, not exr like the Vray Output.

The end goal of this is to setup some event plugins to email that preview.jpg to the user to check if the lighting looks ok, and to make it easy to delete all the lightcaches/temp files in the _temp folder in one go.

This is my submission script. I’ve commented everything I have added with a (J) so you can see the method to the madness :slight_smile:

[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

theRenderer.options_dontRenderImage = true               --disable the rendering
theRenderer.system_distributedRender =true				--turn on dr (J)


--make sure vfb and split files is on otherwise it will error (J)

tempFolder = getFileNamePath theRenderer.output_splitfilename + "_temp" -- specify temp folder (J)
makeDir tempFolder -- make temp folder (J)
rendoutputfilename = tempFolder + "\\" + "preview.jpg"  -- set temp 3dsmax output file as a lightcache preview.jpg (J) 
rendSaveFile = false   --disable 3dsmax output file saving (J)

local lcpath = tempFolder + “\” + getFileNameFile theRenderer.output_splitfilename + “.vrlmap” --build the LC name in the new temp folder (J)

theRenderer.lightcache_autoSave = true                  --enable LC auto-save 
theRenderer.lightcache_autoSaveFileName = lcpath         --and set the file name to the cache path
theRenderer.lightcache_saveFileName = lcpath
	

	
SMTDSettings.ForceWorkstationMode = false
SMTDSettings.MergeSceneXRefsOnSubmission = false
SMTDSettings.MergeXRefsOnSubmission = false
SMTDSettings.Priority = 99
SMTDSettings.SingleTileJobDraftErrorOnMissing = true
SMTDSettings.SingleTileJobCleanup = true
SMTDSettings.SubmitAsSuspended = true
SMTDSettings.RemovePadding = true  --removes 0000  (J)
re = maxOps.GetCurRenderElementMgr() -- turn off render elements to stop the initial dump of 0000 files (J)
re.SetElementsActive false

–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

SMTDSettings.DBR = true					--turn on VrayDR (J)

SMTDSettings.DBRUse3dsCmd = true --turn on 3dscmd in deadline (J)
SMTDSettings.DBRServers = 5 --set 5 dr servers (J)

–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 +" (Pre)" --set the LC job’s name

local batchName = oldJobName + " (Render:BF/LC)" --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 = #singleFrameTiles --switch to tile mode
SMTDSettings.TilesInX = 1 --number of tile columns
SMTDSettings.TilesInY = 1 --number of tile rows
TilesPadding = 0 --whatever padding you want to use

SMTDSettings.SingleTileJobDependent = true --submit a dependent Draft Tile Assembly job

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 = false 	   --make sure output file saving is off (J)
re = maxOps.GetCurRenderElementMgr() -- turn on render elements to stop the initial dump of 0000 files
re.SetElementsActive true

theRenderer.options_dontRenderImage = false            --re-enable rendering 
theRenderer.system_distributedRender =false			--turn off dr (J)
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

SMTDSettings.DBR = false					--turn off VrayDBR (J)
SMTDSettings.DBRUse3dsCmd = false	--turn off 3dscmd in deadline (J)


   
  --Job sends to deadline with the first as a dependency.
SMTDSettings.CloseAfterSubmission = true
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+" (Render)"      --set the job name
SMTDSettings.Priority = 80
 
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
try(destroyDialog SMTD_MainRollout)catch() – close the SMTD window
format “%\n” result
)–end if
)–end local scope[/code]

Thanks.

Privacy | Site terms | Cookie preferences