PDA

View Full Version : Selection Sets and Render Elements


ShiroEd
06-22-2012, 10:35 AM
Hey guys,

I'm being a bit lazy so I thought I'd ask you clever peeps if there was a way to do the following:

I have a number of Selection Sets which I would like to create 'Matte' Render Elements from. Currently I'm doing it manually by creating the 'Matte' Render Element and then choosing a Selection Set from the list to include in the Render Element.

If there was a way to automate creation of a 'Matte' Render Elements directly from the list of Selection Sets on a 1 to 1 mapping basis (if you know what I mean) this would greatly speed up my workflow.

Any thoughts or ideas mucho appreciated!!!

Thanks again.

DaveWortley
06-22-2012, 11:01 AM
For which renderer?

ShiroEd
06-22-2012, 11:06 AM
For which renderer?

Soz. We use Mental Ray.

gazybara
06-22-2012, 11:15 AM
Maybe this script (RenderMask (http://www.scriptspot.com/3ds-max/scripts/rendermask)) can help.

DaveWortley
06-22-2012, 11:21 AM
This will work by setting the gbuffer channel IDs, not using the include list in the matte element as I couldn't see how to access it.

(
re = maxOps.GetCurRenderElementMgr()

for i = 1 to selectionsets.count do
(

for o in selectionsets[i] do o.gbufferchannel = i

re.addrenderelement (MatteRenderElement())
theelement = re.getrenderelement (re.numrenderelements() - 1)
theelement.elementname = ("Matte_" + i as string)
theelement.gbufIDOn = true
theelement.gbufID = i
)

)

ShiroEd
06-22-2012, 01:20 PM
This will work by setting the gbuffer channel IDs, not using the include list in the matte element as I couldn't see how to access it.

(
re = maxOps.GetCurRenderElementMgr()

for i = 1 to selectionsets.count do
(

for o in selectionsets[i] do o.gbufferchannel = i

re.addrenderelement (MatteRenderElement())
theelement = re.getrenderelement (re.numrenderelements() - 1)
theelement.elementname = ("Matte_" + i as string)
theelement.gbufIDOn = true
theelement.gbufID = i
)

)

Hi Dave,

Sorry for the stoopid question but how do I use this? I've assigned a unique G-Buffer ID to each selection 'set' and then run this script with everything seleted but nothing seems to happen...

Many thanks for the help by the way!

DaveWortley
06-22-2012, 01:44 PM
You don't need to set the Gbuffer IDs the script does that for you. Goto the Maxscript menu ->New Script, paste all this code in the window and press Ctrl+E to run the script. Worked here.

If it doesn't work then open your maxscript listener (F11) and paste the output here.

ShiroEd
06-22-2012, 02:04 PM
You don't need to set the Gbuffer IDs the script does that for you. Goto the Maxscript menu ->New Script, paste all this code in the window and press Ctrl+E to run the script. Worked here.

If it doesn't work then open your maxscript listener (F11) and paste the output here.

You, Sir, are a LEGEND!!!

Thank you soooo much for your help.
This works PERFECTLY!!!

Thank you again! :buttrock:

DaveWortley
06-23-2012, 05:29 PM
http://davewortley.wordpress.com/2012/06/22/making-render-element-masks/

I put a breakdown of how to write this script on my blog.

denisT
06-23-2012, 06:15 PM
(
re = maxOps.GetCurRenderElementMgr()

for i = 1 to selectionsets.count do
(

for o in selectionsets[i] do o.gbufferchannel = i

re.addrenderelement (MatteRenderElement())
theelement = re.getrenderelement (re.numrenderelements() - 1)
theelement.elementname = ("Matte_" + i as string)
theelement.gbufIDOn = true
theelement.gbufID = i
)

)

(
re = maxOps.GetCurRenderElementMgr()

for i = 1 to selectionsets.count do
(
re.addrenderelement (MatteRenderElement elementname:("Matte_" + i as string) gbufIDOn:true gbufID:i)
selectionsets[i].gbufferchannel = i
)
)

DaveWortley
06-23-2012, 08:51 PM
I took the optimization 1 step further on my blog, but didn't know you could set a property for all items in a selectionset like that. Cheers for the tip.

denisT
06-23-2012, 09:43 PM
I took the optimization 1 step further on my blog, but didn't know you could set a property for all items in a selectionset like that. Cheers for the tip.
#1 if you create an element first and add it after you don't need to care about update of the list.
#2 you can set any common property of a class using the list (array, collection) of same class nodes...
for example:

objects.material = undefined
(getclassinstances dummy).boxsize = [1,1,1]
...

denisT
06-23-2012, 09:56 PM
#0 i know only one other than close/open render settings dialog way to update the list of render elements. it's collect them all, remove all, and add them back.

DaveWortley
06-24-2012, 12:50 AM
#0 i know only one other than close/open render settings dialog way to update the list of render elements. it's collect them all, remove all, and add them back.

It almost drove me mad trying to work out why my script wasn't working once apon a time and then I realised it was fine and it was just the interface not updating! I normally just close it and re-open it.

There's some really wierd things that go on with the renderelement mgr that you don't have access to, each element has its filepath but also an internal image format that you can't read/change For example...

Set your render output to something.tga and then add a render element, the render element will be a tga file output and will save a tga file. If you then change your main render output to something.tif the render element path will show it as a tga file on the path but will save out the file as a tga file with a tif extension and depending on your image viewer/compositing program will not necessarily open the file until it is renamed with a tif extension. The only solution is to store the properties of the render element and then delete it and add it back in. The next verison of deadline will have an option built in I wrote and sent to them to avoid problems when changing rendering formats.

Would be nice if there was a way to set this so you could output a 32bit float rgb image and only 8bit CC masks as TGAs. Sadly this part of max is a bit dodgey it would seem.

CGTalk Moderation
06-24-2012, 12:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.