Announcement

Collapse
No announcement yet.

AutoCryptomatte mask for selection script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • AutoCryptomatte mask for selection script

    Hey everyone!
    Recently Exr IO (Free Photoshop plugin ) added support for Cryptomatte render element for easier workflow when dealing with masks .
    So I created this simple script to quickly make masks for the selected objects only using Cryptomatte render elements and user defined properties .
    I hope you find it useful : ))

    Download link :
    http://bit.ly/30NOn3F

    How to use :


    Note:
    make sure to have Exr IO 2.0 plugin installed on Photoshop to be able to create masks from the Cryptomatte pass
    https://www.exr-io.com/exr-io-2-00/


    Technical details :
    The script is using " CryptoMatteMask" as user defined property and assign random value for each object .
    the script will create a selection set for all the objects in the scene that have this propriety and name it "AutoCryptomatteSet" for easier selection and for internal calculations ,so please don't add or remove any objects to this set unless you know what are you doing !
    To avoid using the same property value if the user used the script multiple times for different objects, the script will re-assign new value for all the objects that have "CryptoMatteMask" property .so if you are using Nuke/Fusion and need to keep your masks consistent be aware of this .
    the script will clear all user defined properties for the objects in the above mentioned selection set including any other proprieties assigned by the user ..I'll try to avoid that for future update but for now you can delete the part from line 16 to 22 and use the script just once for all the objects in the scene that will need a mask .
    kindly note that I'm still VERY beginner in scripting, so any note or comment to improve this script is highly appreciated !
    let me know if you have any issue too (I hope not xD ), so I try fix it in the future update.
    -------------------------------------------------------------
    Simply, I love to put pixels together! Sounds easy right : ))
    Sketchbook-1 /Sketchbook-2 / Behance / Facebook

  • #2
    Looking good.
    Since this is for selection only, then maybe a tick box whereby you user can choose to do a quick render. This will in turn override the scene with a whitevraymtl (with camera exposure control on), disabled GI, disabled render elements except for crytpomatte.

    That way if you already has a rendr done with some masks (and you didnt just mask everything from the beginning), then you can quickly go back and create additional masks for objects and not having to FULL render the entire scene, just to get masks.

    Later, you can also add transparancy per material, (for things like opacity leaves etc)
    Kind Regards,
    Morne

    Comment


    • #3
      Very nice.
      I wonder why it is that you delete the user props, though, as that's a risky move.
      Couldn't you just append to them your own key/value pairs (ie. +="CryptoMatteMask = counter")?
      You would certainly need some code to search old sets CryptoMatteMask values to clean them up, but at least you'd allow everyone else into the user prop buffer too. :P
      Lele
      Trouble Stirrer in RnD @ Chaos
      ----------------------
      emanuele.lecchi@chaos.com

      Disclaimer:
      The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

      Comment


      • #4
        Originally posted by Morne View Post
        Looking good.
        Since this is for selection only, then maybe a tick box whereby you user can choose to do a quick render. This will in turn override the scene with a whitevraymtl (with camera exposure control on), disabled GI, disabled render elements except for crytpomatte.

        That way if you already has a rendr done with some masks (and you didnt just mask everything from the beginning), then you can quickly go back and create additional masks for objects and not having to FULL render the entire scene, just to get masks.

        Later, you can also add transparancy per material, (for things like opacity leaves etc)
        Thanks Morne for the suggestions!
        doing quick render is really cool idea and it would be easy to implement I guess . not sure about materials opacity with complex shaders , I will need to look into that .
        -------------------------------------------------------------
        Simply, I love to put pixels together! Sounds easy right : ))
        Sketchbook-1 /Sketchbook-2 / Behance / Facebook

        Comment


        • #5
          Originally posted by ^Lele^ View Post
          Very nice.
          I wonder why it is that you delete the user props, though, as that's a risky move.
          Couldn't you just append to them your own key/value pairs (ie. +="CryptoMatteMask = counter")?
          You would certainly need some code to search old sets CryptoMatteMask values to clean them up, but at least you'd allow everyone else into the user prop buffer too. :P
          Thanks Lele !
          Yes appending new values was exactly how I did it at first xD but the issue with having multiple value and VRay is using the first one value caused some objects to share the same mask .
          I've tried to look into a way to remove only "CryptoMatteMask" prop using Findstring but I couldn't make it work

          My Maxscript skills are very low and I literally used google for Evey single line in the script lool , I just wrote a description for how the script should "think " and used google to translate it a code .
          the sad thing that I've noticedthat most of my google search show me very old threads on sites like Cgtalk /Maxforums /Cgarchitect as if no one is using forums for sharing info nowadays and everyone is went to modern Facebook / Discord ..etc
          -------------------------------------------------------------
          Simply, I love to put pixels together! Sounds easy right : ))
          Sketchbook-1 /Sketchbook-2 / Behance / Facebook

          Comment


          • #6
            Oh i know how you feel on both counts, believe you me.
            Little tip: if you select a term in the maxscript editor, and press f1, it will open the online help with a search done. you'll need to select the correct category on the left, and pronto, a page on user props!
            They have recently added more validation methods.
            However, bear in mind the whole "userPropBuffer" is a big string.
            You can perform any string-related method on it, like searching and deleting or replacing, without any issue whatsoever (ie. get the prop buffer into a variable, edit the variable content as a standard string, and set the user prop buffer to the variable).
            Lele
            Trouble Stirrer in RnD @ Chaos
            ----------------------
            emanuele.lecchi@chaos.com

            Disclaimer:
            The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

            Comment


            • #7
              Originally posted by ^Lele^ View Post
              Oh i know how you feel on both counts, believe you me.
              Little tip: if you select a term in the maxscript editor, and press f1, it will open the online help with a search done. you'll need to select the correct category on the left, and pronto, a page on user props!
              They have recently added more validation methods.
              However, bear in mind the whole "userPropBuffer" is a big string.
              You can perform any string-related method on it, like searching and deleting or replacing, without any issue whatsoever (ie. get the prop buffer into a variable, edit the variable content as a standard string, and set the user prop buffer to the variable).
              Thank you for the tip ! I will look into how to deal with string and see if I can fix this =D
              -------------------------------------------------------------
              Simply, I love to put pixels together! Sounds easy right : ))
              Sketchbook-1 /Sketchbook-2 / Behance / Facebook

              Comment

              Working...
              X