When loading VRMats in a VRayMatMtl, how do I assing material id’s? I mean beyond the 1-15 you can with the material editor? With a normal vraymtl you can override this to what you want, but I don’t see an override in a vrmat, or am I not looking in the right place?
I can’t use the object gbuffer, because a lot of this is in multisubobjects in vray proxies
Ideas?
I think Dave mentioned in another thread there’s a way to get more than 15 with just max
It’s using a little sneaky bit of MaxPlus… I’ve been having the occasional error message with this code though at the moment and sometimes running it again fixes it… It’s a bit complicated to track so if you can let me know if it ever errors for you.
fn ExpandMaterialLibrary mLib =
(
materials = #()
for m in mLib where iskindof m material do
(
append materials m
for s = 1 to (getnumsubmtls m) where (getsubmtl m s) != undefined do append materials (getsubmtl m s)
)
materials
)
lib = ExpandMaterialLibrary scenematerials
for j = 1 to lib.count do
(
GlobalInterface = (dotNetClass "Autodesk.Max.GlobalInterface")
CreateStr = GlobalInterface.Instance.StringStream.Create
((GlobalInterface.Instance.ExecuteScript (CreateStr ("lib[" + j as string + "]")) true).ToMtlbase).GbufID = J
)
MMEID = 1
for i = 1 to lib.count by 3 do
(
re = maxOps.GetRenderElementMgr #production
local eleName = ("MME_mats_" + (MMEID as string))
re.addrenderelement (MultiMatteElement elementname:eleName)
theelement = re.getrenderelement (re.numrenderelements() - 1)
theelement.MatID = true
theelement.R_gbufIDOn = true
theelement.R_gbufID = i
if i + 1 <= lib.count then
(
theelement.G_gbufIDOn = true
theelement.G_gbufID = i + 1
)
else
(
theelement.G_gbufIDOn = false
)
if i + 2 <= lib.count then
(
theelement.B_gbufIDOn = true
theelement.B_gbufID = i + 2
)
else
(
theelement.B_gbufIDOn = false
)
MMEID += 1
)