Jump to content

Utilize VRay elements to generate a element with different color for each VrayMtl?


edwardsnowden
 Share

Recommended Posts

Limitation in amount of characters in topic title. Full title question is:

 

Is there any way to ultilize some (single or combination) VRay elements to generate a element which separates object surfaces in scene by VrayMtl?

 

What I mean is a output element which contain solid colors in the way that each solid color represent a unique VRayMtl in scene (and the number of materials is a big number).

 

Usually, we've got RenderID (separate object to each color and no object has same color nearby each other), but it is aliased and it only works for separate object. If the object is one single poly with Multisubobject material for each surface then it returns only one color for whole object.

 

Then we've got Wirecolor which is very good (you can control color you want to separated and AA is better than renderID, etc...) but also the same issue. E.g when we've got a proxy object with multisub materials then the output element returns only 1 color for the whole object.

 

Next thing is VrayMtlID but this one is very limited. 1st you've to set it up yourself. 2nd there're only 16 of them for all usage.

 

Is there any method to generate a output channel that take less time to manually setup and still have clear separated color for each material in scene (like the way renderID create but with unique color for each vrayMtl)? Is it even possible.

 

Thanks for reading.

Link to comment
Share on other sites

I recheck again in scriptspot and find out this one. (Before I saw its name but didn't check and thought it only randomize wirecolor).

scriptspot.com/3ds-max/scripts/random-wire-color-tools

 

  • Colour By Layer. This sets a random wire colour all of the objects on each layer.
  • Colour By Material. Perhaps the most useful of the three options this one will set all objects wire colour based on the material that is applied to it.
  • Random Colour. This is pretty self explanatory it allows you to set a random wire colour to every object in the scene. There is also the option to run these only on selected objects.

The 2nd function is what I want to try. I haven't test but seems like a good solution for separated material in postwork. Wirecolor now represent material, the the manual task is now automatic by script. But if anyone has another tips and tricks could help in this particular case, then I'd like to heard. I post the link above for future reference (upcoming readers who search for similar keywords and tags). But single object with Multisub material still need to manually set MtlID.

Edited by edwardsnowden
Link to comment
Share on other sites

Hey, I've worked with a script before which assigns object IDs to everything and also material IDs, but it only has the 16 for material IDs. I don't think it's possible to have more. Unfortunately I don't have it to give to you.

 

You can create anti aliased passes however. Select Object ID in the Render Elements tab and go to the bottom, you'll see a rollout 'VRayObjectID Parameters' you have an option output type, which by default is set to 'integer (no AA)'. If you change this to the other option 'Color with AA' you will have anti aliasing in the render output. The same applies to Material ID - so you can get both with AA.

Link to comment
Share on other sites

@Tom: Thanks for your info, and don't worry if there was free alternative script then I'll find it out myself. I knew there's parameter to get AA element output. VrayMtlID (limited to 16 ID) has that. But I said RenderID does NOT have that parameter. There're another script which sets wirecolor according to materials, I recheck scriptspot and find out it and posted here but seems like it doesn't show up (awaiting moderator to approve or something similar)...

Link to comment
Share on other sites

As mentioned by Tom you can adjust the antialising on V Ray Materials ID, Object ID , just scroll down the menu.

VRay materials have their own ID and it is almost infinite, cant remember the exact number but you can put more ID's than you'll ever use.

 

You can use this script to manage all your ID

http://www.scriptspot.com/3ds-max/scripts/effectschannelset

Link to comment
Share on other sites

This worked in some brief, non-exhaustive testing.

 

Its sets up a bunch of MultiMatteElements, one channel per scene material. This is accomplished due to the fact MultiMatteElement has include lists that supercede the Object ID/Material Effects ID values.

 

HOWEVER the Mattes will ALSO include anything matching the object ID or Mat FX ID specified. Since in my experience it's more rare to encounter Mat FX IDs in the wild the script defaults to using MatID 14/15/16.

 

--set up VRay multimattes per material

--variable declarations
validGeom = for obj in geometry where obj.material != undefined collect obj
validShapes = for obj in shapes where obj.material != undefined collect obj
validTargets = validGeom + validShapes

--retunrs an array of all objects with the specified material
fn getObjList mtl = 
(
objList = for obj in validTargets where (obj.material == Mtl) collect obj
return objList
)

--function to build render element.  
--Takes three materials as parameters and returns a Multimatte render element named for the materials set up to include the objects with those materials in R, G, and B
-- MultiMatteElement will be set to "Material ID" mode on the theory that this is less likely to have overlaps with scene data. 
--
--If you want it to rely instead on an absence of Object IDs, change MatID:true below to false

fn buildElement rMtl gMtl: bMtl: = 
(
local theElement = MultiMatteElement MatID:true r_gbufID:14 g_gbufID:15 b_gbufID:16

theElement.redlist = getObjList rMtl
theElement.elementName = "Matte_" + rMtl.name

if gMtl != undefined do 
(
	theElement.greenList = getObjList gMtl
	theElement.elementName += ("_" + gMtl.name)
)

if bMtl != undefined do
(
	theElement.blueList = getObjList bMtl
	theElement.elementName += ("_" + bMtl.name)
)

return theElement
)--end fn

--collect scene materials to array
sMats = for m in scenematerials collect m

--derive multimatte element count
numMattes = sMats.count/3
if mod sMats.count 3 != 0 do numMattes +=1

--create a render element for each triplet of materials
for thisMatte in 1 to numMattes do
(
--get index for materials
idx = (thismatte-1)*3 + 1

--initialize render element manager
reMan = MaxOps.GetCurRenderElementMgr()

--build render element and add it to the list
gVal = try(sMats[idx+1])catch(undefined)
bVal = try(sMats[idx+2])catch(undefined)
reMan.AddRenderElement (buildElement sMats[idx] gMtl:gVal bMtl:bVal)

)

Link to comment
Share on other sites

Hey, I've just posted the script we use at work on Scriptspot. It will create an object ID and material ID for all objects and materials in your scene. Unfortunatley you only get 16 material IDs. I think it should do most of what you're asking. The link is:

 

http://www.scriptspot.com/3ds-max/scripts/vray-script-for-randomizing-object-ids-and-material-ids

 

Right now it's waiting for approval from a moderator, but should be active shortly.

Link to comment
Share on other sites

Hey, I've just posted the script we use at work on Scriptspot. It will create an object ID and material ID for all objects and materials in your scene. Unfortunatley you only get 16 material IDs. I think it should do most of what you're asking. The link is:

 

http://www.scriptspot.com/3ds-max/scripts/vray-script-for-randomizing-object-ids-and-material-ids

 

Right now it's waiting for approval from a moderator, but should be active shortly.

 

Finally the link is active. Been checking it every day for a while now! The script works well and should help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...