Alpha Passes

Sweet! Thanks. Yes this works. I’ll have to pick it apart when I have more time. I still have trouble totally comprehending anything but simple loops. I’m learning but my scripting time is about 1% of my work schedule.

Another feature I was trying to implement was to name each MultiMatte with the three objects that it represents. Something like: “Box01Sphere01Sphere02” It was sort of working in mine but again only going over the first three objects several times…

It’s sill pretty crude but it works…

rollout ro_Mattes "Matte Generator v.02" width:338 height:133
(
    edittext edt1 "Render Element Prefix" pos:[12,13] width:315 height:22 enabled:true
    button btn1 "Go!" pos:[130,88] width:77 height:30
    spinner spn1 "Starting G-Buffer ID     " pos:[53,48] width:160 height:16 enabled:true range:[1,100,1] type:#integer
    on btn1 pressed do
    (
        re = maxOps.GetCurRenderElementMgr()
        objs = selection as array
        el=multimatteelement
        count= objs.count    

        For i = 1 to count by 3 do
            (
                    objs[i].gbufferChannel=i+spn1.value-1
                    if (i+1 <= count) then  (
                        objs[i+1].gbufferChannel=i+spn1.value
                        name2 = ("-" + objs[i+1].name )
                        ) else name2=""
                    if (i+2 <= count) then (
                        objs[i+2].gbufferChannel=i+spn1.value+1
                        name3 = ("-" + objs[i+2].name)
                        ) else name3=""

                    re.addrenderelement (el elementname:(edt1.text + "_" + objs[i].name + name2 + name3) R_gbufID:(i+spn1.value-1) R_gbufIDOn:(on) G_gbufID:(i+spn1.value) G_gbufIDOn:(on) B_gbufID:(i+spn1.value+1) B_gbufIDOn:(on) )

            )
    )
)

Createdialog ro_Mattes 338 133 modal:false

I got a little inspired by this and starting coding something to make it a little more useful for myself so I thought I’d share (attached). I usually generate mattes based on materials (matID) rather than g-buffer so that was my first addtion. So as it stands right now here’s what it’s got so far:

  • You can generate mattes based on either the g-buffer ID (unlimited) or the MatID (max 15) of the current selection. I included the checkbox for the first 15 materials as a worst case when you know the material is one of the first objects selected. Normally it’ll pop up a message telling you how many materials (including multi/sub materials) you have selected and tell you to revise your selection.
  • The Mattes are generated using all three channels (RGB) and the channel name is generated from either the object names or the material names.
  • The “Select and group all instances” checkbox will (duh) select all instances if any in your selection and group them under a common g-buffer ID and channel. Otherwise instanced objects each get their own separate channel (this was getting a little crazy for large scenes). Keep in mind this will select all instances of any selected objects whether or not you have them as part of your selection. With this you can get similar results to the MatID output but using g-buffers.
  • The render element prefix just adds a prefix to the render element in addition to the material or object name if you want it.

The code is really, really rough and hasn’t been thoroughly tested so use at your own risk, etc, etc. There’s probably better/faster/cleaner ways to do what I did but it gets the job done. Apologies to Neil Blevins for some of the lifted functions and you’ll also need the Neil/BlurScript library functions (BSLib.ms) for it to function correctly. Run the script and it’ll be under “dPict Tools”-->“MultiMatte Generator” in the customize user interface dialog.

Let me know if any of you have any problems or see where it could be improved.

EDIT: I noticed there was a necessary function for the MatID to work properly that wasn’t part of the script. I updated the attached script.


MME Generator v1.0.zip (2.16 KB)

Badass! If I’m ever in Chi town I’ll buy you a beer!