Here’s a good one! For everyone that has had to make a LOT of Matte shadow files before and remember to keep them up to date when you change the master file.
I am wondering if/how you could overide all the vray object properties (ie making the objects matte shadow, and -1 in the alpha) within an xref’d file, but to only the chosen file, not globally?
I saw in RPmanager you can overide an xref’s materials and not effect other xrefs, and I dont want to mess up the materials of the Mattes due to colour bleed/reflections etc.
You can access just about any properties for an object in a xref scene through <XRefScene>.tree Node
Check out the xref Scene Values in the maxscript help
We’ve created helper objects in the past that would override the materials for objects in an xref scene so I know it is doable, that and thanks to Keith our Script Guru for refreshing my memory.
Good ideas, I’ll try xref objects, but that is not an easy method when its a massive scene your xref’ing.
I was thinking a new tab in Vray called overides, where the global material overides could be moved to. In there could be overides for the xrefs, and overides for the scene, and xref vray parameters. I wonder if Vlado can help here?
Im really only interested in controlling the objects properties to get them to matte shadows, to specific xref’s. An example use would be to render out a static landscape as a base layer, then override to a matte, and render moving obecjts on top. Currently I have to make a copy if the landscape scene, and make that a matte.
I think this is an issue a lot of people must have when splitting their scenes for rendering, and many other reasons.
(
theXRefScene = xrefs.getXRefFile 1 -- the XRefScene
xroot = theXRefScene.tree.children -- the objects in the XRefScene
for x in xroot do ( -- for every object in the xrefscene
if isValidNode x then ( -- makes sure the node is valid
try (setUserProp x "VRay_Matte_Alpha" -1) catch() -- attempts to set the VRay_Matte_Alpha to -1, easy error checking
) -- end isValidNode
) -- end for
)
```Takes the first xref scene and sets the VRay\_Matte\_Alpha (alpha contribution) to -1 eliminating it.
Works great.
-Colin
sweet, Ill try it in the morning, if it works, that will save me a LOT of time!!
Does that script change all objects in an xref to matte shadow?
How can you use the script to set an xref that is not the first in the list, just change the number? Also does it permanently change the xref scene, or only in the file you use the script?
I created a simple xref scene with a box,cylinder,and sphere and then saved it, and xrefed it into another scene. I rendered it produced the correct alpha, then I ran the script and rendered and the alpha was blank just as it should have been.
- It doesn’t change the objects to Matte Shadow, but I’ll show you how to do that
- It only changes the objects in the scene not in the original xref file
- Yes, changing the number by xrefs.getXRefFile will change what xref you are editing, of course you might want to have the script run through all xrefs.
fn setXRefScenesToMatte = (
if (local xrefCount = xrefs.getXRefFileCount()) != 0 then (
for i = 1 to xrefCount do ( -- get each xref scene in the file
local xrscene = xrefs.getXRefFile i -- xrscene equals the xref scene in which is loaded
for x in (xrscene.tree.children) do ( -- for each object in the xref scene
try (
setUserProp x "VRay_Matte_Enable" true -- sets the object to a matte object
setUserProp x "VRay_Matte_Alpha" -1 -- sets the alpha contribution to -1, consider using 0 as well
) catch ()
) -- end each object in scene
) -- end all xrefs done
true
) else false
)
fn resetXRefScenes = (
if (local xrefCount = xrefs.getXRefFileCount()) != 0 then (
for i = 1 to xrefCount do ( -- get each xref scene in the file
local xrscene = xrefs.getXRefFile i -- xrscene equals the xref scene in which is loaded
for x in (xrscene.tree.children) do ( -- for each object in the xref scene
try (
setUserProp x "VRay_Matte_Enable" false -- sets the object NOT to a matte object
setUserProp x "VRay_Matte_Alpha" 1 -- sets the alpha contribution to 1
) catch ()
) -- end each object in scene
) -- end all xrefs done
true
) else false
)
```to use, just type
setXRefScenesToMatte()
in the listener and press enter, or shift-enter
to reset the xref objects type
resetXRefScenes()
-Colin
I have been on to Vlado for a while to see how a global overide on xrefs for this exact process could be included in the Vray setting.
If you make a proper little app to controll the overide setting of xrefs, Im sure near all visualisers will use it. I spend so much time making matte shadow versions of files and then forgetting to update them when I update a model file!!
This way we can have 1 model file, 1 gls etc, and make the mattes in the render file as and when without messing with the xref files.
How would you like it to operate and what features would you like to see incorporated?
I’ll have a small control list on one side for vrayproperties settings for MATTE objects, and one for non-matte objects. I’ll have a button that then applies the settings and a button that resets the settings.
The harder part is having it save all of the original vrayproperties so when you restore them, they go back to the way they were.
Yeah, as Mark says, I think those are the main controls. It would make sense if this came off the XRef scene dialogue, so maybe a VrayProperties button on the right somewhere which opened up the normal dialogue to set the properties for each selected xref. But guess that is slightly more than scripting!(?)
Anyway attached shows a possible interface which has it all I think. Would be nice to be able to select multiple xrefs and set them - but obviously this is easier to fake in photoshop, than script in max.
This really would be a very handy script, so good luck!
Also need to include the setting for the shadow brightness as well as the full controls for receive gi, cast gi, and visible to gi. We use that here a lot to ‘fake’ things when doing matte passes to speed up rendering.
Question: do the matte settings to the xrefs persist through a network render through backburner?
Thanks for the guidance. I will incorporate all the vrayproperties in the script for tuning. I have not tested if matte settings persist through a network, but I’m 95% sure they do. Someone want to test this quickly? If it doesn’t work it’s easy enough to add a script that is run before network rendering.
Ill try to test this morning, but about to leave for meeting all day. Ill keep you posted.
Thanks again for your hard work.
On a side note, I wonder if it would be good to get the input from Vlado. I asked him a while back if this feature could be built in to Vray, and I would hate it if he has put it in to Sp3 and we wasted your time.